Class: Sheetsy::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/sheetsy/cli.rb

Instance Method Summary collapse

Instance Method Details

#convertObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sheetsy/cli.rb', line 12

def convert
  source = if options[:source]
             options[:source]
           elsif ENV.key?("SOURCE")
             ENV.fetch("SOURCE")
           else
             get_input("Source Directory", Dir.pwd)
           end

  destination = if options[:destination]
                  options[:destination]
                elsif ENV.key?("DESTINATION")
                  ENV.fetch("DESTINATION")
                else
                  default_source_folders = source.split("/")
                  default_output_folder = "#{default_source_folders.pop}_json"
                  get_input("Output Directory", File.join(*default_source_folders, default_output_folder))
                end

  Sheetsy::Converter.new(source, destination, options).run
end

#readerObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sheetsy/cli.rb', line 37

def reader
  source = if options[:source]
             options[:source]
           elsif ENV.key?("SOURCE")
             ENV.fetch("SOURCE")
           else
             get_input("Source Directory", Dir.pwd)
           end

  Sheetsy::Reader.new(source, options).run
end