class Traveler::CLI

Public Instance Methods

build() click to toggle source
# File lib/traveler/cli.rb, line 15
def build
  load_configs
  build_world
  generate_wrappers
  puts '', bold_success(SUCCESS_ICONS.sample, '  All Done! You are ready to rock!')
end
init() click to toggle source
# File lib/traveler/cli.rb, line 6
def init
  bootstrap_gemfile    unless gemfile_exists?
  bootstrap_configfile unless configfile_exists?
  if gemfile_exists? && configfile_exists?
    puts success(:ok.icon, "  Awesome! All files in place. You can run `traveler build` now!")
  end
end
wrap() click to toggle source
# File lib/traveler/cli.rb, line 23
def wrap
  load_configs
  generate_wrappers
  puts bold_success(SUCCESS_ICONS.sample, '  Done!')
end

Private Instance Methods

bootstrap_configfile() click to toggle source
# File lib/traveler/cli.rb, line 68
def bootstrap_configfile
  puts info(:seeding.icon, '  Bootstrapping %s...' % CONFIGFILE)
  FileUtils.cp(CONFIGFILE_SKEL, CONFIGFILE_PATH)
end
bootstrap_gemfile() click to toggle source
# File lib/traveler/cli.rb, line 73
def bootstrap_gemfile
  puts info(:seeding.icon, '  Bootstrapping %s...' % GEMFILE)
  FileUtils.cp(GEMFILE_SKEL, GEMFILE_PATH)
end
build_world() click to toggle source
# File lib/traveler/cli.rb, line 30
def build_world
  FileUtils.mkdir_p(Traveler.rubydir)
  Dir.chdir Traveler.rubydir do
    OPTED_PLATFORMS.each do |platform|
      runtime = Runtime.new(platform)
      puts '', :package.icon << bold_warn('  ', runtime.basename)
      runtime.install
      Dir.chdir runtime.basename do
        within_sandbox do
          bundler = Bundler.new(platform)
          bundler.install_into(runtime.dirname)
        end
      end
    end
  end
end
configfile_exists?() click to toggle source
# File lib/traveler/cli.rb, line 82
def configfile_exists?
  File.exists?(CONFIGFILE_PATH)
end
gemfile_exists?() click to toggle source
# File lib/traveler/cli.rb, line 78
def gemfile_exists?
  File.exists?(GEMFILE_PATH)
end
generate_wrappers() click to toggle source
# File lib/traveler/cli.rb, line 47
def generate_wrappers
  return puts('', warn("  No wrappers defined in #{CONFIGFILE}"), '') if WRAPPERS.empty?
  puts '', warn(:wrapping.icon, '  Wrapping...')
  Dir.chdir Traveler.appdir do
    WRAPPERS.each_pair do |name,(ruby_version,cmd_or_file,block)|
      puts warn('   (re)building "%s" wrapper...' % name)
      Wrapper.new(ruby_version, name, cmd_or_file, block)
    end
  end
end
load_configs() click to toggle source
# File lib/traveler/cli.rb, line 86
def load_configs
  require 'traveler/config'
end
within_sandbox() { || ... } click to toggle source
# File lib/traveler/cli.rb, line 58
def within_sandbox
  return unless block_given?
  sandbox = '__traveler_sandbox__'
  FileUtils.rm_rf(sandbox)
  FileUtils.mkdir_p(sandbox)
  Dir.chdir(sandbox) {yield}
ensure
  FileUtils.rm_rf(sandbox) if File.exists?(sandbox)
end