Class: Kontena::PluginManager::Installer
- Inherits:
-
Object
- Object
- Kontena::PluginManager::Installer
- Includes:
- Common
- Defined in:
- lib/kontena/plugin_manager/installer.rb
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#plugin_name ⇒ Object
readonly
Returns the value of attribute plugin_name.
-
#pre ⇒ Object
readonly
Returns the value of attribute pre.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #available_upgrade ⇒ Object
- #command ⇒ Object
-
#initialize(plugin_name, pre: false, version: nil) ⇒ Installer
constructor
Create a new instance of plugin installer.
-
#install ⇒ Object
Install a plugin.
- #install_uri ⇒ Object
- #pre? ⇒ Boolean
-
#upgrade ⇒ Object
Upgrade an installed plugin.
Methods included from Common
dummy_ui, gem_versions, install_dir, installed, installed?, plugin_debug?, plugins, prefix, rubygems_client, search_plugins, use_dummy_ui
Constructor Details
#initialize(plugin_name, pre: false, version: nil) ⇒ Installer
Create a new instance of plugin installer
17 18 19 20 21 |
# File 'lib/kontena/plugin_manager/installer.rb', line 17 def initialize(plugin_name, pre: false, version: nil) @plugin_name = plugin_name @pre = pre @version = version end |
Instance Attribute Details
#plugin_name ⇒ Object (readonly)
Returns the value of attribute plugin_name.
10 11 12 |
# File 'lib/kontena/plugin_manager/installer.rb', line 10 def plugin_name @plugin_name end |
#pre ⇒ Object (readonly)
Returns the value of attribute pre.
10 11 12 |
# File 'lib/kontena/plugin_manager/installer.rb', line 10 def pre @pre end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/kontena/plugin_manager/installer.rb', line 11 def version @version end |
Instance Method Details
#available_upgrade ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/kontena/plugin_manager/installer.rb', line 57 def available_upgrade installed = installed(plugin_name) return false unless installed pre = installed.version.prerelease? latest = rubygems_client.latest_version(prefix(plugin_name), pre: pre? || pre) if latest > installed.version latest.to_s end end |
#command ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/kontena/plugin_manager/installer.rb', line 27 def command @command ||= Gem::DependencyInstaller.new( document: false, force: true, prerelease: pre, minimal_deps: true ) end |
#install ⇒ Object
Install a plugin
37 38 39 40 41 42 |
# File 'lib/kontena/plugin_manager/installer.rb', line 37 def install return install_uri if plugin_name.include?('://') plugin_version = version.nil? ? Gem::Requirement.default : Gem::Requirement.new(version) command.install(prefix(plugin_name), plugin_version) command.installed_gems end |
#install_uri ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kontena/plugin_manager/installer.rb', line 44 def install_uri require 'tempfile' require 'open-uri' file = Tempfile.new(['kontena_plugin', '.gem']) open(plugin_name) do |input| file.write input.read file.close end self.class.new(file.path).install ensure file.unlink end |
#pre? ⇒ Boolean
23 24 25 |
# File 'lib/kontena/plugin_manager/installer.rb', line 23 def pre? !!@pre end |