Sha256: 139dd5d280d135beb9875987de36370d3c444b58e55521a69971b39236d770ba

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

module Dots
  module Bootstrap
    include Thor::Actions

    # These are the programs we are going to download from Homebrew.
    PROGRAMS = %w(git ruby python vim pip hub)
    PACKAGES = %w(httpie aws)

    # Install C binaries, Python programs, and other useful tools
    # from Homebrew.
    def install_programs
      if installed? "brew"
        programs_to_install = PROGRAMS.reduce([]) { |programs, program|
          programs << program unless installed? program
        }.join " "

        system "brew install #{programs_to_install}" \
          unless programs_to_install.empty?
        install_packages
      else
        install_homebrew and install_programs
      end
    end

    # Install the latest version of all gems to the global gemset. These
    # gems are configured in +~/.Gemfile+.
    def install_bundle
      system "cd #{Dots::HOME} && #{bundle_install}"
    end

    # Install Python packages from pip. Pip!
    def install_packages
      system "pip install #{PACKAGES.join(' ')}"
    end

  private
    def installed? command
      `which #{command}` != ""
    end

    def bundle_install
      return install_global_gemset if installed? 'bundle'
      "#{install_bundler} #{install_global_gemset}"
    end

    def install_global_gemset
      "bundle install --gemfile=#{global_gemset}"
    end

    def install_bundler
      "gem install bundler"
    end

    # Install the latest version of the Homebrew package manager.
    def install_homebrew
      %x[ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"]
    end

    def global_gemset
      "#{Dots.root}/config/Gemfile"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zsh_dots-0.5.7 lib/ruby/dots/bootstrap.rb
zsh_dots-0.5.6 lib/ruby/dots/bootstrap.rb
zsh_dots-0.5.5 lib/ruby/dots/bootstrap.rb