Class: Libis::Format::Droid

Inherits:
Object
  • Object
show all
Includes:
Tools::Logger
Defined in:
lib/libis/format/droid.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(file) ⇒ Object



16
17
18
# File 'lib/libis/format/droid.rb', line 16

def self.run(file)
  self.new.run file
end

Instance Method Details

#run(file) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/libis/format/droid.rb', line 20

def run(file)
  profile = File.join Dir.tmpdir, Dir::Tmpname.make_tmpname(%w'droid .profile', nil)
  report = File.join Dir.tmpdir, Dir::Tmpname.make_tmpname(%w'droid .csv', nil)
  result = Libis::Tools::Command.run(
      Libis::Format::Config[:droid_path],
      '-a', file.escape_for_string,
      '-p', profile,
      '-q',
  )
  warn "DROID profile errors: #{result[:err].join("\n")}" unless result[:status] == 0
  result = Libis::Tools::Command.run(
      Libis::Format::Config[:droid_path],
      '-e', report,
      '-p', profile,
      '-q'
  )
  warn "DROID report errors: #{result[:err].join("\n")}" unless result[:status] == 0
  File.delete profile
  result = CSV.read(report , headers: true, header_converters: [:downcase, :symbol])
  File.delete report
  result.map{|r|r.to_hash}
end