Module: Mn2sts

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

Constant Summary collapse

MN2STS_JAR_PATH =
File.join(File.dirname(__FILE__), "../bin/mn2sts.jar")
MN2STS_JAR_VERSION =
'1.8'
VERSION =
"#{MN2STS_JAR_VERSION}.0"

Class Method Summary collapse

Class Method Details

.convert(xml_path_in, xml_path_out, opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mn2sts.rb', line 29

def self.convert(xml_path_in, xml_path_out, opts = {})
  return if xml_path_in.nil? || xml_path_out.nil?

  cmd = ["java", "-Xss5m", "-Xmx1024m", *jvm_options, "-jar", MN2STS_JAR_PATH,
         "--xml-file-in", xml_path_in, "--xml-file-out", xml_path_out].join(" ")

  cmd += " --output-format iso" if opts[:iso]

  puts cmd
  _, error_str, status = Open3.capture3(cmd)

  unless status.success?
    warn error_str
    raise error_str
  end
end

.helpObject



17
18
19
20
21
# File 'lib/mn2sts.rb', line 17

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

.jvm_optionsObject



7
8
9
10
11
12
13
14
15
# File 'lib/mn2sts.rb', line 7

def self.jvm_options
  options = []

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

  options
end

.versionObject



23
24
25
26
27
# File 'lib/mn2sts.rb', line 23

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