Class: BasicAuthMark::Mark

Inherits:
Object
  • Object
show all
Defined in:
lib/basic_auth_mark/mark.rb

Instance Method Summary collapse

Constructor Details

#initializeMark

Returns a new instance of Mark.



5
6
# File 'lib/basic_auth_mark/mark.rb', line 5

def initialize
end

Instance Method Details

#insert_into(html) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/basic_auth_mark/mark.rb', line 8

def insert_into(html)
  position = BasicAuthMark.position
  color = BasicAuthMark.color

  style_tag_str = <<-EOS
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.2/gh-fork-ribbon.min.css" />
<style>.github-fork-ribbon:before { background-color: ##{color};}</style>
  EOS

  div_tag_str = <<-EOS
<div class="github-fork-ribbon #{position}" onClick="this.style.display='none'" data-ribbon="BASIC AUTH"></div>
  EOS

  html
    .sub(%r{(</head>)}i, "#{style_tag_str.strip}\\1")
    .sub(%r{(<body[^>]*>)}i, "\\1#{div_tag_str.strip}")
end