lib/cany/recipes/bundler.rb in cany-0.3.0 vs lib/cany/recipes/bundler.rb in cany-0.4.0
- old
+ new
@@ -1,21 +1,23 @@
module Cany
module Recipes
class Bundler < Cany::Recipe
register_as :bundler
- option :env_vars
+ option :env_vars, GEM_PATH: 'bundler'
+ option :skip_groups, development: true, test: true
+ class DSL < Recipe::DSL
+ def skip_group(name, skip=true)
+ @recipe.configure :skip_groups, name => skip
+ end
+ end
+
def clean
rmtree 'bundler'
- # rmtree 'vendor/bundle' -- do not remove gems, increase testing time
inner.clean
end
- def prepare
- configure :env_vars, GEM_PATH: 'bundler'
- end
-
def create(creator)
require 'bundler'
lock_path = File.join(spec.base_dir, 'Gemfile.lock')
if File.exists? lock_path
lock = ::Bundler::LockfileParser.new File.read lock_path
@@ -28,12 +30,16 @@
end
def build
ENV['GEM_PATH'] = 'bundler'
ENV['PATH'] = 'bundler/bin:' + ENV['PATH']
+ ENV['GEM_HOME'] = File.absolute_path('debian/gems')
+ old_home = ENV['HOME']
+ ENV['HOME'] = File.absolute_path('debian')
ruby_bin 'gem', %w(install bundler --no-ri --no-rdoc --install-dir bundler --bindir bundler/bin)
- ruby_bin 'bundle', %w(install --deployment --without development test)
+ ENV['HOME'] = old_home
+ ruby_bin 'bundle', %w(install --deployment --without), skipped_groups
inner.build
end
def binary
install 'bundler', "/usr/share/#{spec.name}"
@@ -48,9 +54,17 @@
option(:env_vars).each do |name, value|
content << "export #{name}=\"#{value}\""
end
content += [ "exec /usr/share/#{spec.name}/bundler/bin/bundle exec \"$@\"", '' ]
content.join "\n"
+ end
+
+ def skipped_groups
+ option(:skip_groups).select do |option, skipped|
+ skipped
+ end.map do |name, _|
+ name.to_s
+ end
end
end
end
end