fix bug in erb processing for env blocks
This commit is contained in:
parent
f4cc4ec0a7
commit
b3274c7e34
@ -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
|
||||
|
@ -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:
|
||||
"""
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
module Penchant
|
||||
VERSION = "0.2.2"
|
||||
VERSION = "0.2.3"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user