Class: Periphery::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/periphery/installer.rb

Overview

Downloads Periphery binary executable and install it to the specified path.

Instance Method Summary collapse

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.restore_permissions = true
    FileUtils.rm_f(dest_path) if force
    entry.extract(dest_path)
  end
end

#versionObject



25
26
27
# File 'lib/periphery/installer.rb', line 25

def version
  @version ||= @version_spec == :latest ? fetch_latest_version : @version_spec
end