Sha256: 167817cd254cc53578074b2166009c0ee84cbdd01d7b0289550825f44d0e2b50

Contents?: true

Size: 641 Bytes

Versions: 3

Compression:

Stored size: 641 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

3 entries across 3 versions & 1 rubygems

Version Path
ddr-models-3.0.8 lib/ddr/models/file_characterization.rb
ddr-models-3.0.7 lib/ddr/models/file_characterization.rb
ddr-models-3.0.6 lib/ddr/models/file_characterization.rb