Class: Gem::Tasks::Console
- Defined in:
- lib/rubygems/tasks/console.rb
Overview
The console
task.
Constant Summary collapse
- DEFAULT_CONSOLE =
The default Interactive Ruby Console
'irb'
- DEFAULT_COMMAND =
The default command to run
(ENV['RUBYCONSOLE'] || DEFAULT_CONSOLE)
Constants included from Printing
Printing::ANSI_BRIGHT, Printing::ANSI_CLEAR, Printing::ANSI_GREEN, Printing::ANSI_RED, Printing::ANSI_YELLOW, Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::STATUS_PREFIX
Instance Attribute Summary collapse
-
#command ⇒ Object
The Ruby Console command.
-
#options ⇒ Object
Additional options for the Ruby Console.
Attributes inherited from Task
Instance Method Summary collapse
-
#console(name = nil) ⇒ Array<String>
Builds the complete arguments for the console command.
-
#define ⇒ Object
Defines the
console
task. -
#initialize(options = {}) {|_self| ... } ⇒ Console
constructor
Initializes the
console
task.
Methods inherited from Task
#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?
Methods included from Printing
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Console
Initializes the console
task.
34 35 36 37 38 39 40 41 42 |
# File 'lib/rubygems/tasks/console.rb', line 34 def initialize(={}) super() @command = .fetch(:command,DEFAULT_COMMAND) @options = Array([:options]) yield self if block_given? define end |
Instance Attribute Details
#command ⇒ Object
The Ruby Console command
17 18 19 |
# File 'lib/rubygems/tasks/console.rb', line 17 def command @command end |
#options ⇒ Object
Additional options for the Ruby Console
20 21 22 |
# File 'lib/rubygems/tasks/console.rb', line 20 def @options end |
Instance Method Details
#console(name = nil) ⇒ Array<String>
Builds the complete arguments for the console command.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rubygems/tasks/console.rb', line 69 def console(name=nil) gemspec = @project.gemspec(name) require_paths = gemspec.require_paths require_file = gemspec.name.gsub('-',File::SEPARATOR) arguments = [@command] # add -I options for lib/ or ext/ directories arguments.push(*require_paths.map { |dir| "-I#{dir}" }) # add an -r option to require the library arguments.push("-r#{require_file}") # push on additional options arguments.push(*@options) if @project.bundler? # run under `bundle exec` arguments.unshift('bundle', 'exec') end return run(*arguments) end |
#define ⇒ Object
Defines the console
task.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubygems/tasks/console.rb', line 47 def define @project.gemspecs.each_key do |name| namespace :console do task(name) { console(name) } end end desc "Spawns an Interactive Ruby Console" task :console => "console:#{@project.primary_gemspec}" end |