hydra-file_characterization 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/hydra-file_characterization.gemspec +2 -2
- data/lib/hydra-file_characterization.rb +1 -14
- data/lib/hydra/file_characterization.rb +29 -0
- data/lib/{hydra-file_characterization → hydra/file_characterization}/characterizer.rb +17 -9
- data/lib/hydra/file_characterization/characterizers.rb +26 -0
- data/lib/hydra/file_characterization/characterizers/fits.rb +14 -0
- data/lib/hydra/file_characterization/exceptions.rb +12 -0
- data/lib/{hydra-file_characterization → hydra/file_characterization}/to_temp_file.rb +12 -3
- data/lib/{hydra-file_characterization → hydra/file_characterization}/version.rb +1 -1
- data/spec/fixtures/archive.zip.fits.xml +1 -1
- data/spec/fixtures/brendan_behan.jpeg.fits.xml +2 -2
- data/spec/fixtures/brendan_broken.dxxd.fits.xml +2 -2
- data/spec/lib/{hydra-file_characterization/characterizer_spec.rb → hydra/file_characterization/characterizers/fits_spec.rb} +7 -9
- data/spec/lib/hydra/file_characterization/characterizers_spec.rb +14 -0
- data/spec/lib/hydra/file_characterization/to_temp_file_spec.rb +36 -0
- data/spec/lib/hydra/file_characterization_spec.rb +65 -0
- data/spec/spec_helper.rb +11 -0
- metadata +41 -25
- checksums.yaml +0 -7
- data/spec/lib/hydra-file_characterization/to_temp_file_spec.rb +0 -20
- data/spec/lib/hydra-file_characterization_spec.rb +0 -18
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'hydra
|
4
|
+
require 'hydra/file_characterization/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "hydra-file_characterization"
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
]
|
21
21
|
gem.description = %q{To provide a wrapper for file characterization}
|
22
22
|
gem.summary = %q{To provide a wrapper for file characterization}
|
23
|
-
gem.homepage = "https://github.com/projecthydra/hydra
|
23
|
+
gem.homepage = "https://github.com/projecthydra/hydra/file_characterization"
|
24
24
|
gem.license = "APACHE2"
|
25
25
|
|
26
26
|
gem.files = `git ls-files`.split($/)
|
@@ -1,14 +1 @@
|
|
1
|
-
require "hydra
|
2
|
-
require "hydra-file_characterization/characterizer"
|
3
|
-
require "active_support/configurable"
|
4
|
-
|
5
|
-
module Hydra
|
6
|
-
module FileCharacterization
|
7
|
-
|
8
|
-
class Configuration
|
9
|
-
include ActiveSupport::Configurable
|
10
|
-
config_accessor :fits_path
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
1
|
+
require "hydra/file_characterization"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "hydra/file_characterization/version"
|
2
|
+
require "hydra/file_characterization/exceptions"
|
3
|
+
require "hydra/file_characterization/to_temp_file"
|
4
|
+
require "hydra/file_characterization/characterizer"
|
5
|
+
require "hydra/file_characterization/characterizers"
|
6
|
+
require "active_support/configurable"
|
7
|
+
|
8
|
+
module Hydra
|
9
|
+
|
10
|
+
module_function
|
11
|
+
def characterize(content, filename, *options)
|
12
|
+
tool_outputs = []
|
13
|
+
tool_names = Array(options).flatten.compact
|
14
|
+
FileCharacterization::ToTempFile.open(content, filename) do |f|
|
15
|
+
tool_names.each do |tool_name|
|
16
|
+
tool_outputs << FileCharacterization.characterize_with(tool_name, f.path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
tool_names.size == 1 ? tool_outputs.first : tool_outputs
|
20
|
+
end
|
21
|
+
|
22
|
+
module FileCharacterization
|
23
|
+
|
24
|
+
class Configuration
|
25
|
+
include ActiveSupport::Configurable
|
26
|
+
config_accessor :tool_path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,24 +1,22 @@
|
|
1
|
+
require 'hydra/file_characterization/exceptions'
|
1
2
|
require 'open3'
|
3
|
+
require 'active_support/core_ext/class/attribute'
|
2
4
|
|
3
5
|
module Hydra::FileCharacterization
|
4
|
-
|
5
6
|
class Characterizer
|
6
7
|
include Open3
|
7
8
|
|
8
|
-
|
9
|
-
end
|
9
|
+
class_attribute :tool_path
|
10
10
|
|
11
|
-
attr_reader :filename
|
12
|
-
def initialize(filename
|
11
|
+
attr_reader :filename
|
12
|
+
def initialize(filename)
|
13
13
|
@filename = filename
|
14
|
-
@fits_path = fits_path
|
15
14
|
end
|
16
15
|
|
17
16
|
def call
|
18
17
|
unless File.exists?(filename)
|
19
|
-
raise FileNotFoundError.new("File: #{filename} does not exist.")
|
18
|
+
raise Hydra::FileCharacterization::FileNotFoundError.new("File: #{filename} does not exist.")
|
20
19
|
end
|
21
|
-
command = "#{fits_path} -i \"#{filename}\""
|
22
20
|
stdin, stdout, stderr, wait_thr = popen3(command)
|
23
21
|
begin
|
24
22
|
out = stdout.read
|
@@ -32,5 +30,15 @@ module Hydra::FileCharacterization
|
|
32
30
|
stderr.close
|
33
31
|
end
|
34
32
|
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def command
|
37
|
+
raise NotImplementedError, "Method #command should be overriden in child classes"
|
38
|
+
end
|
39
|
+
|
40
|
+
def tool_path
|
41
|
+
raise NotImplementedError, "Method #tool_path should be overriden in child classes"
|
42
|
+
end
|
35
43
|
end
|
36
|
-
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Hydra::FileCharacterization
|
2
|
+
module Characterizers
|
3
|
+
end
|
4
|
+
|
5
|
+
module_function
|
6
|
+
def characterizer(tool_name)
|
7
|
+
characterizer_name = characterizer_name_from(tool_name)
|
8
|
+
if Characterizers.const_defined?(characterizer_name)
|
9
|
+
Characterizers.const_get(characterizer_name)
|
10
|
+
else
|
11
|
+
raise ToolNotFoundError.new(tool_name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def characterizer_name_from(tool_name)
|
16
|
+
tool_name.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }
|
17
|
+
end
|
18
|
+
|
19
|
+
def characterize_with(tool_name, file_path)
|
20
|
+
tool_obj = characterizer(tool_name).new(file_path)
|
21
|
+
tool_obj.call
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'hydra/file_characterization/characterizers/fits'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'hydra/file_characterization/characterizer'
|
2
|
+
module Hydra::FileCharacterization::Characterizers
|
3
|
+
class Fits < Hydra::FileCharacterization::Characterizer
|
4
|
+
|
5
|
+
protected
|
6
|
+
def command
|
7
|
+
"#{tool_path} -i \"#{filename}\""
|
8
|
+
end
|
9
|
+
|
10
|
+
def tool_path
|
11
|
+
self.class.tool_path || (raise "No Tool Path Given")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Hydra::FileCharacterization
|
2
|
+
|
3
|
+
class FileNotFoundError < RuntimeError
|
4
|
+
end
|
5
|
+
|
6
|
+
class ToolNotFoundError < RuntimeError
|
7
|
+
def initialize(tool_name)
|
8
|
+
super("Unable to find Hydra::FileCharacterization tool with name :#{tool_name}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
require 'open3'
|
2
|
+
require 'tempfile'
|
2
3
|
|
3
4
|
module Hydra::FileCharacterization
|
4
5
|
class ToTempFile
|
5
6
|
include Open3
|
6
7
|
|
8
|
+
def self.open(*args, &block)
|
9
|
+
new(*args).call(&block)
|
10
|
+
end
|
11
|
+
|
7
12
|
attr_accessor :data, :filename
|
8
13
|
|
9
14
|
def initialize(data, filename)
|
@@ -12,14 +17,18 @@ module Hydra::FileCharacterization
|
|
12
17
|
end
|
13
18
|
|
14
19
|
def call
|
15
|
-
return
|
16
|
-
|
17
|
-
|
20
|
+
return if data.empty?
|
21
|
+
f = Tempfile.new([File.basename(filename),File.extname(filename)])
|
22
|
+
begin
|
18
23
|
f.binmode
|
19
24
|
f.write(data)
|
20
25
|
f.rewind
|
21
26
|
yield(f)
|
27
|
+
ensure
|
28
|
+
f.close
|
29
|
+
f.unlink
|
22
30
|
end
|
31
|
+
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
</identification>
|
13
13
|
<fileinfo>
|
14
14
|
<lastmodified toolname="Exiftool" toolversion="9.06" status="SINGLE_RESULT">2013:09:17 15:45:51-04:00</lastmodified>
|
15
|
-
<filepath toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra
|
15
|
+
<filepath toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra/file_characterization/spec/fixtures/archive.zip</filepath>
|
16
16
|
<filename toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">spec/fixtures/archive.zip</filename>
|
17
17
|
<size toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">302</size>
|
18
18
|
<md5checksum toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">7c5b22ea09ba0eb837f70e2e8094b26f</md5checksum>
|
@@ -14,8 +14,8 @@
|
|
14
14
|
<fileinfo>
|
15
15
|
<size toolname="Jhove" toolversion="1.5">8744</size>
|
16
16
|
<lastmodified toolname="Exiftool" toolversion="9.06" status="SINGLE_RESULT">2013:09:17 13:15:45-04:00</lastmodified>
|
17
|
-
<filepath toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra
|
18
|
-
<filename toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra
|
17
|
+
<filepath toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra/file_characterization/spec/fixtures/brendan_behan.jpeg</filepath>
|
18
|
+
<filename toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra/file_characterization/spec/fixtures/brendan_behan.jpeg</filename>
|
19
19
|
<md5checksum toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">66a51b92863dd8e2c71c38979d84161c</md5checksum>
|
20
20
|
<fslastmodified toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">1379438145000</fslastmodified>
|
21
21
|
</fileinfo>
|
@@ -6,8 +6,8 @@
|
|
6
6
|
</identity>
|
7
7
|
</identification>
|
8
8
|
<fileinfo>
|
9
|
-
<filepath toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra
|
10
|
-
<filename toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra
|
9
|
+
<filepath toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra/file_characterization/spec/fixtures/brendan_broken.dxxd</filepath>
|
10
|
+
<filename toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">/Users/jfriesen/Repositories/hydra/file_characterization/spec/fixtures/brendan_broken.dxxd</filename>
|
11
11
|
<size toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">9574</size>
|
12
12
|
<md5checksum toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">ca786ec0489e53c945d1fa7b584bac7f</md5checksum>
|
13
13
|
<fslastmodified toolname="OIS File Information" toolversion="0.1" status="SINGLE_RESULT">1379446883000</fslastmodified>
|
@@ -1,14 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'hydra
|
2
|
+
require 'hydra/file_characterization/characterizers/fits'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
File.expand_path(File.join('../../../fixtures', filename), __FILE__)
|
8
|
-
end
|
4
|
+
module Hydra::FileCharacterization::Characterizers
|
5
|
+
|
6
|
+
describe Fits do
|
9
7
|
|
10
|
-
|
11
|
-
subject { Hydra::FileCharacterization::Characterizer.new(filename, fits_path) }
|
8
|
+
subject { Fits.new(filename) }
|
12
9
|
|
13
10
|
describe 'validfile' do
|
14
11
|
let(:filename) { fixture_file('brendan_behan.jpeg') }
|
@@ -20,7 +17,7 @@ describe Hydra::FileCharacterization do
|
|
20
17
|
describe 'invalidFile' do
|
21
18
|
let(:filename) { fixture_file('nofile.pdf') }
|
22
19
|
it "should raise an error if the path does not contain the file" do
|
23
|
-
expect {subject.call}.to raise_error(Hydra::FileCharacterization::
|
20
|
+
expect {subject.call}.to raise_error(Hydra::FileCharacterization::FileNotFoundError)
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
@@ -37,4 +34,5 @@ describe Hydra::FileCharacterization do
|
|
37
34
|
end
|
38
35
|
|
39
36
|
end
|
37
|
+
|
40
38
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hydra/file_characterization/characterizers'
|
3
|
+
|
4
|
+
module Hydra::FileCharacterization
|
5
|
+
describe Characterizers do
|
6
|
+
subject { Hydra::FileCharacterization.characterizer(tool_name) }
|
7
|
+
|
8
|
+
describe 'with :fits tool_name' do
|
9
|
+
let(:tool_name) { :fits }
|
10
|
+
it { should eq(Characterizers::Fits) }
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hydra/file_characterization/to_temp_file'
|
3
|
+
|
4
|
+
module Hydra::FileCharacterization
|
5
|
+
|
6
|
+
describe 'ToTempFile' do
|
7
|
+
|
8
|
+
let(:content) { "This is the content of the file." }
|
9
|
+
let(:filename) { "hello.rb" }
|
10
|
+
|
11
|
+
describe '.open' do
|
12
|
+
subject { ToTempFile }
|
13
|
+
it 'creates a tempfile then unlinks it' do
|
14
|
+
subject.open(content, filename) do |temp_file|
|
15
|
+
@temp_file = temp_file
|
16
|
+
expect(File.exist?(@temp_file.path)).to eq true
|
17
|
+
expect(File.extname(@temp_file.path)).to include '.rb'
|
18
|
+
end
|
19
|
+
expect(@temp_file.path).to eq nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'instance' do
|
24
|
+
subject { ToTempFile.new(content, filename) }
|
25
|
+
it 'create a tempfile that exists' do
|
26
|
+
subject.call do |temp_file|
|
27
|
+
@temp_file = temp_file
|
28
|
+
expect(File.exist?(@temp_file.path)).to eq true
|
29
|
+
expect(File.extname(@temp_file.path)).to include '.rb'
|
30
|
+
end
|
31
|
+
expect(@temp_file.path).to eq nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hydra/file_characterization'
|
3
|
+
require 'hydra/file_characterization/characterizer'
|
4
|
+
|
5
|
+
module Hydra
|
6
|
+
|
7
|
+
describe '.characterize' do
|
8
|
+
let(:content) { "class Test; end\n" }
|
9
|
+
let(:filename) { 'test.rb' }
|
10
|
+
subject { Hydra.characterize(content, filename, tool_names) }
|
11
|
+
|
12
|
+
describe 'for fits' do
|
13
|
+
let(:tool_names) { :fits }
|
14
|
+
it { should match(/#{'<identity format="Plain text" mimetype="text/plain"'}/) }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'for a bogus tool' do
|
18
|
+
let(:tool_names) { :cookie_monster }
|
19
|
+
it {
|
20
|
+
expect {
|
21
|
+
subject
|
22
|
+
}.to raise_error(Hydra::FileCharacterization::ToolNotFoundError)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'for a mix of bogus and valid tools' do
|
27
|
+
let(:tool_names) { [:fits, :cookie_monster] }
|
28
|
+
it {
|
29
|
+
expect {
|
30
|
+
subject
|
31
|
+
}.to raise_error(Hydra::FileCharacterization::ToolNotFoundError)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'for no tools' do
|
36
|
+
let(:tool_names) { nil }
|
37
|
+
it { should eq [] }
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
module FileCharacterization
|
43
|
+
|
44
|
+
describe Configuration do
|
45
|
+
subject { Configuration.new }
|
46
|
+
let (:expected_fits_path) {"string"}
|
47
|
+
before(:each) do
|
48
|
+
subject.tool_path = expected_fits_path
|
49
|
+
end
|
50
|
+
its(:config) {should have_key :tool_path}
|
51
|
+
its(:tool_path) {should == expected_fits_path}
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'preliminary integration' do
|
55
|
+
let (:tempfile) { ToTempFile.new("This is the content of the file.", 'test.rb')}
|
56
|
+
it '#call' do
|
57
|
+
tempfile.call do |f|
|
58
|
+
@fits_output = Characterizers::Fits.new(f.path ).call
|
59
|
+
end
|
60
|
+
expect(@fits_output).to include '<identity format="Plain text" mimetype="text/plain"'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,15 @@
|
|
4
4
|
# loaded once.
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
module SpecSupport
|
9
|
+
def fixture_file(filename)
|
10
|
+
File.expand_path(File.join('../fixtures', filename), __FILE__)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
7
14
|
RSpec.configure do |config|
|
15
|
+
config.include SpecSupport
|
8
16
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
17
|
config.run_all_when_everything_filtered = true
|
10
18
|
config.filter_run :focus
|
@@ -14,4 +22,7 @@ RSpec.configure do |config|
|
|
14
22
|
# the seed, which is printed after each run.
|
15
23
|
# --seed 1234
|
16
24
|
config.order = 'random'
|
25
|
+
config.before(:suite) do
|
26
|
+
Hydra::FileCharacterization::Characterizers::Fits.tool_path = `which fits || which fits.sh`.strip
|
27
|
+
end
|
17
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-file_characterization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- James Treacy
|
@@ -11,62 +12,70 @@ authors:
|
|
11
12
|
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
|
-
date: 2013-09-
|
15
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: activesupport
|
18
19
|
requirement: !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
19
21
|
requirements:
|
20
|
-
- - '>='
|
22
|
+
- - ! '>='
|
21
23
|
- !ruby/object:Gem::Version
|
22
24
|
version: 3.0.0
|
23
25
|
type: :runtime
|
24
26
|
prerelease: false
|
25
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
26
29
|
requirements:
|
27
|
-
- - '>='
|
30
|
+
- - ! '>='
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: 3.0.0
|
30
33
|
- !ruby/object:Gem::Dependency
|
31
34
|
name: rspec
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
33
37
|
requirements:
|
34
|
-
- - '>='
|
38
|
+
- - ! '>='
|
35
39
|
- !ruby/object:Gem::Version
|
36
40
|
version: '0'
|
37
41
|
type: :development
|
38
42
|
prerelease: false
|
39
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
40
45
|
requirements:
|
41
|
-
- - '>='
|
46
|
+
- - ! '>='
|
42
47
|
- !ruby/object:Gem::Version
|
43
48
|
version: '0'
|
44
49
|
- !ruby/object:Gem::Dependency
|
45
50
|
name: guard
|
46
51
|
requirement: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
47
53
|
requirements:
|
48
|
-
- - '>='
|
54
|
+
- - ! '>='
|
49
55
|
- !ruby/object:Gem::Version
|
50
56
|
version: '0'
|
51
57
|
type: :development
|
52
58
|
prerelease: false
|
53
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
54
61
|
requirements:
|
55
|
-
- - '>='
|
62
|
+
- - ! '>='
|
56
63
|
- !ruby/object:Gem::Version
|
57
64
|
version: '0'
|
58
65
|
- !ruby/object:Gem::Dependency
|
59
66
|
name: guard-rspec
|
60
67
|
requirement: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
61
69
|
requirements:
|
62
|
-
- - '>='
|
70
|
+
- - ! '>='
|
63
71
|
- !ruby/object:Gem::Version
|
64
72
|
version: '0'
|
65
73
|
type: :development
|
66
74
|
prerelease: false
|
67
75
|
version_requirements: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
68
77
|
requirements:
|
69
|
-
- - '>='
|
78
|
+
- - ! '>='
|
70
79
|
- !ruby/object:Gem::Version
|
71
80
|
version: '0'
|
72
81
|
description: To provide a wrapper for file characterization
|
@@ -88,42 +97,48 @@ files:
|
|
88
97
|
- Rakefile
|
89
98
|
- hydra-file_characterization.gemspec
|
90
99
|
- lib/hydra-file_characterization.rb
|
91
|
-
- lib/hydra
|
92
|
-
- lib/hydra
|
93
|
-
- lib/hydra
|
100
|
+
- lib/hydra/file_characterization.rb
|
101
|
+
- lib/hydra/file_characterization/characterizer.rb
|
102
|
+
- lib/hydra/file_characterization/characterizers.rb
|
103
|
+
- lib/hydra/file_characterization/characterizers/fits.rb
|
104
|
+
- lib/hydra/file_characterization/exceptions.rb
|
105
|
+
- lib/hydra/file_characterization/to_temp_file.rb
|
106
|
+
- lib/hydra/file_characterization/version.rb
|
94
107
|
- spec/fixtures/archive.zip
|
95
108
|
- spec/fixtures/archive.zip.fits.xml
|
96
109
|
- spec/fixtures/brendan_behan.jpeg
|
97
110
|
- spec/fixtures/brendan_behan.jpeg.fits.xml
|
98
111
|
- spec/fixtures/brendan_broken.dxxd
|
99
112
|
- spec/fixtures/brendan_broken.dxxd.fits.xml
|
100
|
-
- spec/lib/hydra
|
101
|
-
- spec/lib/hydra
|
102
|
-
- spec/lib/hydra
|
113
|
+
- spec/lib/hydra/file_characterization/characterizers/fits_spec.rb
|
114
|
+
- spec/lib/hydra/file_characterization/characterizers_spec.rb
|
115
|
+
- spec/lib/hydra/file_characterization/to_temp_file_spec.rb
|
116
|
+
- spec/lib/hydra/file_characterization_spec.rb
|
103
117
|
- spec/spec_helper.rb
|
104
|
-
homepage: https://github.com/projecthydra/hydra
|
118
|
+
homepage: https://github.com/projecthydra/hydra/file_characterization
|
105
119
|
licenses:
|
106
120
|
- APACHE2
|
107
|
-
metadata: {}
|
108
121
|
post_install_message:
|
109
122
|
rdoc_options: []
|
110
123
|
require_paths:
|
111
124
|
- lib
|
112
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
113
127
|
requirements:
|
114
|
-
- - '>='
|
128
|
+
- - ! '>='
|
115
129
|
- !ruby/object:Gem::Version
|
116
130
|
version: '0'
|
117
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
118
133
|
requirements:
|
119
|
-
- - '>='
|
134
|
+
- - ! '>='
|
120
135
|
- !ruby/object:Gem::Version
|
121
136
|
version: '0'
|
122
137
|
requirements: []
|
123
138
|
rubyforge_project:
|
124
|
-
rubygems_version:
|
139
|
+
rubygems_version: 1.8.23
|
125
140
|
signing_key:
|
126
|
-
specification_version:
|
141
|
+
specification_version: 3
|
127
142
|
summary: To provide a wrapper for file characterization
|
128
143
|
test_files:
|
129
144
|
- spec/fixtures/archive.zip
|
@@ -132,7 +147,8 @@ test_files:
|
|
132
147
|
- spec/fixtures/brendan_behan.jpeg.fits.xml
|
133
148
|
- spec/fixtures/brendan_broken.dxxd
|
134
149
|
- spec/fixtures/brendan_broken.dxxd.fits.xml
|
135
|
-
- spec/lib/hydra
|
136
|
-
- spec/lib/hydra
|
137
|
-
- spec/lib/hydra
|
150
|
+
- spec/lib/hydra/file_characterization/characterizers/fits_spec.rb
|
151
|
+
- spec/lib/hydra/file_characterization/characterizers_spec.rb
|
152
|
+
- spec/lib/hydra/file_characterization/to_temp_file_spec.rb
|
153
|
+
- spec/lib/hydra/file_characterization_spec.rb
|
138
154
|
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 3042462b8a14d3ec133d9ccc86fa20663fe4260d
|
4
|
-
data.tar.gz: 12e6b321515dfdcbf5621d107bf8b9a28ea0a597
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 53c9607e32ab504221c9f8752450af260ac109ebd497d85c546e5fd35dc22293169b16ddef8884351a34e4a1759636a45461a8172f8ac774d867a57d09080568
|
7
|
-
data.tar.gz: 4b1bdb304e398b2f78e5ce039d94e666373d6f247d11d7912fba2db35ac51f1daed7dcad21924df53be7fa875e9048aab9091f74c21cbc50816ad1277c826309
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'hydra-file_characterization/to_temp_file'
|
3
|
-
|
4
|
-
describe Hydra::FileCharacterization do
|
5
|
-
|
6
|
-
describe 'ToTempFile' do
|
7
|
-
let(:string) { "This is the content of the file." }
|
8
|
-
subject { Hydra::FileCharacterization::ToTempFile.new(string, "hello.rb") }
|
9
|
-
|
10
|
-
it 'create a tempfile that exists' do
|
11
|
-
@temp_file = ''
|
12
|
-
subject.call do |temp_file|
|
13
|
-
@temp_file = temp_file
|
14
|
-
expect(File.exist?(@temp_file)).to eq true
|
15
|
-
expect(File.extname(@temp_file)).to eq '.rb'
|
16
|
-
end
|
17
|
-
expect(File.exist?(@temp_file)).to eq false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'hydra-file_characterization'
|
3
|
-
|
4
|
-
describe Hydra::FileCharacterization do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
describe 'config' do
|
9
|
-
subject { Hydra::FileCharacterization::Configuration.new }
|
10
|
-
let (:expected_fits_path) {"string"}
|
11
|
-
before(:each) do
|
12
|
-
subject.fits_path = expected_fits_path
|
13
|
-
end
|
14
|
-
its(:config) {should have_key :fits_path}
|
15
|
-
its(:fits_path) {should == expected_fits_path}
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|