class ImageServer::Installer
Attributes
configuration[R]
Public Class Methods
install(configuration = ImageServer.configuration)
click to toggle source
# File lib/image_server/installer.rb, line 10 def self.install(configuration = ImageServer.configuration) new(configuration).install end
new(configuration = ImageServer.configuration)
click to toggle source
# File lib/image_server/installer.rb, line 14 def initialize(configuration = ImageServer.configuration) @configuration = configuration end
Public Instance Methods
bin_path()
click to toggle source
# File lib/image_server/installer.rb, line 57 def bin_path configuration.path_to_binary end
current_version()
click to toggle source
# File lib/image_server/installer.rb, line 39 def current_version '1.17.1' end
executable_name()
click to toggle source
# File lib/image_server/installer.rb, line 43 def executable_name "images-#{platform}-#{current_version}" end
install()
click to toggle source
# File lib/image_server/installer.rb, line 18 def install return unless valid_platform? return if installed_latest? FileUtils.mkdir_p 'bin' File.open(bin_path, 'wb') do |saved_file| open(remote_url, 'rb') do |read_file| saved_file.write(read_file.read) end end File.chmod(744, bin_path) end
installed_latest?()
click to toggle source
# File lib/image_server/installer.rb, line 51 def installed_latest? File.exist?(bin_path) && `#{bin_path} --version`.split(' ').last.chomp == current_version rescue false end
platform()
click to toggle source
# File lib/image_server/installer.rb, line 35 def platform `uname -s`.strip.downcase end
remote_url()
click to toggle source
# File lib/image_server/installer.rb, line 47 def remote_url "https://github.com/image-server/image-server/releases/download/v#{current_version}/#{executable_name}" end
valid_platform?()
click to toggle source
# File lib/image_server/installer.rb, line 31 def valid_platform? %w(darwin linux).include?(platform) end