Sha256: e8d3d96ad51c4d694a90af2702629f8236e0ddaa2a647c2f39fab42a39afae5e

Contents?: true

Size: 1.28 KB

Versions: 20

Compression:

Stored size: 1.28 KB

Contents

require 'singleton'

require 'tempfile'
require 'csv'

require 'libis/tools/extend/string'
require 'libis/tools/logger'
require 'libis/tools/command'

require 'libis/format/config'

module Libis
  module Format

    class Droid
      include Singleton
      include ::Libis::Tools::Logger

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

      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
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
libis-format-0.9.32 lib/libis/format/droid.rb
libis-format-0.9.30 lib/libis/format/droid.rb
libis-format-0.9.29 lib/libis/format/droid.rb
libis-format-0.9.28 lib/libis/format/droid.rb
libis-format-0.9.27 lib/libis/format/droid.rb
libis-format-0.9.25 lib/libis/format/droid.rb
libis-format-0.9.24 lib/libis/format/droid.rb
libis-format-0.9.23 lib/libis/format/droid.rb
libis-format-0.9.22 lib/libis/format/droid.rb
libis-format-0.9.21 lib/libis/format/droid.rb
libis-format-0.9.20 lib/libis/format/droid.rb
libis-format-0.9.19 lib/libis/format/droid.rb
libis-format-0.9.18 lib/libis/format/droid.rb
libis-format-0.9.17 lib/libis/format/droid.rb
libis-format-0.9.16 lib/libis/format/droid.rb
libis-format-0.9.15 lib/libis/format/droid.rb
libis-format-0.9.13 lib/libis/format/droid.rb
libis-format-0.9.12 lib/libis/format/droid.rb
libis-format-0.9.11 lib/libis/format/droid.rb
libis-format-0.9.10 lib/libis/format/droid.rb