Class: Tabby::Runner
- Inherits:
-
Object
- Object
- Tabby::Runner
- Defined in:
- lib/tabby/runner.rb
Constant Summary collapse
- TABBYDIR =
File.("~/.tabby")
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Project name, should be the filename in ~/.tabby.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
-
#start ⇒ Object
Loads the environment file (from ~/.tabby), finds the class which matches the filename and calls it.
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 |
# File 'lib/tabby/runner.rb', line 8 def initialize(argv) @project = argv[0] @klass = @project.split("_").map { |p| p.capitalize }.join.to_sym end |
Instance Attribute Details
#project ⇒ Object (readonly)
Project name, should be the filename in ~/.tabby.
6 7 8 |
# File 'lib/tabby/runner.rb', line 6 def project @project end |
Instance Method Details
#start ⇒ Object
Loads the environment file (from ~/.tabby), finds the class which matches the filename and calls it.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tabby/runner.rb', line 16 def start require File.join(TABBYDIR, "#{@project}.rb") ObjectSpace.class.const_get(@klass).new.call rescue LoadError puts "=> ERROR: Project (#{TABBYDIR}/#{@project}.rb) does not exist." rescue NameError puts "=> ERROR: Project filename/classname mismatch." puts " Filename is: #{@project}.rb" puts " Classname should be: #{@klass}" end |