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.
76 77 78 |
# File 'lib/stackup/rake_tasks.rb', line 76 def initialize @options = {} end |
Instance Method Details
#[]=(option, file_or_value) ⇒ Object
80 81 82 |
# File 'lib/stackup/rake_tasks.rb', line 80 def []=(option, file_or_value) @options[option] = file_or_value end |
#files ⇒ Object
84 85 86 |
# File 'lib/stackup/rake_tasks.rb', line 84 def files @options.values.grep(String) end |
#maybe_tempfile(file_or_data, type) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/stackup/rake_tasks.rb', line 97 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
88 89 90 91 92 93 94 95 |
# File 'lib/stackup/rake_tasks.rb', line 88 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 |