Skip to content

Commit fb4bee5

Browse files
committed
use erb trim mode '-' to skip new lines + make sure GEM_PATH is set by default
forcing `ENV['GEM_PATH'] = ENV['GEM_HOME']` (closes GH-344)
1 parent fc03240 commit fb4bee5

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

lib/warbler/jar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def add_with_pathmaps(config, f, map_type)
272272

273273
def expand_erb(file, config)
274274
require 'erb'
275-
erb = ERB.new(File.open(file) {|f| f.read })
275+
erb = ERB.new(File.read(file), nil, '-')
276276
StringIO.new(erb.result(erb_binding(config)))
277277
end
278278

lib/warbler/templates/bundler.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
ENV['BUNDLE_WITHOUT'] = '<%= config.bundle_without.join(':') %>'
2-
<% if config.bundler[:frozen] %>ENV['BUNDLE_FROZEN'] = '1'<% end %>
2+
<% if config.bundler[:frozen] -%>
3+
ENV['BUNDLE_FROZEN'] = '1'
4+
<% end -%>

lib/warbler/templates/jar.erb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
<% assignment_operator = config.override_gem_home ? "=" : "||=" %>
2-
<% if config.relative_gem_path.empty? %>
3-
ENV['GEM_HOME'] <%= assignment_operator %> File.expand_path('../..', __FILE__)
4-
<% else %>
5-
ENV['GEM_HOME'] <%= assignment_operator %> File.expand_path('../../<%= config.relative_gem_path %>', __FILE__)
6-
<% end %>
7-
<% if config.bundler && config.bundler[:gemfile_path] %>
1+
<% if config.relative_gem_path.empty? -%>
2+
ENV['GEM_HOME'] <%= config.override_gem_home ? '=' : '||=' %> File.expand_path('../..', __FILE__)
3+
<% else -%>
4+
ENV['GEM_HOME'] <%= config.override_gem_home ? '=' : '||=' %> File.expand_path('../../<%= config.relative_gem_path %>', __FILE__)
5+
<% end -%>
6+
<% if config.override_gem_home -%>
7+
ENV['GEM_PATH'] = ENV['GEM_HOME']
8+
<% end -%>
9+
<% if config.bundler && config.bundler[:gemfile_path] -%>
810
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../<%= config.bundler[:gemfile_path] %>', __FILE__)
9-
<% end %>
11+
<% end -%>

lib/warbler/templates/rails.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ENV['RAILS_ENV'] ||= '<%= config.webxml.rails.env %>'
1+
ENV['RAILS_ENV'] ||= '<%= config.webxml.rails.env %>'

lib/warbler/templates/war.erb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
<% assignment_operator = config.override_gem_home ? "=" : "||=" %>
21
if $servlet_context.nil?
3-
ENV['GEM_HOME'] <%= assignment_operator %> File.expand_path(File.join('..', '..', '<%= config.gem_path %>'), __FILE__)
4-
<% if config.bundler && config.bundler[:gemfile_path] %>
2+
ENV['GEM_HOME'] <%= config.override_gem_home ? '=' : '||=' %> File.expand_path(File.join('..', '..', '<%= config.gem_path %>'), __FILE__)
3+
<% if config.override_gem_home -%>
4+
ENV['GEM_PATH'] = ENV['GEM_HOME']
5+
<% end -%>
6+
<% if config.bundler && config.bundler[:gemfile_path] -%>
57
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(File.join('..', '..', '<%= config.bundler[:gemfile_path] %>'), __FILE__)
6-
<% end %>
8+
<% end -%>
79
else
8-
ENV['GEM_HOME'] <%= assignment_operator %> $servlet_context.getRealPath('<%= config.gem_path %>')
9-
<% if config.bundler && config.bundler[:gemfile_path] %>
10+
ENV['GEM_HOME'] <%= config.override_gem_home ? '=' : '||=' %> $servlet_context.getRealPath('<%= config.gem_path %>')
11+
<% if config.override_gem_home -%>
12+
ENV['GEM_PATH'] = ENV['GEM_HOME']
13+
<% end -%>
14+
<% if config.bundler && config.bundler[:gemfile_path] -%>
1015
ENV['BUNDLE_GEMFILE'] ||= $servlet_context.getRealPath('/<%= config.bundler[:gemfile_path] %>')
11-
<% end %>
16+
<% end -%>
1217
end

0 commit comments

Comments
 (0)