Class: Termium::Cli

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

Overview

Command-line interface

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



68
69
70
71
72
# File 'lib/termium/cli.rb', line 68

def method_missing(*args)
  warn "No method found named: #{args[0]}"
  warn "Run with `--help` or `-h` to see available options"
  exit 1
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/termium/cli.rb', line 78

def self.exit_on_failure?
  true
end

Instance Method Details

#convertObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/termium/cli.rb', line 45

def convert
  input_path = input_file_as_path(options[:input_file])

  puts "Reading TERMIUM export file: #{input_path.relative_path_from(Dir.pwd)}"
  termium_extract = Termium::Extract.from_xml(IO.read(input_path.expand_path))

  puts "Size of TERMIUM dataset: #{termium_extract.core.size}"

  puts "Converting to Glossarist..."
  convert_options = {}
  if options[:date_accepted]
    convert_options[:date_accepted] = Date.parse(options[:date_accepted]).iso8601
  end
  glossarist_col = termium_extract.to_concept(convert_options)
  # pp glossarist_col.first

  output_path = output_dir_as_path(options[:output_file], input_path)
  puts "Writing Glossarist dataset to: #{output_path.relative_path_from(Dir.pwd)}"
  glossarist_col.save_to_files(output_path.expand_path)
  puts "Done."
  exit 0
end

#respond_to_missing?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/termium/cli.rb', line 74

def respond_to_missing?
  true
end