Sha256: 78e54340302c38356168f3974a68ee0059174c87dd93a083a22dfdce13e630a8

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

module WGif
  class Installer

    DEPENDENCIES = [['ffmpeg', 'ffmpeg'],
                    ['imagemagick', 'convert']]

    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

    def dependencies_installed?
      DEPENDENCIES.map { |_, binary| installed?(binary) }.inject(:&)
    end

    def homebrew_installed?
      Kernel.system 'brew info > /dev/null'
    end

    def install(dependency, binary)
      unless installed?(binary)
        puts "Installing #{dependency}..."
        Kernel.system "brew install #{dependency}"
        puts "Successfully installed #{dependency}."
      end
    end

    def installed?(binary)
      Kernel.system "which #{binary} > /dev/null"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wgif-0.5.4 lib/wgif/installer.rb
wgif-0.5.3 lib/wgif/installer.rb
wgif-0.5.2 lib/wgif/installer.rb
wgif-0.5.1 lib/wgif/installer.rb
wgif-0.5.0 lib/wgif/installer.rb
wgif-0.4.0 lib/wgif/installer.rb
wgif-0.3.1 lib/wgif/installer.rb
wgif-0.3.0 lib/wgif/installer.rb