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-3.0.3 lib/ddr/models/file_characterization.rb
ddr-models-3.0.2 lib/ddr/models/file_characterization.rb
ddr-models-3.0.1 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.rc6 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.rc5 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.rc4 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.rc3 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.rc2 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.rc1 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.22 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.21 lib/ddr/models/file_characterization.rb
ddr-models-2.4.10 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.20 lib/ddr/models/file_characterization.rb
ddr-models-2.4.9 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.18 lib/ddr/models/file_characterization.rb
ddr-models-2.4.8 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.17 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.16 lib/ddr/models/file_characterization.rb
ddr-models-3.0.0.beta.15 lib/ddr/models/file_characterization.rb