Class: Cany::Recipes::Bundler
- Inherits:
-
Cany::Recipe
show all
- Defined in:
- lib/cany/recipes/bundler.rb,
lib/cany/recipes/bundler/gem_db.rb
Defined Under Namespace
Classes: DSL, Gem
Instance Attribute Summary
Attributes inherited from Cany::Recipe
#inner, #spec
Instance Method Summary
collapse
#configure, #depend, #exec, from_name, hook, #hook, #initialize, #install, #install_content, #install_dir, #install_link, #install_service, #option, option, #prepare, #recipe, register_as, #rmtree, #ruby_bin, #run_hook
#create_dep
Constructor Details
This class inherits a constructor from Cany::Recipe
Instance Method Details
#binary ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/cany/recipes/bundler.rb', line 44
def binary
install 'bundler', "/usr/share/#{spec.name}"
install '.bundle', "/usr/share/#{spec.name}"
install 'vendor/bundle', "/usr/share/#{spec.name}/vendor"
install_content "/usr/bin/#{spec.name}", wrapper_script
inner.binary
end
|
#build ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/cany/recipes/bundler.rb', line 32
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)
ENV['HOME'] = old_home
ruby_bin 'bundle', %w(install --deployment --retry 3 --without), skipped_groups
inner.build
end
|
#clean ⇒ Object
14
15
16
17
|
# File 'lib/cany/recipes/bundler.rb', line 14
def clean
rmtree 'bundler'
inner.clean
end
|
#create(creator) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/cany/recipes/bundler.rb', line 19
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
lock.specs.each do |spec|
Gem.get(spec.name.to_sym).dependencies.each do |dep|
depend dep
end
end
end
end
|
#skipped_groups ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/cany/recipes/bundler.rb', line 61
def skipped_groups
option(:skip_groups).select do |option, skipped|
skipped
end.map do |name, _|
name.to_s
end
end
|
#wrapper_script ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/cany/recipes/bundler.rb', line 52
def wrapper_script
content = [ '#!/bin/sh', "cd /usr/share/#{spec.name}" ]
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
|