Sha256: 609cdc3bf6eaef9f7cece7965d96a20333cc837fd1676eb15f8c22b377891424

Contents?: true

Size: 1.14 KB

Versions: 111

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
# encoding: utf-8
#
module Picky

  # Handles the IRB console for Picky.
  #
  class Console

    def self.start args = ARGV
      irb = 'irb'

      require 'optparse'
      options = { :sandbox => false, :irb => irb }
      OptionParser.new do |opt|
        opt.banner = "Usage: console [environment] [options]"
        opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
        opt.parse!(args)
      end

      libs =  " -r irb/completion"
      libs << %( -r "#{File.expand_path('../../picky.rb', __FILE__)}" )

      mapping = {
        'p' => 'production',
        'd' => 'development',
        't' => 'test'
      }
      given_env = args.first
      ENV['PICKY_ENV'] = mapping[given_env] || given_env || ENV['PICKY_ENV'] || 'development'

      puts "Use \x1b[1;30mPicky::Loader.load_application\x1b[m to load app."
      puts "Use \x1b[1;30mPicky::Indexes.load\x1b[m after that to load indexes."
      puts "Copy the following line to do just that:"
      puts "\x1b[1;30mPicky::Loader.load_application; Picky::Indexes.load; p\x1b[m"
      exec "#{options[:irb]} #{libs} --simple-prompt"
    end

  end

end

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
picky-4.31.3 lib/picky/console.rb
picky-4.31.2 lib/picky/console.rb
picky-4.31.1 lib/picky/console.rb
picky-4.31.0 lib/picky/console.rb
picky-4.30.0 lib/picky/console.rb
picky-4.29.0 lib/picky/console.rb
picky-4.28.1 lib/picky/console.rb
picky-4.27.1 lib/picky/console.rb
picky-4.27.0 lib/picky/console.rb
picky-4.26.2 lib/picky/console.rb
picky-4.26.1 lib/picky/console.rb
picky-4.26.0 lib/picky/console.rb
picky-4.25.3 lib/picky/console.rb
picky-4.25.2 lib/picky/console.rb
picky-4.25.1 lib/picky/console.rb
picky-4.25.0 lib/picky/console.rb
picky-4.24.0 lib/picky/console.rb
picky-4.23.2 lib/picky/console.rb
picky-4.23.1 lib/picky/console.rb
picky-4.23.0 lib/picky/console.rb