Sha256: a60665fa09f67c05c4621fcc5135c33e98ab56ea5e31509564bea47587eafdec

Contents?: true

Size: 639 Bytes

Versions: 84

Compression:

Stored size: 639 Bytes

Contents

require "delegate"
require "shellwords"

module Ddr::Models
  class FileCharacterization < SimpleDelegator

    class FITSError < Error; end

    def self.call(obj)
      new(obj).call
    end

    def call
      with_content_file do |path|
        fits_output = run_fits(path)
        reload
        fits.content = fits_output
        save!
      end
    end

    private

    def run_fits(path)
      output = `#{fits_command} -i #{Shellwords.escape(path)}`
      unless $?.success?
        raise FITSError, output
      end
      output
    end

    def fits_command
      File.join(Ddr::Models.fits_home, 'fits.sh')
    end

  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
ddr-models-2.4.0.rc4 lib/ddr/models/file_characterization.rb
ddr-models-2.4.0.rc3 lib/ddr/models/file_characterization.rb
ddr-models-2.4.0.rc2 lib/ddr/models/file_characterization.rb
ddr-models-2.4.0.rc1 lib/ddr/models/file_characterization.rb