Class: VagrantPlugins::Bindler::PluginCommand::Bundle
- Inherits:
-
CommandPlugin::Command::Base
- Object
- CommandPlugin::Command::Base
- VagrantPlugins::Bindler::PluginCommand::Bundle
show all
- Includes:
- Logging
- Defined in:
- lib/bindler/plugin_command/bundle.rb
Overview
Instance Method Summary
collapse
Methods included from Logging
#bindler_debug, #bindler_info
Constructor Details
#initialize ⇒ Bundle
Returns a new instance of Bundle.
13
14
15
16
17
18
19
20
21
|
# File 'lib/bindler/plugin_command/bundle.rb', line 13
def initialize(*)
super
if @env.local_data_path
@local_gems_path = @env.local_data_path.join('gems')
else
bindler_debug 'Local data path is not set'
end
end
|
Instance Method Details
#execute ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/bindler/plugin_command/bundle.rb', line 23
def execute
if @env.bindler_plugins_file
bindler_debug "#{@env.bindler_plugins_file} data: #{@env.bindler_plugins.inspect}"
if @env.bindler_plugins.any?
@env.ui.info('Installing plugins...')
@env.bindler_plugins.each do |plugin|
if plugin.is_a?(String)
install plugin
else
install *plugin.first
end
end
exit_code = 0
else
@env.ui.info("No plugins specified on #{@env.bindler_plugins_file}")
end
else
@env.ui.error "No plugins manifest file found, looked up on #{Vagrant::Environment::PLUGINS_JSON_LOOKUP}"
exit_code = 1
end
exit_code
end
|
#gem_helper(path) ⇒ Object
52
53
54
|
# File 'lib/bindler/plugin_command/bundle.rb', line 52
def gem_helper(path)
CommandPlugin::GemHelper.new(path)
end
|
#install(plugin_name, version = nil) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/bindler/plugin_command/bundle.rb', line 67
def install(plugin_name, version = nil)
plugin_name_label = plugin_name
plugin_name_label += " (#{version})" if version
versions = installed_gems.fetch(plugin_name, {}).keys
bindler_debug "Installed versions for #{plugin_name}: #{versions}"
if (versions.include? version) || (version.nil? && versions.any?)
@env.ui.info(" -> #{plugin_name_label} already installed")
return
end
gem_helper(@local_gems_path).with_environment do
installer = Gem::DependencyInstaller.new(:document => [])
begin
@env.ui.info(" -> #{plugin_name_label} ")
installer.install(plugin_name, version)
rescue Gem::GemNotFoundException
raise Vagrant::Errors::PluginInstallNotFound,
:name => plugin_name
end
end
end
|
#installed_gems ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/bindler/plugin_command/bundle.rb', line 56
def installed_gems
@installed ||= {}.tap do |installed|
gem_helper("#{@local_gems_path}#{::File::PATH_SEPARATOR}#{@env.gems_path}").with_environment do
Gem::Specification.find_all.each do |spec|
(installed[spec.name] ||= {})[spec.version.to_s] = spec
end
end
end
end
|