hydra-file_characterization 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +6 -4
- data/lib/hydra/file_characterization.rb +16 -2
- data/lib/hydra/file_characterization/characterizer.rb +1 -1
- data/lib/hydra/file_characterization/characterizers/fits.rb +1 -3
- data/lib/hydra/file_characterization/exceptions.rb +6 -0
- data/lib/hydra/file_characterization/version.rb +1 -1
- data/spec/lib/hydra/file_characterization_spec.rb +15 -15
- metadata +14 -24
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b75ad5f0b18e047cebdb796c7f8ba98cd992a019
|
4
|
+
data.tar.gz: f53ac70d926460f8f3ec8b827ee5673fe07784a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77cd1a59aa05a2ad96531b48e5191df939c84a4e15a67417c11c852860972ed02bf51d869b1d08ee98740210c4a211d48a0521e8d086e81fa3d3f944069b09b2
|
7
|
+
data.tar.gz: 28acf276a405e40d53d0101459be9b27f70bf3f7602251c992ff9f1deb0525901f20e6fb8776fa6d93d9d2dd3bc7a61635830330c113b05c0f59b86c8f06c42c
|
data/README.md
CHANGED
@@ -15,16 +15,18 @@ How others are using the extract_metadata method
|
|
15
15
|
|
16
16
|
- ~~Given a filename, characterize the file and return a raw XML stream~~
|
17
17
|
- ~~Provide method for converting a StringIO and original file name to a temp file with comparable, then running the characterizer against the tempfile~~
|
18
|
-
- ~~Provide a configuration option for the fits path; This would be the default for the characterizer
|
18
|
+
- ~~Provide a configuration option for the fits path; This would be the default for the characterizer~~
|
19
19
|
- Update existing Sufia implementation
|
20
20
|
- Deprecrate Hydra::Derivatives direct method call
|
21
21
|
- Instead call the characterizer with the content
|
22
22
|
- Allow characterization services to be chained together
|
23
|
-
- ~~This would involve renaming the Characterizer to something else (i.e. Characterizers::Fits)
|
23
|
+
- ~~This would involve renaming the Characterizer to something else (i.e. Characterizers::Fits)~~
|
24
24
|
- Provide an ActiveFedora Datastream that maps the raw XML stream to a datastructure
|
25
25
|
|
26
26
|
## How to configure path to fits tool
|
27
27
|
|
28
|
-
|
29
|
-
Hydra::FileCharacterization::Characterizers::Fits.tool_path = '/path/to/fits'
|
28
|
+
If you are using Rails add the following to an initializer (./config/initializers/hydra-file_characterization_config.rb):
|
30
29
|
|
30
|
+
Hydra::FileCharacterization.configure do |config|
|
31
|
+
config.tool_path(:fits, '/path/to/fits')
|
32
|
+
end
|
@@ -22,8 +22,22 @@ module Hydra
|
|
22
22
|
module FileCharacterization
|
23
23
|
|
24
24
|
class Configuration
|
25
|
-
|
26
|
-
|
25
|
+
def configure
|
26
|
+
yield(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def tool_path(tool_name, tool_path)
|
30
|
+
Hydra::FileCharacterization.characterizer(tool_name).tool_path = tool_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module_function
|
35
|
+
def configuration
|
36
|
+
@configuration ||= Configuration.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def configure(&block)
|
40
|
+
configuration.configure(&block)
|
27
41
|
end
|
28
42
|
end
|
29
43
|
end
|
@@ -38,7 +38,7 @@ module Hydra::FileCharacterization
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def tool_path
|
41
|
-
|
41
|
+
self.class.tool_path || (raise Hydra::FileCharacterization::UnspecifiedToolPathError.new(self.class))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'hydra/file_characterization/exceptions'
|
1
2
|
require 'hydra/file_characterization/characterizer'
|
2
3
|
module Hydra::FileCharacterization::Characterizers
|
3
4
|
class Fits < Hydra::FileCharacterization::Characterizer
|
@@ -7,8 +8,5 @@ module Hydra::FileCharacterization::Characterizers
|
|
7
8
|
"#{tool_path} -i \"#{filename}\""
|
8
9
|
end
|
9
10
|
|
10
|
-
def tool_path
|
11
|
-
self.class.tool_path || (raise "No Tool Path Given")
|
12
|
-
end
|
13
11
|
end
|
14
12
|
end
|
@@ -39,25 +39,25 @@ module Hydra
|
|
39
39
|
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
describe FileCharacterization do
|
43
43
|
|
44
|
-
describe
|
45
|
-
|
46
|
-
let
|
47
|
-
|
48
|
-
|
44
|
+
describe '.configure' do
|
45
|
+
let(:content) { "class Test; end\n" }
|
46
|
+
let(:filename) { 'test.rb' }
|
47
|
+
around do |example|
|
48
|
+
old_tool_path = Hydra::FileCharacterization::Characterizers::Fits.tool_path
|
49
|
+
example.run
|
50
|
+
Hydra::FileCharacterization::Characterizers::Fits.tool_path = old_tool_path
|
49
51
|
end
|
50
|
-
its(:config) {should have_key :tool_path}
|
51
|
-
its(:tool_path) {should == expected_fits_path}
|
52
|
-
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
tempfile.call do |f|
|
58
|
-
@fits_output = Characterizers::Fits.new(f.path ).call
|
53
|
+
it 'without configuration' do
|
54
|
+
Hydra::FileCharacterization.configure do |config|
|
55
|
+
config.tool_path(:fits, nil)
|
59
56
|
end
|
60
|
-
|
57
|
+
|
58
|
+
expect {
|
59
|
+
Hydra.characterize(content, filename, :fits)
|
60
|
+
}.to raise_error(Hydra::FileCharacterization::UnspecifiedToolPathError)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-file_characterization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- James Treacy
|
@@ -17,65 +16,57 @@ dependencies:
|
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: activesupport
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
19
|
requirements:
|
22
|
-
- -
|
20
|
+
- - '>='
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: 3.0.0
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 3.0.0
|
33
30
|
- !ruby/object:Gem::Dependency
|
34
31
|
name: rspec
|
35
32
|
requirement: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
33
|
requirements:
|
38
|
-
- -
|
34
|
+
- - '>='
|
39
35
|
- !ruby/object:Gem::Version
|
40
36
|
version: '0'
|
41
37
|
type: :development
|
42
38
|
prerelease: false
|
43
39
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
40
|
requirements:
|
46
|
-
- -
|
41
|
+
- - '>='
|
47
42
|
- !ruby/object:Gem::Version
|
48
43
|
version: '0'
|
49
44
|
- !ruby/object:Gem::Dependency
|
50
45
|
name: guard
|
51
46
|
requirement: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
47
|
requirements:
|
54
|
-
- -
|
48
|
+
- - '>='
|
55
49
|
- !ruby/object:Gem::Version
|
56
50
|
version: '0'
|
57
51
|
type: :development
|
58
52
|
prerelease: false
|
59
53
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
54
|
requirements:
|
62
|
-
- -
|
55
|
+
- - '>='
|
63
56
|
- !ruby/object:Gem::Version
|
64
57
|
version: '0'
|
65
58
|
- !ruby/object:Gem::Dependency
|
66
59
|
name: guard-rspec
|
67
60
|
requirement: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
61
|
requirements:
|
70
|
-
- -
|
62
|
+
- - '>='
|
71
63
|
- !ruby/object:Gem::Version
|
72
64
|
version: '0'
|
73
65
|
type: :development
|
74
66
|
prerelease: false
|
75
67
|
version_requirements: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
68
|
requirements:
|
78
|
-
- -
|
69
|
+
- - '>='
|
79
70
|
- !ruby/object:Gem::Version
|
80
71
|
version: '0'
|
81
72
|
description: To provide a wrapper for file characterization
|
@@ -118,27 +109,26 @@ files:
|
|
118
109
|
homepage: https://github.com/projecthydra/hydra-file_characterization
|
119
110
|
licenses:
|
120
111
|
- APACHE2
|
112
|
+
metadata: {}
|
121
113
|
post_install_message:
|
122
114
|
rdoc_options: []
|
123
115
|
require_paths:
|
124
116
|
- lib
|
125
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
118
|
requirements:
|
128
|
-
- -
|
119
|
+
- - '>='
|
129
120
|
- !ruby/object:Gem::Version
|
130
121
|
version: '0'
|
131
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
123
|
requirements:
|
134
|
-
- -
|
124
|
+
- - '>='
|
135
125
|
- !ruby/object:Gem::Version
|
136
126
|
version: '0'
|
137
127
|
requirements: []
|
138
128
|
rubyforge_project:
|
139
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.0.3
|
140
130
|
signing_key:
|
141
|
-
specification_version:
|
131
|
+
specification_version: 4
|
142
132
|
summary: To provide a wrapper for file characterization
|
143
133
|
test_files:
|
144
134
|
- spec/fixtures/archive.zip
|