libis-format 0.9.44 → 0.9.45

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22fe2305d1461bf58825e88933f215cd64fffdba
4
- data.tar.gz: 454e2fc45afeae5b338723df845923c7f4364d10
3
+ metadata.gz: 90f7a025d3c3669dbb927c8c9b15c69f2d56920e
4
+ data.tar.gz: 2f44a0d3433882991a5bb2f68a40b0b68c1ae6e8
5
5
  SHA512:
6
- metadata.gz: ecf6f26241e61b34c6162c31ee1f55896a8d9bb67b01e2484db1714d1c5dfc75ce5666fad215dc8bc99d6e12d6f50fac3e81f92c9f47a5d8f26bdb43c0766d7b
7
- data.tar.gz: 8743beb8af9bc17f9953e9488d0fc78ccb8e709a5fcbc551470926fea972e39560b6ab092faa52789109ff796b7309f45bba9844e395c1e2cc0f3c10d94b27b8
6
+ metadata.gz: ac9e8ca2115f0d57fd3d161bbab2e9ecd5d1f7e08b2517bfaa5793a644555921ea404f806f2a99cba44044b72f236636cadd4a4258a199ec0fbed1021dfd095a
7
+ data.tar.gz: 2a61012eb18282b6f0164abf4948d5018e207c414cebc489296b50679594877c4bd33cd38003901ec0d05a6349fa25fd06e98ecb2707207e3aced31e9c173b1c
data/bin/formatinfo ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'libis-format'
4
+ require 'libis-tools'
5
+ require 'awesome_print'
6
+
7
+ ::Libis::Tools::Config.logger.level = :WARN
8
+
9
+ result = ::Libis::Format::Identifier.get ARGV[0]
10
+
11
+ puts '--- messages ---'
12
+ result[:messages].each do |message|
13
+ puts "#{message[0]} : #{message[1]}"
14
+ end
15
+
16
+ puts '--- formats ---'
17
+ result[:formats].each do |file, info|
18
+ puts "#{file}:"
19
+ ap info
20
+ end
data/data/types.yml CHANGED
@@ -131,7 +131,7 @@ AUDIO:
131
131
  M4A:
132
132
  NAME: MPEG-4 Media File (M4A)
133
133
  MIME: audio/mp4
134
- PUID: fmt/199, fmt/596
134
+ PUID: fmt/596
135
135
  EXTENSIONS: m4a f4a
136
136
 
137
137
  VIDEO:
@@ -97,7 +97,7 @@ module Libis
97
97
  end
98
98
 
99
99
  def get_fido_identification(file, result, options)
100
- output = ::Libis::Format::Tool::Fido.run(file, options[:recursive])
100
+ output = ::Libis::Format::Tool::Fido.run(file, options[:recursive], options[:fido_options])
101
101
  process_tool_output(output, result, options[:base_dir])
102
102
  output
103
103
  end
@@ -197,7 +197,7 @@ module Libis
197
197
 
198
198
  def process_tool_output(output, result, base_dir)
199
199
  output.each do |file, file_output|
200
- file = Pathname.new(file).relative_path_from(Pathname(base_dir)).to_s.freeze if base_dir
200
+ file = Pathname.new(file).relative_path_from(Pathname(File.absolute_path(base_dir))).to_s.freeze if base_dir
201
201
  result[:output][file] ||= []
202
202
  result[:output][file] += file_output
203
203
  end
@@ -20,28 +20,24 @@ module Libis
20
20
 
21
21
  class Droid < Libis::Format::Tool::IdentificationTool
22
22
 
23
- def run_list(filelist)
23
+ def run_list(filelist, _options = {})
24
24
  runner(filelist)
25
25
  end
26
26
 
27
- def run_dir(dir, recursive = true)
28
- profile = profile_file_name
29
- report = result_file_name
30
- create_profile(dir, profile, recursive)
31
- create_report(profile, report)
32
- parse_report(report)
27
+ def run_dir(dir, recursive = true, _options = {})
28
+ runner(dir, recursive)
33
29
  end
34
30
 
35
- def run(file)
31
+ def run(file, _options = {})
36
32
  runner(file)
37
33
  end
38
34
 
39
35
  protected
40
36
 
41
- def runner(file_or_list)
37
+ def runner(file_or_list, recursive = false)
42
38
  profile = profile_file_name
43
39
  report = result_file_name
44
- create_profile(file_or_list, profile)
40
+ create_profile(file_or_list, profile, recursive)
45
41
  create_report(profile, report)
46
42
  parse_report(report)
47
43
  end
@@ -6,7 +6,7 @@ module Libis
6
6
 
7
7
  class ExtensionIdentification < Libis::Format::Tool::IdentificationTool
8
8
 
9
- def run_list(filelist)
9
+ def run_list(filelist, _options = {})
10
10
 
11
11
  output = runner(nil, filelist)
12
12
 
@@ -14,7 +14,7 @@ module Libis
14
14
 
15
15
  end
16
16
 
17
- def run_dir(dir, recursive = true)
17
+ def run_dir(dir, recursive = true, _options = {})
18
18
 
19
19
  filelist = find_files(dir, recursive)
20
20
 
@@ -24,7 +24,7 @@ module Libis
24
24
 
25
25
  end
26
26
 
27
- def run(file)
27
+ def run(file, _options)
28
28
 
29
29
  output = runner(file)
30
30
 
@@ -22,22 +22,23 @@ module Libis
22
22
 
23
23
  attr_reader :formats
24
24
 
25
- def run_list(filelist)
25
+ def run_list(filelist, options = {})
26
26
  create_list_file(filelist) do |list_file|
27
- output = runner(nil, '-input', list_file.escape_for_string)
27
+ output = runner(nil, '-input', list_file.escape_for_string, options)
28
28
  process_output(output)
29
29
  end
30
30
  end
31
31
 
32
- def run_dir(dir, recursive = true)
32
+ def run_dir(dir, recursive = true, options = {})
33
33
  args = []
34
34
  args << '-recurse' if recursive
35
+ args << options
35
36
  output = runner(dir, *args)
36
37
  process_output(output)
37
38
  end
38
39
 
39
- def run(file)
40
- output = runner(file)
40
+ def run(file, options = {})
41
+ output = runner(file, options)
41
42
  process_output(output)
42
43
  end
43
44
 
@@ -53,11 +54,18 @@ module Libis
53
54
  attr_writer :formats
54
55
 
55
56
  def runner(filename, *args)
57
+ options = {}
58
+ options = args.pop if args.last.is_a?(Hash)
56
59
  # Load custome format definitions if present
57
60
  args << '-loadformats' << "#{formats.join(',')}" unless formats.empty?
58
61
 
59
62
  # Workaround for Fido performance bug
60
- args << '-bufsize' << '1000'
63
+ args << '-bufsize' << (options[:bufsize] || 1000).to_s
64
+
65
+ # Other options
66
+ args << '-container_bufsize' << options[:container_bufsize].to_s if options[:container_bufsize]
67
+ args << '-pronom_only' if options[:pronom_only]
68
+ args << '-nocontainer' if options[:nocontainer]
61
69
 
62
70
  # Add filename to argument list (optional)
63
71
  args << "#{filename.escape_for_string}" if filename
@@ -6,7 +6,7 @@ module Libis
6
6
 
7
7
  class FileTool < Libis::Format::Tool::IdentificationTool
8
8
 
9
- def run_list(filelist)
9
+ def run_list(filelist, _options = {})
10
10
 
11
11
  create_list_file(filelist) do |list_file|
12
12
 
@@ -18,7 +18,7 @@ module Libis
18
18
 
19
19
  end
20
20
 
21
- def run_dir(dir, recursive = true)
21
+ def run_dir(dir, recursive = true, _options = {})
22
22
 
23
23
  filelist = find_files(dir, recursive)
24
24
 
@@ -32,7 +32,7 @@ module Libis
32
32
 
33
33
  end
34
34
 
35
- def run(file)
35
+ def run(file, _options = {})
36
36
 
37
37
  output = runner(file)
38
38
 
@@ -21,26 +21,27 @@ module Libis
21
21
  self.instance.bad_mimetype(mimetype)
22
22
  end
23
23
 
24
- def self.run(file, recursive = false)
24
+ def self.run(file, recursive = false, options = {})
25
+ options ||= {}
25
26
  if file.is_a?(Array)
26
- return run_list file
27
+ return run_list file, options
27
28
  elsif file.is_a?(String) && File.exists?(file) && File.readable?(file)
28
29
  if File.directory?(file)
29
- return run_dir(file, recursive)
30
+ return run_dir(file, recursive, options)
30
31
  elsif File.file?(file)
31
- return self.instance.run(file)
32
+ return self.instance.run(file, options)
32
33
  end
33
34
  end
34
35
  raise ArgumentError,
35
36
  'IdentificationTool: file argument should be a path to an existing file or directory or a list of those'
36
37
  end
37
38
 
38
- def self.run_dir(file, recursive = true)
39
- self.instance.run_dir file, recursive
39
+ def self.run_dir(file, recursive = true, options = {})
40
+ self.instance.run_dir file, recursive, options
40
41
  end
41
42
 
42
- def self.run_list(filelist)
43
- self.instance.run_list filelist
43
+ def self.run_list(filelist , options = {})
44
+ self.instance.run_list filelist, options
44
45
  end
45
46
 
46
47
  protected
@@ -83,9 +84,9 @@ module Libis
83
84
  #
84
85
  def process_output(output)
85
86
  output.reduce({}) do |results, x|
86
- filepath = x.delete(:filepath)
87
+ filepath = File.absolute_path(x.delete(:filepath)).freeze
87
88
  results[filepath] ||= []
88
- results[filepath.freeze] << annotate(x)
89
+ results[filepath] << annotate(x)
89
90
  results
90
91
  end
91
92
  end
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Format
3
- VERSION = '0.9.44'
3
+ VERSION = '0.9.45'
4
4
  end
5
5
  end
@@ -96,7 +96,7 @@ describe 'Identfier' do
96
96
  File.exists?(Libis::Format::Config[:fido_path])) do
97
97
 
98
98
  it 'should identify all files in a folder at once' do
99
- result = identifier.get (dir)
99
+ result = identifier.get(dir)
100
100
  expect(result[:formats].size).to be >= formatlist.size
101
101
  formatlist.each do |file, format|
102
102
  expect(result[:formats][File.join(dir, file)]).to include format
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.44
4
+ version: 0.9.45
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-11-20 00:00:00.000000000 Z
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,6 +143,7 @@ email:
143
143
  executables:
144
144
  - droid
145
145
  - fido
146
+ - formatinfo
146
147
  - pdf_copy
147
148
  extensions: []
148
149
  extra_rdoc_files: []
@@ -156,6 +157,7 @@ files:
156
157
  - Rakefile
157
158
  - bin/droid
158
159
  - bin/fido
160
+ - bin/formatinfo
159
161
  - bin/pdf_copy
160
162
  - data/ISOcoated_v2_eci.icc
161
163
  - data/PDFA_def.ps