Class: Rookie::Tasks::Console
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Rookie::Tasks::Console
- Defined in:
- lib/rookie/tasks/console.rb
Instance Attribute Summary collapse
- #command ⇒ Object
-
#program ⇒ Object
Returns the value of attribute program.
-
#spec ⇒ Object
Returns the value of attribute spec.
Instance Method Summary collapse
- #define ⇒ Object
- #generate_command_string ⇒ Object
-
#initialize(spec, opts = {}) {|_self| ... } ⇒ Console
constructor
A new instance of Console.
Constructor Details
#initialize(spec, opts = {}) {|_self| ... } ⇒ Console
Returns a new instance of Console.
14 15 16 17 18 19 20 |
# File 'lib/rookie/tasks/console.rb', line 14 def initialize(spec, opts = {}) self.spec = spec self.program = opts.fetch :program, 'irb' self.command = opts.fetch :command, nil yield self if block_given? define end |
Instance Attribute Details
#command ⇒ Object
10 11 12 |
# File 'lib/rookie/tasks/console.rb', line 10 def command @command ||= generate_command_string end |
#program ⇒ Object
Returns the value of attribute program.
7 8 9 |
# File 'lib/rookie/tasks/console.rb', line 7 def program @program end |
#spec ⇒ Object
Returns the value of attribute spec.
7 8 9 |
# File 'lib/rookie/tasks/console.rb', line 7 def spec @spec end |
Instance Method Details
#define ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rookie/tasks/console.rb', line 22 def define desc 'Starts an interactive ruby session with your gem loaded' task :console do sh command end end |
#generate_command_string ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/rookie/tasks/console.rb', line 29 def generate_command_string program.dup.tap do |command_string| spec.require_paths.each do |path| command_string << ' -I ' << path end command_string << ' -r ' << spec.name end end |