Module: Makesheets

Defined in:
lib/makesheets.rb,
lib/makesheets/version.rb

Overview

Entry point, which validates and deligates the task

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.run(options) ⇒ Object

Validator and Delegator



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/makesheets.rb', line 9

def self.run(options)
    #puts options.inspect
    unless options[:infile]
        puts "[Error]: File path of the spreadsheet is required"
        exit
    end
    unless options[:column]
        puts "[Error]: Key column name must be given"
        exit
    end
    unless Validator::FileValidator.new(options[:infile]).validate
        puts "[Error]: #{options[:infile]} is not a valid infile!!!"
        exit
    end
    if options[:outfile]
        unless Validator::FileValidator.new(options[:outfile]).validate
            puts "[Error]: #{options[:outfile]} is not a valid outfile!!!"
            exit
        end
    end
    if options[:skiprows]
        options[:skiprows] = options[:skiprows].to_i
    end
    if options[:readrows]
        options[:readrows] = options[:readrows].to_i
    end
    Processor.new(options).process
end