Module: Vagrant::Templated::Catalog
- Defined in:
- lib/vagrant-templated/catalog.rb
Class Method Summary collapse
- .attributes_for(template, version) ⇒ Object
- .berksfile_for(template, version) ⇒ Object
- .max_version_for(template) ⇒ Object
- .patch(template, version) ⇒ Object
- .root ⇒ Object
- .templates ⇒ Object
- .vagrantfile_for(template, version) ⇒ Object
- .versions_for(template) ⇒ Object
Class Method Details
.attributes_for(template, version) ⇒ Object
29 30 31 32 |
# File 'lib/vagrant-templated/catalog.rb', line 29 def attributes_for(template, version) raise Vagrant::Templated::Errors::VersionNotFound unless versions_for(template).include? version attributes[template][version] end |
.berksfile_for(template, version) ⇒ Object
15 16 17 18 19 |
# File 'lib/vagrant-templated/catalog.rb', line 15 def berksfile_for(template, version) template_attributes = attributes_for template, version berksfile_template = File.read(Catalog.root.join 'config/templates/Berksfile.erb') ERB.new(berksfile_template, nil, '-').result binding end |
.max_version_for(template) ⇒ Object
34 35 36 37 38 |
# File 'lib/vagrant-templated/catalog.rb', line 34 def max_version_for(template) versions_for(template).max do |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) end end |
.patch(template, version) ⇒ Object
21 22 23 |
# File 'lib/vagrant-templated/catalog.rb', line 21 def patch(template, version) max_version_for(template) end |
.root ⇒ Object
45 46 47 |
# File 'lib/vagrant-templated/catalog.rb', line 45 def root @root ||= Pathname.new File. '../..', File.dirname(File.(__FILE__)) end |
.templates ⇒ Object
25 26 27 |
# File 'lib/vagrant-templated/catalog.rb', line 25 def templates attributes.keys end |
.vagrantfile_for(template, version) ⇒ Object
9 10 11 12 13 |
# File 'lib/vagrant-templated/catalog.rb', line 9 def vagrantfile_for(template, version) template_attributes = attributes_for template, version vagrantfile_template = File.read(Catalog.root.join 'config/templates/Vagrantfile.erb') ERB.new(vagrantfile_template, nil, '-').result binding end |
.versions_for(template) ⇒ Object
40 41 42 43 |
# File 'lib/vagrant-templated/catalog.rb', line 40 def versions_for(template) raise Vagrant::Templated::Errors::TemplateNotFound unless attributes.include? template attributes[template].keys end |