Module: Promotion::Generator::Profile
- Defined in:
- lib/promotion/generator/profile.rb
Class Method Summary collapse
-
.contents(specs) ⇒ Object
Generates the contents for /etc/profile, containing environment variables and aliases.
-
.generate(specs) ⇒ Object
Writes the system profile.
Class Method Details
.contents(specs) ⇒ Object
Generates the contents for /etc/profile, containing environment variables and aliases
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/promotion/generator/profile.rb', line 19 def self.contents(specs) contents = [] contents << "# This section of the file should not be edited\n" contents << "# It was generated by the promotion application and will be overwritten\n" contents << "# when the next promotion occurs.\n" contents << "# The previous section will be preserved\n" specs.each { |spec| spec.elements.each("/Specification/Environment") { |env| env.elements.each("Variable") { |var| t = var.cdatas.length > 0 ? var.cdatas[0].to_s() : var.text() contents << "export #{var.attributes["Name"]}=\"#{t}\" \n" } env.elements.each("Alias") { |ali| contents << "# #{ali.attributes["Comment"]}\n" if ali.attributes["Comment"] t = ali.cdatas.length > 0 ? ali.cdatas[0].to_s() : ali.text() contents << "alias #{ali.attributes["Name"]}='#{t}' \n" } } } return(contents.join("")) end |
.generate(specs) ⇒ Object
Writes the system profile
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/promotion/generator/profile.rb', line 6 def self.generate(specs) sym = "Profile" begin originalContents = Promotion::Generator::original_contents_for(sym) newContents = originalContents + Marker + "\n" + contents(specs) Promotion::Generator::write_file_for(sym, newContents) rescue => e $log.error("Error occurred while generating #{sym}\n#{e.}" + e.backtrace.join("\n")) exit 1 end end |