module Faststrap::InstallActions

Public Class Methods

brew_install(g) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 42
def self.brew_install(g)
  brew?
  system "brew install #{g}"
end
brew_uninstall(g) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 51
def self.brew_uninstall(g)
  brew?
  system "brew uninstall #{g}"
end
cmd?(c) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 36
def self.cmd?(c)
  `which #{c}`
  $?.success?
end
gem_install(g) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 47
def self.gem_install(g)
  system "sudo gem install #{g} --verbose"
end
gem_uninstall(g) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 56
def self.gem_uninstall(g)
  system "sudo gem uninstall #{g} --verbose"
end
list() click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 13
def self.list
  cs = @@mod.constants.select {|c| Class === @@mod.const_get(c)}
  cs.collect! { |c| eval("#{@@mod}::#{c.to_s}") }
  sort_actions(cs)
end
list_installed() click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 19
def self.list_installed
  l = list.select{|a| a.installed?}
  delete_and_push_action(find_brew_action(l),l)
end
load_default_actions() click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 7
def self.load_default_actions
  Dir[File.expand_path '*install_action.rb', File.dirname(__FILE__)].each do |file|
    require file
  end
end
present(g) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 29
def self.present(g)
  puts "\n#{g} Group:"
  list.select{|a| a.group == g}.each do |ac|
    puts " - #{ac.name}".yellow
  end
end
sort_actions(actions) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 24
def self.sort_actions(actions)
  l = actions.sort {|x,y| x.name <=> y.name}
  delete_and_unshift_action(find_brew_action(l),l)
end

Private Class Methods

brew?() click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 61
def self.brew?
  raise "HomeBrew not installed".red unless cmd? "brew"
end
delete_and_push_action(e,l) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 69
def self.delete_and_push_action(e,l)
  return l if e.nil?
  l.delete(e)
  l.push(e)
end
delete_and_unshift_action(e,l) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 75
def self.delete_and_unshift_action(e,l)
  return l if e.nil?
  l.delete(e)
  l.unshift(e)
end
find_brew_action(l) click to toggle source
# File lib/faststrap/install_actions/install_actions_helper.rb, line 65
def self.find_brew_action(l)
  l.find{|e| e.name.upcase.include?("brew".upcase)}
end