Class: SpigitConf::Engage
- Inherits:
-
Object
- Object
- SpigitConf::Engage
- Defined in:
- lib/spigit_conf/engage.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#spigit_config ⇒ Object
readonly
Returns the value of attribute spigit_config.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Engage
constructor
A new instance of Engage.
- #save!(opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Engage
Returns a new instance of Engage.
78 79 80 81 82 |
# File 'lib/spigit_conf/engage.rb', line 78 def initialize(opts = {}) @file = opts.fetch(:file) @doc = Nokogiri::XML(File.read(@file)) { |x| x.noblanks } @spigit_config = @doc.at_css('spigit-config') end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
76 77 78 |
# File 'lib/spigit_conf/engage.rb', line 76 def doc @doc end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
76 77 78 |
# File 'lib/spigit_conf/engage.rb', line 76 def file @file end |
#spigit_config ⇒ Object (readonly)
Returns the value of attribute spigit_config.
76 77 78 |
# File 'lib/spigit_conf/engage.rb', line 76 def spigit_config @spigit_config end |
Instance Method Details
#save!(opts = {}) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/spigit_conf/engage.rb', line 84 def save!(opts = {}) backup = opts.fetch(:backup, true) take_backup if backup File.open(file, 'w') do |f| f.write(doc.to_xml(save_with: SpigitConf::XML_SAVE_OPTIONS, :indent => 4, :encoding => 'UTF-8')) end end |