Module: MnConvert

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

Defined Under Namespace

Modules: InputFormat

Constant Summary collapse

MNCONVERT_JAR_NAME =
"mnconvert.jar".freeze
MNCONVERT_JAR_PATH =
File.join(File.dirname(__FILE__), "..", "bin",
MNCONVERT_JAR_NAME)
VERSION =
"1.30.0"
MNCONVERT_JAR_VERSION =
VERSION

Class Method Summary collapse

Class Method Details

.convert(input_file, opts = {}) ⇒ Object



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

def self.convert(input_file, opts = {})
  validate(opts)

  cmd = [*java_cmd, input_file, *optional_opts(opts)].join(" ")

  puts cmd if opts[:debug]
  output_str, error_str, status = Open3.capture3(cmd)
  p output_str if opts[:debug]

  unless status.success?
    raise error_str
  end
end

.helpObject



24
25
26
27
28
# File 'lib/mnconvert.rb', line 24

def self.help
  cmd = ["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH].join(" ")
  message, = Open3.capture3(cmd)
  message
end

.jvm_optionsObject



14
15
16
17
18
19
20
21
22
# File 'lib/mnconvert.rb', line 14

def self.jvm_options
  options = ["-Xss5m", "-Xmx1024m"]

  if RbConfig::CONFIG["host_os"].match?(/darwin|mac os/)
    options << "-Dapple.awt.UIElement=true"
  end

  options
end

.versionObject



30
31
32
33
34
# File 'lib/mnconvert.rb', line 30

def self.version
  cmd = ["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH, "-v"].join(" ")
  message, = Open3.capture3(cmd)
  message.strip
end