Class: BirdGrinder::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/bird_grinder/console.rb

Overview

A simple controller for bringing up an IRB instance with the birdgrinder environment pre-loaded.

Defined Under Namespace

Modules: BaseExtensions

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConsole

Returns a new instance of Console.



16
17
18
# File 'lib/bird_grinder/console.rb', line 16

def initialize
  setup_irb
end

Class Method Details

.runObject

Starts up a new IRB instance with access to birdgrinder features.



37
38
39
# File 'lib/bird_grinder/console.rb', line 37

def self.run
  self.new.run
end

Instance Method Details

#runObject

Actually starts IRB



29
30
31
32
33
34
# File 'lib/bird_grinder/console.rb', line 29

def run
  puts "Loading BirdGrinder Console..."
  # Trick IRB into thinking it has no arguments.
  ARGV.replace []
  IRB.start
end

#setup_irbObject

Include the base extensions in our top level binding so they can be accessed at the prompt.



22
23
24
25
26
# File 'lib/bird_grinder/console.rb', line 22

def setup_irb
  # This is a bit hacky, surely there is a better way?
  # e.g. some way to specify which scope irb runs in.
  eval("include BirdGrinder::Console::BaseExtensions", TOPLEVEL_BINDING)
end