Class: Velcro::Homebrew
- Inherits:
-
Object
- Object
- Velcro::Homebrew
- Defined in:
- lib/velcro/homebrew.rb
Constant Summary collapse
- HOMEBREW_COMMAND =
'brew'
Instance Method Summary collapse
- #child_dependencies(dependency) ⇒ Object
- #deps(dependency) ⇒ Object
- #install(dependency) ⇒ Object
- #install_dependencies(dependencies) ⇒ Object
- #shellout(command, quiet = false) ⇒ Object
- #versions(dependency) ⇒ Object
Instance Method Details
#child_dependencies(dependency) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/velcro/homebrew.rb', line 19 def child_dependencies(dependency) deps(dependency).split.map do |child| child = OpenStruct.new(name: child) child.version = versions(child).split.first child end end |
#deps(dependency) ⇒ Object
27 28 29 30 |
# File 'lib/velcro/homebrew.rb', line 27 def deps(dependency) command = "#{HOMEBREW_COMMAND} deps #{dependency.name}" shellout(command, true) end |
#install(dependency) ⇒ Object
13 14 15 16 17 |
# File 'lib/velcro/homebrew.rb', line 13 def install(dependency) command = "#{HOMEBREW_COMMAND} install #{dependency.name}" command << " -v #{dependency.version}" if dependency.version shellout(command) end |
#install_dependencies(dependencies) ⇒ Object
7 8 9 10 11 |
# File 'lib/velcro/homebrew.rb', line 7 def install_dependencies(dependencies) dependencies.each do |dependency| install(dependency) end end |
#shellout(command, quiet = false) ⇒ Object
37 38 39 40 41 |
# File 'lib/velcro/homebrew.rb', line 37 def shellout(command, quiet = false) output = `#{command}` puts output unless quiet output end |
#versions(dependency) ⇒ Object
32 33 34 35 |
# File 'lib/velcro/homebrew.rb', line 32 def versions(dependency) command = "#{HOMEBREW_COMMAND} versions --compact #{dependency.name}" shellout(command, true) end |