Sha256: c9991ec62cc69bd732b51f38c1c6258f157397ddf1ee787b944085f705e0e4bb

Contents?: true

Size: 1.05 KB

Versions: 11

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
module Slideshow
  module HeadersFilter

def leading_headers( content_with_headers )
  
  # todo: read headers before command line options (lets you override options using commandline switch)?
  
  # read source document; split off optional header from source
  # strip leading optional headers (key/value pairs) including optional empty lines

  read_headers = true
  content = ""

  headers = [] # track header keys for stats
  
  content_with_headers.each_line do |line|
    if read_headers && line =~ /^\s*(\w[\w-]*)[ \t]*:[ \t]*(.*)/
      key = $1.downcase
      value = $2.strip
      
      headers << key
    
      logger.debug "  adding option: key=>#{key}< value=>#{value}<"
      opts.put( key, value )
    elsif line =~ /^\s*$/
      content << line  unless read_headers
    else
      read_headers = false
      content << line
    end
  end 

  puts "  Reading #{headers.length} headers: #{headers.join(', ')}..."

  content
end
  
end  # module HeadersFilter
end # module Slideshow

class Slideshow::Gen
  include Slideshow::HeadersFilter
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
slideshow-1.1.0.beta5 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta4 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta3 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta2 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta1 lib/slideshow/filters/headers_filter.rb
slideshow-1.0.5 lib/slideshow/filters/headers_filter.rb
slideshow-1.0.4 lib/slideshow/filters/headers_filter.rb
slideshow-1.0.3 lib/slideshow/filters/headers_filter.rb
slideshow-1.0.2 lib/slideshow/filters/headers_filter.rb
slideshow-1.0.1 lib/slideshow/filters/headers_filter.rb
slideshow-1.0.0 lib/slideshow/filters/headers_filter.rb