libis-format 1.0.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +32 -24
  3. data/README.md +2 -2
  4. data/base/Dockerfile +5 -3
  5. data/base/rework_path +5 -10
  6. data/lib/libis/format.rb +5 -2
  7. data/lib/libis/format/cli/convert.rb +4 -4
  8. data/lib/libis/format/config.rb +3 -1
  9. data/lib/libis/format/converter/audio_converter.rb +2 -36
  10. data/lib/libis/format/converter/base.rb +21 -8
  11. data/lib/libis/format/converter/chain.rb +3 -3
  12. data/lib/libis/format/converter/image_assembler.rb +82 -0
  13. data/lib/libis/format/converter/image_converter.rb +20 -138
  14. data/lib/libis/format/converter/image_splitter.rb +80 -0
  15. data/lib/libis/format/converter/image_watermarker.rb +261 -0
  16. data/lib/libis/format/converter/jp2_converter.rb +1 -1
  17. data/lib/libis/format/converter/office_converter.rb +2 -2
  18. data/lib/libis/format/converter/pdf_assembler.rb +66 -0
  19. data/lib/libis/format/converter/pdf_converter.rb +27 -85
  20. data/lib/libis/format/converter/pdf_optimizer.rb +70 -0
  21. data/lib/libis/format/converter/pdf_splitter.rb +65 -0
  22. data/lib/libis/format/converter/pdf_watermarker.rb +110 -0
  23. data/lib/libis/format/converter/spreadsheet_converter.rb +2 -2
  24. data/lib/libis/format/converter/video_converter.rb +1 -1
  25. data/lib/libis/format/identifier.rb +3 -3
  26. data/lib/libis/format/info.rb +27 -0
  27. data/lib/libis/format/library.rb +147 -0
  28. data/lib/libis/format/tool/extension_identification.rb +4 -4
  29. data/lib/libis/format/tool/identification_tool.rb +6 -6
  30. data/lib/libis/format/tool/spreadsheet_to_ods.rb +1 -0
  31. data/lib/libis/format/version.rb +1 -1
  32. data/lib/libis/format/yaml_loader.rb +71 -0
  33. data/libis-format.gemspec +2 -1
  34. data/tools/fop/fop.bat +75 -75
  35. data/tools/fop/fop.cmd +31 -31
  36. data/tools/fop/fop.js +341 -341
  37. data/tools/fop/lib/avalon-framework.NOTICE.TXT +11 -11
  38. data/tools/fop/lib/xml-apis.LICENSE-SAX.html +17 -17
  39. data/tools/fop/lib/xml-apis.LICENSE.DOM-documentation.html +74 -74
  40. data/tools/fop/lib/xml-apis.LICENSE.DOM-software.html +66 -66
  41. metadata +13 -6
  42. data/lib/libis/format/type_database.rb +0 -133
  43. data/lib/libis/format/type_database_impl.rb +0 -120
@@ -1,120 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'singleton'
4
- require 'yaml'
5
-
6
- require 'libis/tools/logger'
7
- require 'libis/tools/extend/hash'
8
- require 'libis/tools/extend/string'
9
-
10
- module Libis
11
- module Format
12
-
13
- class TypeDatabaseImpl
14
- include Singleton
15
- include ::Libis::Tools::Logger
16
-
17
- def typeinfo(t)
18
- @types[t.to_sym] || {}
19
- end
20
-
21
- def group_types(group)
22
- @types.select do |_, v|
23
- v[:GROUP] == group.to_sym
24
- end.keys
25
- end
26
-
27
- def puid_infos(puid)
28
- @types.select do |_, v|
29
- v[:PUID].include? puid rescue false
30
- end.values
31
- end
32
-
33
- def puid_types(puid)
34
- @types.select do |_, v|
35
- v[:PUID].include? puid rescue false
36
- end.keys
37
- end
38
-
39
- def mime_infos(mime)
40
- @types.select do |_, v|
41
- v[:MIME].include? mime rescue false
42
- end.values
43
- end
44
-
45
- def mime_types(mime)
46
- @types.select do |_, v|
47
- v[:MIME].include? mime rescue false
48
- end.keys
49
- end
50
-
51
- def ext_infos(ext)
52
- ext = ext.gsub /^\./, ''
53
- @types.select do |_, v|
54
- v[:EXTENSIONS].include?(ext) rescue false
55
- end.values
56
- end
57
-
58
- def ext_types(ext)
59
- ext = ext.gsub /^\./, ''
60
- @types.select do |_, v|
61
- v[:EXTENSIONS].include?(ext) rescue false
62
- end.keys
63
- end
64
-
65
- def puid_typeinfo(puid)
66
- @types.each do |_, v|
67
- return v if v[:PUID] and v[:PUID].include?(puid)
68
- end
69
- nil
70
- end
71
-
72
- def known_mime?(mime)
73
- @types.each do |_, v|
74
- return true if v[:MIME].include? mime
75
- end
76
- false
77
- end
78
-
79
- def load_types(file_or_hash = {}, append = true)
80
- hash = file_or_hash.is_a?(Hash) ? file_or_hash : YAML::load_file(file_or_hash)
81
- # noinspection RubyResolve
82
- hash.each do |group, type_info|
83
- type_info.each do |type_name, info|
84
- type_key = type_name.to_sym
85
- info.symbolize_keys!
86
- info[:TYPE] = type_key
87
- info[:GROUP] = group.to_sym
88
- info[:MIME] = info[:MIME].strip.split(/[\s,]+/).map(&:strip) rescue []
89
- info[:EXTENSIONS] = info[:EXTENSIONS].strip.split(/[\s,]+/).map { |v| v.strip } rescue []
90
- info[:PUID] = info[:PUID].strip.split(/[\s,]+/).map { |v| v.strip } if info[:PUID]
91
- if @types.has_key?(type_key)
92
- warn 'Type %s already defined; merging with info from %s.', type_name.to_s, file_or_hash
93
- info.merge!(@types[type_key]) do |_,v_new,v_old|
94
- case v_old
95
- when Array
96
- append ? v_old + v_new : v_new + v_old
97
- when Hash
98
- append ? v_new.merge(v_old) : v_old.merge(v_new)
99
- else
100
- append ? v_old : v_new
101
- end
102
- end
103
- end
104
- @types[type_key] = info
105
- end
106
- end
107
- end
108
-
109
- protected
110
-
111
- def initialize
112
- @types = Hash.new
113
- type_database = Libis::Format::Config[:type_database]
114
- load_types(type_database)
115
- end
116
-
117
- end
118
-
119
- end
120
- end