Class: Bookery::Processors::IncludeProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/bookery/processors/include_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cwd) ⇒ IncludeProcessor

Returns a new instance of IncludeProcessor.



6
7
8
# File 'lib/bookery/processors/include_processor.rb', line 6

def initialize(cwd)
  @current_dir = cwd
end

Instance Attribute Details

#current_dirObject (readonly)

Returns the value of attribute current_dir.



4
5
6
# File 'lib/bookery/processors/include_processor.rb', line 4

def current_dir
  @current_dir
end

Instance Method Details

#process(markdown) ⇒ Object



10
11
12
13
14
# File 'lib/bookery/processors/include_processor.rb', line 10

def process(markdown)
  markdown.gsub(/\b*includes::(.*)\b*/) do |match|
    File.read(File.join(current_dir, $1))
  end
end