class BasicAuthMark::Mark

Public Class Methods

new() click to toggle source
# File lib/basic_auth_mark/mark.rb, line 5
def initialize
end

Public Instance Methods

insert_into(html) click to toggle source
# 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