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 ⇒ String
The Ruby Console command.
-
#options ⇒ Array<String>
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
consoletask. -
#initialize(command: DEFAULT_COMMAND, options: []) {|_self| ... } ⇒ Console
constructor
Initializes the
consoletask.
Methods inherited from Task
#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?
Methods included from Printing
Constructor Details
#initialize(command: DEFAULT_COMMAND, options: []) {|_self| ... } ⇒ Console
Initializes the console task.
37 38 39 40 41 42 43 44 45 |
# File 'lib/rubygems/tasks/console.rb', line 37 def initialize(command: DEFAULT_COMMAND, options: []) super() @command = command @options = yield self if block_given? define end |
Instance Attribute Details
#command ⇒ String
The Ruby Console command
21 22 23 |
# File 'lib/rubygems/tasks/console.rb', line 21 def command @command end |
#options ⇒ Array<String>
Additional options for the Ruby Console
26 27 28 |
# File 'lib/rubygems/tasks/console.rb', line 26 def @options end |
Instance Method Details
#console(name = nil) ⇒ Array<String>
Builds the complete arguments for the console command.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rubygems/tasks/console.rb', line 72 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubygems/tasks/console.rb', line 50 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 |