Class: BookChef::TreeMerger

Inherits:
Object
  • Object
show all
Defined in:
lib/bookchef/tree_merger.rb

Defined Under Namespace

Classes: LinkLevelOutOfReach

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, fn) ⇒ TreeMerger

Returns a new instance of TreeMerger.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bookchef/tree_merger.rb', line 9

def initialize(path, fn)
  @path     = File.expand_path(path)
  @filename = fn
  @document = File.read("#@path/#@filename").gsub(/<%(.*?)%>/, '&lt;%\1%&gt;')
  @document = Nokogiri::XML.parse @document
  insert_version_from_git_tag!
  if File.exists?("#@path/settings.xml")
    @settings = File.read("#@path/settings.xml") 
    @document.root << @settings
  end
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



5
6
7
# File 'lib/bookchef/tree_merger.rb', line 5

def document
  @document
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/bookchef/tree_merger.rb', line 5

def version
  @version
end

Instance Method Details

#runObject



21
22
23
24
# File 'lib/bookchef/tree_merger.rb', line 21

def run
  @documents = []
  @document  = process_level(@document)
end

#save_to(fn) ⇒ Object



26
27
28
29
30
# File 'lib/bookchef/tree_merger.rb', line 26

def save_to(fn)
  f = File.open(fn, "w")
  f.write @document.to_s
  f.close
end