Class: Padrino::Cli::Base

### Home Classes Methods

### In Files

- lib/padrino-core/cli/base.rb

### Parent

Launcher

### Methods

- ::banner
- #capture
- #console
- #generate
- #rake
- #runner
- #silence
- #version

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Application
- Padrino::ApplicationLoadError
- Padrino::ApplicationSetup
- Padrino::ApplicationSetup::ClassMethods
- Padrino::AuthenticityToken
- Padrino::Cli
- Padrino::Cli::Adapter
- Padrino::Cli::Base
- Padrino::Cli::Launcher
- Padrino::Filter
- Padrino::Flash
- Padrino::Flash::Helpers
- Padrino::Flash::Storage
- Padrino::Loader
- Padrino::Logger
- Padrino::Logger::Colorize
- Padrino::Logger::Extensions
- Padrino::Logger::Rack
- Padrino::Module
- Padrino::Mounter
- Padrino::Mounter::ApplicationWrapper
- Padrino::Mounter::MounterException
- Padrino::ParamsProtection
- Padrino::ParamsProtection::ClassMethods
- Padrino::ParamsProtection::InstanceMethods
- Padrino::Reloader
- Padrino::Reloader::Rack
- Padrino::Reloader::Storage
- Padrino::Router
- Padrino::Routing
- Padrino::Routing::ClassMethods
- Padrino::Routing::InstanceMethods
- Padrino::Routing::Parent
- Padrino::Routing::UnrecognizedException
- Padrino::Server
- Padrino::ShowExceptions
- Padrino::Tasks
- HttpRouter
- HttpRouter::Node
- HttpRouter::Node::FreeRegex
- HttpRouter::Node::Glob
- HttpRouter::Node::Path
- HttpRouter::Node::SpanningRegex
- HttpRouter::Request
- HttpRouter::Route
- Sinatra
- Sinatra::Base
- Sinatra::Request
- Kernel
- Object
- PadrinoTasks

No matching classes.

# Padrino::Cli::Base

### Protected Class Methods

banner(task=nil, *args) click to toggle source

    # File lib/padrino-core/cli/base.rb, line 86
    def self.banner(task=nil, *args)
      "padrino #{task.name}"
    end

### Public Instance Methods

console(*args) click to toggle source

    # File lib/padrino-core/cli/base.rb, line 28
    def console(*args)
      prepare :console
      require File.expand_path("../../version", __FILE__)
      ARGV.clear
      require 'irb'
      begin
        require "irb/completion"
      rescue LoadError
      end
      require File.expand_path('config/boot.rb')
      puts "=> Loading #{Padrino.env} console (Padrino v.#{Padrino.version})"
      require File.expand_path('../console', __FILE__)
      IRB.start
    end

generate(*args) click to toggle source

    # File lib/padrino-core/cli/base.rb, line 45
    def generate(*args)
      begin
        # We try to load the vendored padrino-gen if exist
        padrino_gen_path = File.expand_path('../../../../../padrino-gen/lib', __FILE__)
        $:.unshift(padrino_gen_path) if File.directory?(padrino_gen_path) && !$:.include?(padrino_gen_path)
        require 'padrino-core/command'
        require 'padrino-gen/command'
        ARGV.shift
        ARGV << 'help' if ARGV.empty?
        Padrino.bin_gen(*ARGV)
      rescue
        puts "<= You need padrino-gen! Run: gem install padrino-gen"
      end
    end

rake(*args) click to toggle source

    # File lib/padrino-core/cli/base.rb, line 10
    def rake(*args)
      prepare :rake
      args << "-T" if options[:list]
      args << options[:list]  unless options[:list].nil? || options[:list].to_s == "list"
      args << "--trace" if options[:trace]
      args << "--verbose" if options[:verbose]
      ARGV.clear
      ARGV.concat(args)
      puts "=> Executing Rake #{ARGV.join(' ')} ..."
      load File.expand_path('../rake.rb', __FILE__)
      Rake.application.init
      Rake.application.instance_variable_set(:@rakefile, __FILE__)
      load File.expand_path('Rakefile')
      Rake.application.top_level
    end

runner(*args) click to toggle source

    # File lib/padrino-core/cli/base.rb, line 69
    def runner(*args)
      prepare :runner

      code_or_file = args.shift
      abort "Please specify code or file" if code_or_file.nil?

      require File.expand_path('config/boot.rb')

      if File.exist?(code_or_file)
        eval(File.read(code_or_file), nil, code_or_file)
      else
        eval(code_or_file)
      end
    end

version() click to toggle source

    # File lib/padrino-core/cli/base.rb, line 62
    def version
      require 'padrino-core/version'
      puts "Padrino v. #{Padrino.version}"
    end

### Protected Instance Methods

capture(stream) click to toggle source

    # File lib/padrino-core/cli/base.rb, line 90
    def capture(stream)
      begin
        stream = stream.to_s
        eval "$#{stream} = StringIO.new"
        yield
        result = eval("$#{stream}").string
      ensure
        eval("$#{stream} = #{stream.upcase}")
      end

      result
    end

Also aliased as: silence
silence(stream) click to toggle source
Alias for: capture

[Validate]

Generated with the Darkfish Rdoc Generator 2.