Class: Brew

Inherits:
Object
  • Object
show all
Defined in:
lib/leap/support/brew.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dependenciesObject (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

Returns:

  • (Boolean)


9
10
11
# File 'lib/leap/support/brew.rb', line 9

def eligible?
  !RbConfig::CONFIG['host_os'].match(/darwin|mac os/).nil?
end

#installObject



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_dependenciesObject



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

Returns:

  • (Boolean)


30
31
32
# File 'lib/leap/support/brew.rb', line 30

def present?
  !(find_executable 'brew').nil?
end