Class: Greg::GemfileTemplate
- Inherits:
-
FileTemplate
- Object
- DefaultTemplate
- FileTemplate
- Greg::GemfileTemplate
- Defined in:
- lib/greg/templates/gemfile_template.rb
Instance Attribute Summary collapse
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
Instance Method Summary collapse
- #contents ⇒ Object
- #destination ⇒ Object
-
#initialize(*gems) ⇒ GemfileTemplate
constructor
A new instance of GemfileTemplate.
Methods inherited from FileTemplate
Methods inherited from DefaultTemplate
Constructor Details
#initialize(*gems) ⇒ GemfileTemplate
Returns a new instance of GemfileTemplate.
5 6 7 |
# File 'lib/greg/templates/gemfile_template.rb', line 5 def initialize(*gems) @gems = gems end |
Instance Attribute Details
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
3 4 5 |
# File 'lib/greg/templates/gemfile_template.rb', line 3 def gems @gems end |
Instance Method Details
#contents ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/greg/templates/gemfile_template.rb', line 13 def contents @contents = [] @contents << 'source "https://rubygems.org"' @contents << nil @gems.each do |gem| if gem.is_a?(Hash) gem_name, = gem.first r = [] r << "gem \"#{gem_name}\"" .each do |key, value| r << "#{key.to_sym}: \"#{value.to_s}\"" end @contents << r.join(", ") else @contents << "gem \"#{gem}\"" end end @contents.join("\n") end |
#destination ⇒ Object
9 10 11 |
# File 'lib/greg/templates/gemfile_template.rb', line 9 def destination "Gemfile" end |