class QB::Labs::Atom::APM
@todo document QB::Atom::APM class.
Attributes
bin[R]
What to use as the `apm` executable.
@return [String]
Public Class Methods
default()
click to toggle source
@todo Document default method.
@param [type] arg_name
@todo Add name param description.
@return [return_type]
@todo Document return value.
# File lib/qb/labs/atom/apm.rb, line 61 def self.default @default ||= new end
find_bin()
click to toggle source
# File lib/qb/labs/atom/apm.rb, line 66 def self.find_bin bin = ['apm-beta', 'apm'].find_map { |bin_name| which = Cmds.chomp 'which %s', bin_name if !which.empty? && File.executable?( which ) which end } if bin.nil? raise "Could not find apm bin!" end bin end
new(bin: self.class.find_bin)
click to toggle source
Instantiate a new `QB::Atom::APM`.
# File lib/qb/labs/atom/apm.rb, line 105 def initialize bin: self.class.find_bin @bin = bin end
Public Instance Methods
install(name:, force: false)
click to toggle source
# File lib/qb/labs/atom/apm.rb, line 159 def install name:, force: false if current_version = self.version( name ) logger.info "Atom package #{ name } already installed", version: current_version return false unless force logger.info "Forcing installation..." end end
installed?(package_name)
click to toggle source
@todo Document installed? method.
@param [type] arg_name
@todo Add name param description.
@return [return_type]
@todo Document return value.
# File lib/qb/labs/atom/apm.rb, line 154 def installed? package_name list.key? t.non_empty_str.check( package_name ) end
list()
click to toggle source
@todo Document list method.
@param [type] arg_name
@todo Add name param description.
@return [return_type]
@todo Document return value.
# File lib/qb/labs/atom/apm.rb, line 121 def list Cmds.out!( '%{bin} list --bare', bin: bin ). lines. each_with_object( {} ) do |line, packages| next if line =~ /\A\s+\z/ name, version = line.chomp.split( '@', 2 ) if [name, version].all? { |s| t.non_empty_str === s } packages[name] = version else logger.warn "Unable to parse `apm list --bare line`", line: line, name: name, version: version end end # each_with_object end
version(name: list[t.non_empty_str.check( name )])
click to toggle source
# File lib/qb/labs/atom/apm.rb, line 141 def version name: list[t.non_empty_str.check( name )] end