Class: BookChef::TreeMerger
- Inherits:
-
Object
- Object
- BookChef::TreeMerger
- Defined in:
- lib/bookchef/tree_merger.rb
Defined Under Namespace
Classes: LinkLevelOutOfReach
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(path, fn) ⇒ TreeMerger
constructor
A new instance of TreeMerger.
- #run ⇒ Object
- #save_to(fn) ⇒ Object
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.(path) @filename = fn @document = File.read("#@path/#@filename").gsub(/<%(.*?)%>/, '<%\1%>') @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
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'lib/bookchef/tree_merger.rb', line 5 def document @document end |
#version ⇒ Object (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
#run ⇒ Object
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 |