Class: Iev::Cli::Command

Inherits:
Thor
  • Object
show all
Includes:
CommandHelper
Defined in:
lib/iev/cli/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ui

debug, info, progress, set_ui_tag, warn

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/iev/cli/command.rb', line 147

def self.exit_on_failure?
  true
end

Instance Method Details

#db2yaml(dbfile) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/iev/cli/command.rb', line 99

def db2yaml(dbfile)
  handle_generic_options(options)

  Iev::Exporter.new(
    dbfile,
    output_dir: options[:output],
    only_concepts: options[:only_concepts],
    only_languages: options[:only_languages],
  ).export

  summary
end

#export(file) ⇒ Object



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

def export(file)
  handle_generic_options(options)

  Iev::Exporter.new(
    file,
    output_dir: options[:output],
    only_concepts: options[:only_concepts],
    only_languages: options[:only_languages],
  ).export

  info "Done!"
end

#fetch(code) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/iev/cli/command.rb', line 131

def fetch(code)
  raw = if options[:scrape]
          Scraper.new.fetch_concept(code)
        else
          DataSource.fetch_concept(code)
        end

  unless raw
    warn "IEV: concept #{code} not found."
    exit 1
  end

  concept = build_concept_from_raw(code, raw)
  print_concept_grouped_yaml(concept)
end

#xlsx2db(file) ⇒ Object



120
121
122
123
124
125
126
# File 'lib/iev/cli/command.rb', line 120

def xlsx2db(file)
  handle_generic_options(options)
  db = Sequel.sqlite
  DbWriter.new(db).import_spreadsheet(file)
  save_db_to_file(db, options[:output])
  summary
end

#xlsx2yaml(file) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/iev/cli/command.rb', line 68

def xlsx2yaml(file)
  handle_generic_options(options)

  Iev::Exporter.new(
    file,
    output_dir: options[:output],
    only_concepts: options[:only_concepts],
    only_languages: options[:only_languages],
  ).export

  summary
end