Class: Shoestring::Homebrew

Inherits:
Base
  • Object
show all
Defined in:
lib/shoestring/homebrew.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

check

Constructor Details

#initialize(name, url, brew_cmd, &block) ⇒ Homebrew

Returns a new instance of Homebrew.



5
6
7
8
9
10
# File 'lib/shoestring/homebrew.rb', line 5

def initialize(name, url, brew_cmd, &block)
  @name = name
  @url = url
  @brew_cmd = brew_cmd
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/shoestring/homebrew.rb', line 3

def block
  @block
end

#brew_cmdObject (readonly)

Returns the value of attribute brew_cmd.



3
4
5
# File 'lib/shoestring/homebrew.rb', line 3

def brew_cmd
  @brew_cmd
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/shoestring/homebrew.rb', line 3

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/shoestring/homebrew.rb', line 3

def url
  @url
end

Instance Method Details

#checkObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shoestring/homebrew.rb', line 12

def check
  if block.call
    puts "#{name}: check!"
  else
    puts "You need to setup #{name} #{url}"

    homebrew_installed = %x(brew -v)
    if homebrew_installed
      install_with_homebrew
    else
      install_homebrew
      install_with_homebrew
    end
  end
end