diff --git a/features/gemfile.feature b/features/gemfile.feature index 290db10..ac6d788 100644 --- a/features/gemfile.feature +++ b/features/gemfile.feature @@ -32,6 +32,19 @@ Feature: Gemfiles this is content """ + Scenario: Simple env + Given I have the file "Gemfile.erb" with the content: + """ + <% env :local do %> + gem 'test' + <% end %> + """ + When I rebuild the Gemfile for "local" mode + Then the file "Gemfile" should have the following stripped content: + """ + # generated by penchant, environment: local + gem 'test' + """ Scenario: Use placeholder expansion Given I have the file "Gemfile.erb" with the content: """ @@ -40,10 +53,11 @@ Feature: Gemfiles <% end %> """ When I rebuild the Gemfile for "local" mode + Then the file "Gemfile" should have the following stripped content: """ # generated by penchant, environment: local - gem 'test', :path => %{../test} + gem 'test', {:path=>"../test"} """ Scenario: Use a gem list for an operation @@ -59,7 +73,7 @@ Feature: Gemfiles Then the file "Gemfile" should have the following stripped content: """ # generated by penchant, environment: local - gem 'test', :path => %{../test} + gem 'test', {:path=>"../test"} """ Scenario: Let gem get additional info diff --git a/features/ruby_gemfile.feature b/features/ruby_gemfile.feature index a41b0bd..5234470 100644 --- a/features/ruby_gemfile.feature +++ b/features/ruby_gemfile.feature @@ -173,7 +173,6 @@ Feature: Gemfiles | cat | | dog | - @wip Scenario: Get the list of git repos defined Given I have the file "Gemfile.penchant" with the content: """ diff --git a/lib/penchant/gemfile.rb b/lib/penchant/gemfile.rb index 7082c51..8fe9d35 100644 --- a/lib/penchant/gemfile.rb +++ b/lib/penchant/gemfile.rb @@ -181,14 +181,20 @@ module Penchant end def env(check, template = {}, &block) - if check.to_s == @env.to_s + if check.to_s == @environment.to_s original_erbout = @_erbout.dup output = instance_eval(&block).lines.to_a output.each do |line| if gem_name = line[%r{gem ['"]([^'"]+)['"]}, 1] - line.replace(line.rstrip + process_options(gem_name, template) + "\n") + new_line = line.rstrip + + if !(options = process_options(gem_name, template)).empty? + new_line += ", #{options.inspect}" + end + + line.replace(new_line + "\n") end end diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb index fee3a95..0254e7d 100644 --- a/lib/penchant/version.rb +++ b/lib/penchant/version.rb @@ -1,3 +1,3 @@ module Penchant - VERSION = "0.2.2" + VERSION = "0.2.3" end