Class: Tabby::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/tabby/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
# File 'lib/tabby/runner.rb', line 5

def initialize(project)
  @project = project
  @path    = TABBYDIR.join("#{@project}.rb")
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/tabby/runner.rb', line 3

def project
  @project
end

Instance Method Details

#dasherizeObject



10
11
12
# File 'lib/tabby/runner.rb', line 10

def dasherize
  @project.gsub("_", "-")
end

#klassObject



14
15
16
# File 'lib/tabby/runner.rb', line 14

def klass
  @project.split(/_|-/).map { |p| p.capitalize }.join.to_sym
end

#run!Object



18
19
20
21
22
23
24
25
# File 'lib/tabby/runner.rb', line 18

def run!
  if @path.expand_path.exist?
    require TABBYDIR.join("#{@project}.rb")
    ObjectSpace.class.const_get(klass).new.call
  else
    puts ">> Project '#{@project}' does not exist."
  end
end