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.11.0 lib/ddr/models/file_characterization.rb
ddr-models-2.10.2 lib/ddr/models/file_characterization.rb
ddr-models-2.10.1 lib/ddr/models/file_characterization.rb
ddr-models-2.10.0 lib/ddr/models/file_characterization.rb
ddr-models-2.10.0.rc2 lib/ddr/models/file_characterization.rb
ddr-models-2.10.0.rc1 lib/ddr/models/file_characterization.rb
ddr-models-2.9.2 lib/ddr/models/file_characterization.rb
ddr-models-2.9.1 lib/ddr/models/file_characterization.rb
ddr-models-2.9.0 lib/ddr/models/file_characterization.rb
ddr-models-2.9.0.rc1 lib/ddr/models/file_characterization.rb
ddr-models-2.8.0 lib/ddr/models/file_characterization.rb
ddr-models-2.8.0.rc1 lib/ddr/models/file_characterization.rb
ddr-models-2.7.6 lib/ddr/models/file_characterization.rb
ddr-models-2.7.5 lib/ddr/models/file_characterization.rb
ddr-models-2.7.4 lib/ddr/models/file_characterization.rb
ddr-models-2.7.3 lib/ddr/models/file_characterization.rb
ddr-models-2.7.2 lib/ddr/models/file_characterization.rb
ddr-models-2.7.1 lib/ddr/models/file_characterization.rb
ddr-models-2.7.0 lib/ddr/models/file_characterization.rb
ddr-models-2.7.0.rc1 lib/ddr/models/file_characterization.rb