libis-format 0.9.33 → 0.9.35

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: 5a13d9df8f5e85ccc58758e46e556066d16935b0
4
- data.tar.gz: 3a80e5cfc6d7ea70f4c0091420012446ec801b74
3
+ metadata.gz: da9fb9519c4c34acf71a1d337b38a575be668b59
4
+ data.tar.gz: 22f23bb3cc7f5772c95891b2fa2a356bbc881d43
5
5
  SHA512:
6
- metadata.gz: c6a45a701e5ec6e07ebf763ee2fe3d97eb327fdccc85ca9aaca3e006e5dee3c1c058081c9a33c311aa72a7f2272661986799ab4a3f731f35e6ed5053ac1a25b3
7
- data.tar.gz: 6f7b02f7ab9a9fad169920f7b2dc04fdbc63a33fb8d5e70e458de9055fa1427acf453f88ca3937883d721a15d636af53ce943a6feeb68e980e0d28a04970222d
6
+ metadata.gz: 2a6e12bd802a6f12b6367c07e08d1ad59d7c55ff53f0669ac82b11074c96930e3cb61b9dae44c0fc2590284e223efb27b2bb41b06978893620ae7abe3d5a5548
7
+ data.tar.gz: 21c025acb844ec485e65ca494b565cbc620024f77255c19f0eaf96e51739f44b57061740ecf497c532763eb9c745b5304eff56b08eed5d6bcc136ea3f5f6753f
@@ -40,9 +40,9 @@ module Libis
40
40
 
41
41
  def get(file, options = {})
42
42
 
43
- options[:droid] = true unless options[:tool] and options[:tool] != :droid
44
- options[:fido] = true unless options[:tool] and options[:tool] != :fido
45
- options[:file] = true unless options[:tool] and options[:tool] != :file
43
+ options[:droid] = true unless options.keys.include?(:droid) and options[:tool] and options[:tool] != :droid
44
+ options[:fido] = true unless options.keys.include?(:fido) and options[:tool] and options[:tool] != :fido
45
+ options[:file] = true unless options.keys.include?(:file) and options[:tool] and options[:tool] != :file
46
46
 
47
47
  result = {messages: [], output: {}, formats: {}}
48
48
 
@@ -72,10 +72,6 @@ module Libis
72
72
 
73
73
  process_results(result)
74
74
 
75
- # result[:mimetype] ?
76
- # log_msg(result, :info, "Identification of '#{file}': '#{result}'") :
77
- # log_msg(result, :warn, "Could not identify MIME type of '#{file}'")
78
-
79
75
  result
80
76
 
81
77
  end
@@ -139,9 +135,11 @@ module Libis
139
135
  end
140
136
 
141
137
  def process_results(result)
142
- result[:output].map do |file, output|
138
+ result[:output].keys.each do |file|
139
+ output = result[:output].delete(file)
143
140
  file_result = result[:formats][file] = {}
144
141
  if output.empty?
142
+ log_msg(result, :warn, "Could not identify format of '#{file}'.")
145
143
  file_result = {
146
144
  mimetype: 'application/octet-stream',
147
145
  puid: 'fmt/unknown',
@@ -164,6 +162,7 @@ module Libis
164
162
  end
165
163
  end
166
164
  end
165
+ result.delete(:output)
167
166
  end
168
167
 
169
168
  def process_multiple_formats(file_result, format_matches, output)
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Format
3
- VERSION = '0.9.33'
3
+ VERSION = '0.9.35'
4
4
  end
5
5
  end
@@ -181,7 +181,6 @@ describe 'Converters' do
181
181
  src_file = File.join(file_dir, 'data', 'multipage.tif')
182
182
  ref_file = File.join(file_dir, 'data', 'multipage.tif.jp2')
183
183
  tgt_file = File.join('', 'tmp', 'test.jp2')
184
- diff_file = File.join('', 'tmp', 'diff.jpg')
185
184
  FileUtils.mkdir_p File.dirname(tgt_file)
186
185
  converter.delete_date
187
186
  converter.quiet(true)
@@ -198,6 +197,50 @@ describe 'Converters' do
198
197
  FileUtils.rm tgt_file, force: true
199
198
  end
200
199
 
200
+ it 'converts TIFF to JP2' do
201
+ src_file = File.join(file_dir, 'data', 'test.tif')
202
+ tgt_file = File.join('', 'tmp', 'test.jp2')
203
+ FileUtils.mkdir_p File.dirname(tgt_file)
204
+ converter.delete_date
205
+ result = converter.convert(src_file, tgt_file, :JP2)
206
+ expect(result).to eq tgt_file
207
+ expect(File.exist?(tgt_file)).to be_truthy
208
+ end
209
+
210
+
211
+ end
212
+
213
+ context 'JP2 Converter' do
214
+
215
+ let(:converter) {Libis::Format::Converter::Jp2Converter.new}
216
+ let(:diff_file) {File.join('', 'tmp', 'diff.jpg')}
217
+
218
+ it 'converts TIFF to JP2' do
219
+ src_file = File.join(file_dir, 'data', 'test.tif')
220
+ tgt_file = File.join('', 'tmp', 'test.jp2')
221
+ FileUtils.mkdir_p File.dirname(tgt_file)
222
+ result = converter.convert(src_file, tgt_file, :JP2)
223
+ expect(result).to eq tgt_file
224
+ expect(File.exist?(tgt_file)).to be_truthy
225
+ end
226
+
227
+ it 'converts only first page of multipage TIFF to JP2' do
228
+ src_file = File.join(file_dir, 'data', 'multipage.tif')
229
+ ref_file = File.join(file_dir, 'data', 'multipage.tif.jp2')
230
+ tgt_file = File.join('', 'tmp', 'test.jp2')
231
+ FileUtils.mkdir_p File.dirname(tgt_file)
232
+ result = converter.convert(src_file, tgt_file, :JP2)
233
+ expect(result).to eq tgt_file
234
+ expect(File.exist?(tgt_file)).to be_truthy
235
+ compare = MiniMagick::Tool::Compare.new
236
+ compare << ref_file << tgt_file
237
+ compare.metric << 'MAE'
238
+ compare.fuzz << '10%'
239
+ compare << diff_file
240
+ compare.call {|_,_,status| expect(status).to be 0}
241
+ FileUtils.rm tgt_file, force: true
242
+ end
243
+
201
244
  end
202
245
 
203
246
  context 'Pdf Converter' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.33
4
+ version: 0.9.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-17 00:00:00.000000000 Z
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  version: '0'
254
254
  requirements: []
255
255
  rubyforge_project:
256
- rubygems_version: 2.6.12
256
+ rubygems_version: 2.5.1
257
257
  signing_key:
258
258
  specification_version: 4
259
259
  summary: LIBIS File format format services.