Sha256: 7a60fe9e834ca99b0dd869b840a6dcf1d4772b4eceabe8ae23c3f262175e723b

Contents?: true

Size: 1.07 KB

Versions: 20

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
module Slideshow
  module HeadersFilter

def leading_headers( content_with_headers )
  
  # todo: lets user override headers with command line options
  #  that is, 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 = ""

  keys = [] # 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
      
      keys << key
    
      logger.debug "  adding header: key=>#{key}< value=>#{value}<"
      headers.put( key, value )
    elsif line =~ /^\s*$/
      content << line  unless read_headers
    else
      read_headers = false
      content << line
    end
  end 

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

  content
end
  
end  # module HeadersFilter
end # module Slideshow

class Slideshow::Gen
  include Slideshow::HeadersFilter
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
slideshow-2.3.0 lib/slideshow/filters/headers_filter.rb
slideshow-2.2.0 lib/slideshow/filters/headers_filter.rb
slideshow-2.1.0 lib/slideshow/filters/headers_filter.rb
slideshow-2.0.1 lib/slideshow/filters/headers_filter.rb
slideshow-2.0.0 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.5 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.4 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.3 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.2 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.1 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.0 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.0.beta5 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.0.beta4 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.0.beta3 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.0.beta2 lib/slideshow/filters/headers_filter.rb
slideshow-1.2.0.beta1 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta8 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta7 lib/slideshow/filters/headers_filter.rb
slideshow-1.1.0.beta6 lib/slideshow/filters/headers_filter.rb