Module: Kibou::Utility::Helpers

Included in:
Package, RakeTask, Recipe, Recipe
Defined in:
lib/kibou/utility.rb

Instance Method Summary collapse

Instance Method Details

#brew(*args) ⇒ Object



9
10
11
12
# File 'lib/kibou/utility.rb', line 9

def brew(*args)
  args.unshift "brew"
  `#{args.join(" ")}`.split(/\n/)
end

#brew_installed?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/kibou/utility.rb', line 5

def brew_installed?
  `which brew`.chomp =~ /brew$/
end

#capture(*args) ⇒ Object



55
56
57
# File 'lib/kibou/utility.rb', line 55

def capture(*args)
  `#{args.join(" ")}`
end

#info(pkg) ⇒ Object



14
15
16
# File 'lib/kibou/utility.rb', line 14

def info(pkg)
  brew :info, pkg
end

#outdatedObject



22
23
24
# File 'lib/kibou/utility.rb', line 22

def outdated
  brew :outdated
end

#package_included?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/kibou/utility.rb', line 42

def package_included?(pkg)
  search(pkg).include?(pkg)
end

#package_install(pkg) ⇒ Object



30
31
32
# File 'lib/kibou/utility.rb', line 30

def package_install(pkg)
  system("brew install #{pkg}")
end

#package_installed?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/kibou/utility.rb', line 38

def package_installed?(pkg)
  !info(pkg).include?("Not installed")
end

#package_outdated?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/kibou/utility.rb', line 46

def package_outdated?(pkg)
  list = outdated.map {|pkg| pkg.split(/ /).first }
  list.include?(pkg)
end

#package_upgrade(pkg) ⇒ Object



34
35
36
# File 'lib/kibou/utility.rb', line 34

def package_upgrade(pkg)
  system("brew upgrade #{pkg}")
end

#run(*args) ⇒ Object



51
52
53
# File 'lib/kibou/utility.rb', line 51

def run(*args)
  system(args.join(" "))
end

#search(pkg) ⇒ Object



18
19
20
# File 'lib/kibou/utility.rb', line 18

def search(pkg)
  brew :search, pkg
end

#update!Object



26
27
28
# File 'lib/kibou/utility.rb', line 26

def update!
  system("brew update > /dev/null 2>&1")
end