Class: Sinew::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/sinew/main.rb

Overview

Helper class used by sinew bin. This exists as an independent class solely for testing, otherwise it would be built into the bin script.

Defined Under Namespace

Classes: DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Main

Returns a new instance of Main.



7
8
9
10
11
12
13
14
15
16
# File 'lib/sinew/main.rb', line 7

def initialize(options)
  options[:output] ||= begin
    src = options[:recipe]
    dst = File.join(File.dirname(src), "#{File.basename(src, File.extname(src))}.csv")
    dst = dst.sub(%r{^./}, '') # nice to clean this up
    dst
  end

  @sinew = Sinew::Base.new(options)
end

Instance Attribute Details

#sinewObject (readonly)

Returns the value of attribute sinew.



5
6
7
# File 'lib/sinew/main.rb', line 5

def sinew
  @sinew
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sinew/main.rb', line 18

def run
  tm = Time.now
  header if !sinew.options[:silent]
  recipe = sinew.options[:recipe]
  dsl = DSL.new(sinew)
  begin
    dsl.instance_eval(File.read(recipe, mode: 'rb'), recipe)
  rescue LimitError
    # ignore - this is flow control for --limit
  end
  footer(Time.now - tm) if !sinew.options[:silent]
end