hets.rb revision b5bf21df9d1d61069e6dc9e13569543d0b868bc8
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller yaml = YAML.load_file(File.join(Rails.root, 'config', 'hets.yml'))
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller @path = first_which_exists yaml['hets_path']
e062724b7bdbbe8c1ddfbc7f3bb5bdb6e129d82cDaniel Vale raise HetsError, 'Could not find hets' unless @path
e062724b7bdbbe8c1ddfbc7f3bb5bdb6e129d82cDaniel Vale raise ArgumentError, "Your version of hets is too old" if version.include?("2011")
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller ENV[key.upcase] = first_which_exists value if key != 'hets_path'
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller # Runs hets with input_file and returns XML output file path.
705933deb08bc4269e8c08d50143af3cb5c1c670henning mueller def self.parse(input_file, output_path = '')
705933deb08bc4269e8c08d50143af3cb5c1c670henning mueller output_path = "-O \"#{output_path}\"" unless output_path.blank?
1cc8cf027c7907544308ffefc3e8071292c907f7henning mueller command = "#{config.path} -o xml --full-signatures -v2 #{output_path} '#{input_file}' 2>&1"
b5bf21df9d1d61069e6dc9e13569543d0b868bc8Daniel Couto Vale # Exclude usage message if exit status equals 2
b5bf21df9d1d61069e6dc9e13569543d0b868bc8Daniel Couto Vale if $?.exitstatus == 2 and output.include? 'Usage:'
b5bf21df9d1d61069e6dc9e13569543d0b868bc8Daniel Couto Vale # Raise error if exit status different from 0
b5bf21df9d1d61069e6dc9e13569543d0b868bc8Daniel Couto Vale if $?.exitstatus != 0 or output.starts_with? '*** Error'