Class: WGif::Installer
- Inherits:
-
Object
- Object
- WGif::Installer
- Defined in:
- lib/wgif/installer.rb
Constant Summary collapse
- DEPENDENCIES =
[['ffmpeg', 'ffmpeg'], ['imagemagick', 'convert']]
Instance Method Summary collapse
- #dependencies_installed? ⇒ Boolean
- #homebrew_installed? ⇒ Boolean
- #install(dependency, binary) ⇒ Object
- #installed?(binary) ⇒ Boolean
- #run ⇒ Object
Instance Method Details
#dependencies_installed? ⇒ Boolean
23 24 25 |
# File 'lib/wgif/installer.rb', line 23 def dependencies_installed? DEPENDENCIES.map { |_, binary| installed?(binary) }.inject(:&) end |
#homebrew_installed? ⇒ Boolean
27 28 29 |
# File 'lib/wgif/installer.rb', line 27 def homebrew_installed? Kernel.system 'brew info > /dev/null' end |
#install(dependency, binary) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/wgif/installer.rb', line 31 def install(dependency, binary) unless installed?(binary) puts "Installing #{dependency}..." Kernel.system "brew install #{dependency}" puts "Successfully installed #{dependency}." end end |
#installed?(binary) ⇒ Boolean
39 40 41 |
# File 'lib/wgif/installer.rb', line 39 def installed?(binary) Kernel.system "which #{binary} > /dev/null" end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wgif/installer.rb', line 7 def run if dependencies_installed? puts 'All dependencies are installed. Go make a gif.' Kernel.exit 0 end if homebrew_installed? DEPENDENCIES.each do |dependency, binary| install(dependency, binary) end else puts "WGif can't find Homebrew. Visit http://brew.sh/ to get it." Kernel.exit 1 end Kernel.exit 0 end |