Class: Rdm::SourceComposer
- Inherits:
-
Object
- Object
- Rdm::SourceComposer
- Defined in:
- lib/rdm/source_composer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #format_value(value) ⇒ Object
-
#initialize(source) ⇒ SourceComposer
constructor
A new instance of SourceComposer.
- #run ⇒ Object
Constructor Details
#initialize(source) ⇒ SourceComposer
Returns a new instance of SourceComposer.
6 7 8 9 |
# File 'lib/rdm/source_composer.rb', line 6 def initialize(source) @source = source @content = [] end |
Class Method Details
.run(source) ⇒ Object
2 3 4 |
# File 'lib/rdm/source_composer.rb', line 2 def self.run(source) Rdm::SourceComposer.new(source).run end |
Instance Method Details
#format_value(value) ⇒ Object
33 34 35 36 37 |
# File 'lib/rdm/source_composer.rb', line 33 def format_value(value) return "\"#{value}\"" if value.is_a?(String) value.to_s end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rdm/source_composer.rb', line 11 def run @content.push "setup do" Rdm.settings.settings.each do |setting, value| @content.push " #{setting} #{format_value(value)}" end @content.push "end" @content.push "\n" @source.config_names.each do |config, _| @content.push "config :#{config}" end @content.push "\n" @source.package_paths.each do |package, _| @content.push "package \"#{package}\"" end File.open(Rdm.root(@source.root_path), 'w') {|f| f.puts @content} end |