Sha256: 47dadda4cdfad6f0e1f09cda345fe70bad019d3c2324baba84c00508b229d3db

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

module Rack
  module DevMark
    module Theme
      class Base
        attr_reader :env, :revision, :timestamp

        def initialize(*args)
          raise RuntimeError, 'Abstract class can not be instantiated' if self.class == Rack::DevMark::Theme::Base
        end

        def setup(env, revision, timestamp)
          @env = env
          @revision = revision
          @timestamp = timestamp
        end

        def insert_into(html)

        end

        private

        def stylesheet_link_tag(path)
          %Q~<style>#{::File.open(::File.join(::File.dirname(__FILE__), '../../../../vendor/assets/stylesheets', path)).read}</style>~
        end

        def gsub_tag_content(html, name, &block)
          String.new(html).gsub(%r{(<#{name}\s*[^>]*>)([^<]*)(</#{name}>)}im) do
            "#{$1}#{block.call($2)}#{$3}"
          end
        end

        def gsub_tag_attribute(html, name, attr, &block)
          String.new(html).gsub %r{(<#{name}\s*)([^>]*)(>)}im do
            s1, s2, s3 = $1, $2, $3
            s2.gsub! %r{(#{attr}=')([^']*)(')} do
              "#{$1}#{block.call($2)}#{$3}"
            end
            s2.gsub! %r{(#{attr}=")([^"]*)(")} do
              "#{$1}#{block.call($2)}#{$3}"
            end
            "#{s1}#{s2}#{s3}"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rack-dev-mark-0.6.4 lib/rack/dev-mark/theme/base.rb
rack-dev-mark-0.6.3 lib/rack/dev-mark/theme/base.rb
rack-dev-mark-0.6.2 lib/rack/dev-mark/theme/base.rb
rack-dev-mark-0.6.0 lib/rack/dev-mark/theme/base.rb