From 5b7dd7fb342a5cd10f79a87b654dabf5b01b7fa8 Mon Sep 17 00:00:00 2001 From: Artem Iarmoliuk Date: Tue, 17 Oct 2017 00:44:50 +0300 Subject: [PATCH 1/3] Add `description` and `min_packer_version` options Missing keys were added README and CHANGELOG updated for new keys --- CHANGELOG.md | 6 +++++- README.md | 10 ++++++++++ lib/racker/template.rb | 6 ++++++ racker.gemspec | 2 +- spec/fixtures/high_priority_template.rb | 2 ++ spec/unit/processor_spec.rb | 20 ++++++++++++++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb4ab7c..240f5de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased + +* Added support for `min_packer_version` and `description` keys. + ## 0.2.0 (2016-03-01) * Added support for output to STDOUT. The filename of '-' is used to signify outout should go to STDOUT. (PR#7) This feature will become the default functionality in the 0.3.0 release. @@ -52,4 +56,4 @@ Bug Fixes: ## 0.0.1 (Internal) * Initial private release -* Supports Amazon, Virtualbox and VMWare builders \ No newline at end of file +* Supports Amazon, Virtualbox and VMWare builders diff --git a/README.md b/README.md index 97db1f5..2439e15 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,16 @@ Racker::Processor.register_template do |t| end ``` +#### Other keys + +You can add `description` or `min_packer_version` to template. + +```ruby +Racker::Processor.register_template do |t| + t.description = 'some description' + t.min_packer_version = '1.0.0' +end +``` ### Putting it all together Racker offers 2 very basic example templates `example/template1.rb` and `example/template2.rb` as well as the resulting packer template from the two templates run through Racker. diff --git a/lib/racker/template.rb b/lib/racker/template.rb index 844f82c..ae7c365 100644 --- a/lib/racker/template.rb +++ b/lib/racker/template.rb @@ -22,6 +22,12 @@ def to_packer # Create the new smash packer = Smash.new + # Packer Version + packer['min_packer_version'] = self['min_packer_version'].dup unless self['min_packer_version'].nil? || self['min_packer_version'].empty? + + # Description + packer['description'] = self['description'].dup unless self['description'].nil? || self['description'].empty? + # Variables packer['variables'] = self['variables'].dup unless self['variables'].nil? || self['variables'].empty? diff --git a/racker.gemspec b/racker.gemspec index 125b17f..dbc2db6 100644 --- a/racker.gemspec +++ b/racker.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec' gem.add_development_dependency 'rspec-mocks' - gem.add_development_dependency 'rubocop', '~> 0.26.1' + gem.add_development_dependency 'rubocop', '>= 0.38.0' gem.add_development_dependency 'ruby_gntp', '~> 0.3.4' gem.add_development_dependency 'simplecov', '~> 0.7.1' gem.add_development_dependency 'yard', '~> 0.8' diff --git a/spec/fixtures/high_priority_template.rb b/spec/fixtures/high_priority_template.rb index 9bccd8c..295af80 100644 --- a/spec/fixtures/high_priority_template.rb +++ b/spec/fixtures/high_priority_template.rb @@ -3,4 +3,6 @@ :iso_url => 'priority.img', :password => '~~', } + t.description = 'some description' + t.min_packer_version = '1.1.1' end diff --git a/spec/unit/processor_spec.rb b/spec/unit/processor_spec.rb index 9b6e279..0f94dc2 100644 --- a/spec/unit/processor_spec.rb +++ b/spec/unit/processor_spec.rb @@ -112,6 +112,26 @@ expect(JSON.parse(template)).to eq(parsed_low_priority_template) end + it 'supports `min_packer_version` option' do + @options[:templates] = [ + fixture_path('high_priority_template.rb'), + ] + template = @instance.execute! + + result = JSON.parse(template) + expect(result['min_packer_version']).to eq('1.1.1') + end + + it 'supports `description` option' do + @options[:templates] = [ + fixture_path('high_priority_template.rb'), + ] + template = @instance.execute! + + result = JSON.parse(template) + expect(result['description']).to eq('some description') + end + end context '#initialize' do From 4aa19477b3f81cda11c188b8bbefcc8fce2bc635 Mon Sep 17 00:00:00 2001 From: Artem Iarmoliuk Date: Tue, 17 Oct 2017 10:54:14 +0300 Subject: [PATCH 2/3] Fix travis build for bundler --- .travis.yml | 5 ++++- racker.gemspec | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 114226a..572f0d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,4 +20,7 @@ rvm: - rbx script: - - rake spec + - bundle exec rake spec + +before_install: + - gem update bundler diff --git a/racker.gemspec b/racker.gemspec index dbc2db6..5878828 100644 --- a/racker.gemspec +++ b/racker.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'multi_json', '~> 1.8' gem.add_dependency 'log4r', '~> 1.1.10' - gem.add_development_dependency 'bundler', '~> 1.3' + gem.add_development_dependency 'bundler', '~> 1.15' gem.add_development_dependency 'coveralls', '~> 0.6.7' gem.add_development_dependency 'guard', '~> 2.2.3' gem.add_development_dependency 'guard-bundler', '~> 2.0.0' From 6f85eb7b5eb7136da71e9050e77b30622f19c3cb Mon Sep 17 00:00:00 2001 From: Artem Iarmoliuk Date: Tue, 17 Oct 2017 11:42:56 +0300 Subject: [PATCH 3/3] Add latest stable ruby to travis build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 572f0d4..4baa25c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ rvm: - 1.9.3 - 2.0.0 - 2.1.3 + - 2.4.1 - jruby - rbx