Class: Stackup::RakeTasks::DataOptions
- Inherits:
-
Object
- Object
- Stackup::RakeTasks::DataOptions
- Defined in:
- lib/stackup/rake_tasks.rb
Overview
Options to “stackup up”.
Instance Method Summary collapse
- #[]=(option, file_or_value) ⇒ Object
- #files ⇒ Object
-
#initialize ⇒ DataOptions
constructor
A new instance of DataOptions.
- #maybe_tempfile(file_or_data, type) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ DataOptions
Returns a new instance of DataOptions.
81 82 83 |
# File 'lib/stackup/rake_tasks.rb', line 81 def initialize @options = {} end |
Instance Method Details
#[]=(option, file_or_value) ⇒ Object
85 86 87 |
# File 'lib/stackup/rake_tasks.rb', line 85 def []=(option, file_or_value) @options[option] = file_or_value end |
#files ⇒ Object
89 90 91 |
# File 'lib/stackup/rake_tasks.rb', line 89 def files @options.values.grep(String) end |
#maybe_tempfile(file_or_data, type) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/stackup/rake_tasks.rb', line 102 def maybe_tempfile(file_or_data, type) return file_or_data if file_or_data.is_a?(String) tempfile = Tempfile.new([type, ".yml"]) tempfile.write(YAML.dump(file_or_data)) tempfile.close tempfile.path.to_s end |
#to_a ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/stackup/rake_tasks.rb', line 93 def to_a [].tap do |result| @options.each do |option, file_or_data| result << option result << maybe_tempfile(file_or_data, option[2..-1]) end end end |