hydra-file_characterization 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cff05141ecefe9beaec133587dda6bef344e10b7
4
- data.tar.gz: 9479e89d684e59174fd1323e4ee1885495937a27
3
+ metadata.gz: 81aa30a5af29b1bb419e67d30f0273faa4f7cd1a
4
+ data.tar.gz: 998e940542884ba96698b9bb4e03e8c06e9cabbc
5
5
  SHA512:
6
- metadata.gz: 2275213d1646d9ca4c346bcb22bec3df42e37bced35e984d65615c87796d37a91389d4bfb3b5f90f1dd90ce18c134bf548be2925825ebe65b168d8112eb0210d
7
- data.tar.gz: f732e2aed7c2a5d5b39a11d8caa698f2e73fd8944eab7772b4acfe6cc8988fbef6c110de6db37c178a3b1f820017b67aab7f066982d43290c9313f89b3af5ab8
6
+ metadata.gz: df13ebfc40df2ac4a9c6a8fac0319f1049459fbb65e47309738e6dbf0abf99a6e3641b31b5d6801cb55f33e14ae96f962d9bcd3f9d90f24719dcf0a5d6914246
7
+ data.tar.gz: e7466aa4a460b3e7ac62a06b21864ab7e4487fb23b46e99b4a11f34fc1dbf38d820e2745ba9656deb449f329378b6ab2e05ffff0eb17bd6ccc6e4ce04e65d04b
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # hydra-file_chracterization
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/hydra-file_characterization.png)](http://badge.fury.io/rb/hydra-file_characterization)
4
+
3
5
  Hydra::FileCharacterization as (extracted from Sufia and Hydra::Derivatives)
4
6
 
5
7
  ## Purpose
@@ -29,7 +31,7 @@ xml_string = Hydra::FileCharacterization.characterize(contents_of_a_file, 'file.
29
31
  end
30
32
  ```
31
33
 
32
- …or even make the path callable
34
+ …or even make the path callable
33
35
 
34
36
  ```ruby
35
37
  xml_string = Hydra::FileCharacterization.characterize(contents_of_a_file, 'file.rb', :fits) do |config|
@@ -37,6 +39,14 @@ xml_string = Hydra::FileCharacterization.characterize(contents_of_a_file, 'file.
37
39
  end
38
40
  ```
39
41
 
42
+ …or even create your custom characterizer on the file…
43
+
44
+ ```ruby
45
+ xml_string = Hydra::FileCharacterization.characterize(contents_of_a_file, 'file.rb', :my_characterizer) do |config|
46
+ config[:my_characterizer] = lambda {|filename| … }
47
+ end
48
+ ```
49
+
40
50
  You can also call multiple characterizers at the same time.
41
51
 
42
52
  ```ruby
@@ -32,6 +32,11 @@ module Hydra
32
32
  # end
33
33
  #
34
34
  # @example
35
+ # xml_string = Hydra::FileCharacterization.characterize(contents_of_a_file, 'file.rb', :fits) do |config|
36
+ # config[:fits] = lambda {|filename| … }
37
+ # end
38
+ #
39
+ # @example
35
40
  # fits_xml, ffprobe_xml = Hydra::FileCharacterization.characterize(contents_of_a_file, 'file.rb', :fits, :ffprobe)
36
41
  #
37
42
  # @param [String] content - The contents of the original file
@@ -16,9 +16,13 @@ module Hydra::FileCharacterization
16
16
  tool_name.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }
17
17
  end
18
18
 
19
- def characterize_with(tool_name, *args)
20
- tool_obj = characterizer(tool_name).new(*args)
21
- tool_obj.call
19
+ def characterize_with(tool_name, path_to_file, path_to_tool)
20
+ if path_to_tool.respond_to?(:call)
21
+ path_to_tool.call(path_to_file)
22
+ else
23
+ tool_obj = characterizer(tool_name).new(path_to_file, path_to_tool)
24
+ tool_obj.call
25
+ end
22
26
  end
23
27
 
24
28
  end
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module FileCharacterization
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
@@ -15,5 +15,28 @@ module Hydra::FileCharacterization
15
15
  it { should eq(Characterizers::Ffprobe) }
16
16
  end
17
17
 
18
+ context '.characterize_with' do
19
+ let(:tool_name) { :fits }
20
+ let(:filename) { __FILE__ }
21
+ let(:tool_path) { nil }
22
+ subject { Hydra::FileCharacterization.characterize_with(tool_name, filename, tool_path) }
23
+
24
+ context 'with callable tool_path and missing tool name' do
25
+ let(:tool_path) { lambda {|filename| [filename, :tool_path]} }
26
+ let(:tool_name) { :chunky_salsa }
27
+ it { should eq [filename, :tool_path] }
28
+ end
29
+
30
+ context 'with missing tool name and non-callable tool_path' do
31
+ let(:tool_name) { :chunky_salsa }
32
+ let(:tool_path) { '/path' }
33
+ it 'should raise exception' do
34
+ expect {
35
+ subject
36
+ }.to raise_error(ToolNotFoundError)
37
+ end
38
+ end
39
+ end
40
+
18
41
  end
19
- end
42
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-file_characterization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Treacy