Class: Brew
- Inherits:
-
Object
- Object
- Brew
- Defined in:
- lib/leap/support/brew.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
- #eligible? ⇒ Boolean
-
#initialize(thor, config, project_name) ⇒ Brew
constructor
A new instance of Brew.
- #install ⇒ Object
- #install_dependencies ⇒ Object
- #present? ⇒ Boolean
Constructor Details
#initialize(thor, config, project_name) ⇒ Brew
Returns a new instance of Brew.
4 5 6 7 |
# File 'lib/leap/support/brew.rb', line 4 def initialize(thor, config, project_name) @dependencies = extract_dependencies(config, project_name) @thor = thor end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
2 3 4 |
# File 'lib/leap/support/brew.rb', line 2 def dependencies @dependencies end |
Instance Method Details
#eligible? ⇒ Boolean
9 10 11 |
# File 'lib/leap/support/brew.rb', line 9 def eligible? !RbConfig::CONFIG['host_os'].match(/darwin|mac os/).nil? end |
#install ⇒ Object
13 14 15 16 |
# File 'lib/leap/support/brew.rb', line 13 def install @thor.say 'Installing brew', :green exec('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"') end |
#install_dependencies ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/leap/support/brew.rb', line 18 def install_dependencies @dependencies.each do |dependency| local_package = `brew list | grep #{dependency}` if local_package.empty? @thor.say "Installing #{dependency}", :green exec("brew install #{dependency}") end end.empty? and begin @thor.say "No dependencies found in leap config", :red end end |
#present? ⇒ Boolean
30 31 32 |
# File 'lib/leap/support/brew.rb', line 30 def present? !(find_executable 'brew').nil? end |