Class: Periphery::Installer
- Inherits:
-
Object
- Object
- Periphery::Installer
- Defined in:
- lib/periphery/installer.rb
Overview
Downloads Periphery binary executable and install it to the specified path.
Instance Method Summary collapse
-
#initialize(version_spec) ⇒ Installer
constructor
A new instance of Installer.
- #install(dest_path, force: false) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(version_spec) ⇒ Installer
Returns a new instance of Installer.
12 13 14 |
# File 'lib/periphery/installer.rb', line 12 def initialize(version_spec) @version_spec = version_spec end |
Instance Method Details
#install(dest_path, force: false) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/periphery/installer.rb', line 16 def install(dest_path, force: false) URI.parse(download_url).open do |src| entry = Zip::File.open_buffer(src).get_entry('periphery') entry. = true FileUtils.rm_f(dest_path) if force entry.extract(dest_path) end end |
#version ⇒ Object
25 26 27 |
# File 'lib/periphery/installer.rb', line 25 def version @version ||= @version_spec == :latest ? fetch_latest_version : @version_spec end |