libis-format 1.0.4 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -1
  3. data/.travis.yml +43 -25
  4. data/README.md +2 -2
  5. data/base/Dockerfile +35 -0
  6. data/base/Dockerfile.alpine +20 -0
  7. data/base/Dockerfile.rvm +56 -0
  8. data/base/rework_path +20 -0
  9. data/docker_cfg.yml +1 -0
  10. data/lib/libis/format.rb +12 -3
  11. data/lib/libis/format/cli/convert.rb +4 -4
  12. data/lib/libis/format/config.rb +15 -10
  13. data/lib/libis/format/converter/audio_converter.rb +3 -37
  14. data/lib/libis/format/converter/base.rb +22 -8
  15. data/lib/libis/format/converter/chain.rb +3 -3
  16. data/lib/libis/format/converter/image_assembler.rb +82 -0
  17. data/lib/libis/format/converter/image_converter.rb +20 -138
  18. data/lib/libis/format/converter/image_splitter.rb +84 -0
  19. data/lib/libis/format/converter/image_watermarker.rb +261 -0
  20. data/lib/libis/format/converter/jp2_converter.rb +2 -2
  21. data/lib/libis/format/converter/office_converter.rb +2 -2
  22. data/lib/libis/format/converter/pdf_assembler.rb +66 -0
  23. data/lib/libis/format/converter/pdf_converter.rb +10 -134
  24. data/lib/libis/format/converter/pdf_metadata.rb +82 -0
  25. data/lib/libis/format/converter/pdf_optimizer.rb +67 -0
  26. data/lib/libis/format/converter/pdf_protecter.rb +147 -0
  27. data/lib/libis/format/converter/pdf_selecter.rb +83 -0
  28. data/lib/libis/format/converter/pdf_splitter.rb +70 -0
  29. data/lib/libis/format/converter/pdf_watermarker_header.rb +71 -0
  30. data/lib/libis/format/converter/pdf_watermarker_image.rb +76 -0
  31. data/lib/libis/format/converter/pdf_watermarker_text.rb +93 -0
  32. data/lib/libis/format/converter/spreadsheet_converter.rb +2 -2
  33. data/lib/libis/format/converter/video_converter.rb +1 -1
  34. data/lib/libis/format/identifier.rb +3 -3
  35. data/lib/libis/format/info.rb +27 -0
  36. data/lib/libis/format/library.rb +147 -0
  37. data/lib/libis/format/tool.rb +4 -1
  38. data/lib/libis/format/tool/droid.rb +2 -2
  39. data/lib/libis/format/tool/extension_identification.rb +4 -4
  40. data/lib/libis/format/tool/ffmpeg.rb +1 -1
  41. data/lib/libis/format/tool/fido.rb +1 -1
  42. data/lib/libis/format/tool/fop_pdf.rb +1 -1
  43. data/lib/libis/format/tool/identification_tool.rb +6 -6
  44. data/lib/libis/format/tool/office_to_pdf.rb +1 -1
  45. data/lib/libis/format/tool/pdf_merge.rb +4 -4
  46. data/lib/libis/format/tool/{pdf_copy.rb → pdf_metadata.rb} +6 -6
  47. data/lib/libis/format/tool/pdf_protect.rb +47 -0
  48. data/lib/libis/format/tool/pdf_select.rb +47 -0
  49. data/lib/libis/format/tool/pdf_split.rb +5 -5
  50. data/lib/libis/format/tool/pdf_to_pdfa.rb +1 -2
  51. data/lib/libis/format/tool/pdf_watermark.rb +47 -0
  52. data/lib/libis/format/tool/pdfa_validator.rb +3 -4
  53. data/lib/libis/format/tool/spreadsheet_to_ods.rb +2 -1
  54. data/lib/libis/format/version.rb +1 -1
  55. data/lib/libis/format/yaml_loader.rb +71 -0
  56. data/libis-format.gemspec +5 -4
  57. data/tools/PdfTool.jar +0 -0
  58. data/tools/bcpkix-jdk15on-167.jar +0 -0
  59. data/tools/bcprov-jdk15on-167.jar +0 -0
  60. data/tools/fop/build/fop.jar +0 -0
  61. data/tools/fop/conf/fop.xconf +466 -0
  62. data/tools/fop/fop +258 -0
  63. data/tools/fop/fop.bat +75 -0
  64. data/tools/fop/fop.cmd +31 -0
  65. data/tools/fop/fop.js +341 -0
  66. data/tools/fop/lib/README.txt +243 -0
  67. data/tools/fop/lib/avalon-framework-api-4.3.1.jar +0 -0
  68. data/tools/fop/lib/avalon-framework-impl-4.3.1.jar +0 -0
  69. data/tools/fop/lib/avalon-framework.LICENSE.txt +175 -0
  70. data/tools/fop/lib/avalon-framework.NOTICE.TXT +11 -0
  71. data/tools/fop/lib/batik-all-1.10.jar +0 -0
  72. data/tools/fop/lib/batik.LICENSE.txt +201 -0
  73. data/tools/fop/lib/batik.NOTICE.txt +18 -0
  74. data/tools/fop/lib/commons-io-1.3.1.jar +0 -0
  75. data/tools/fop/lib/commons-io.LICENSE.txt +203 -0
  76. data/tools/fop/lib/commons-io.NOTICE.txt +6 -0
  77. data/tools/fop/lib/commons-logging-1.0.4.jar +0 -0
  78. data/tools/fop/lib/commons-logging.LICENSE.txt +202 -0
  79. data/tools/fop/lib/commons-logging.NOTICE.txt +3 -0
  80. data/tools/fop/lib/fontbox-2.0.7.jar +0 -0
  81. data/tools/fop/lib/serializer-2.7.2.jar +0 -0
  82. data/tools/fop/lib/serializer.LICENSE.txt +201 -0
  83. data/tools/fop/lib/serializer.NOTICE.txt +15 -0
  84. data/tools/fop/lib/xalan-2.7.2.jar +0 -0
  85. data/tools/fop/lib/xalan.BCEL.LICENSE.txt +52 -0
  86. data/tools/fop/lib/xalan.LICENSE.txt +202 -0
  87. data/tools/fop/lib/xalan.NOTICE.txt +44 -0
  88. data/tools/fop/lib/xalan.regexp.LICENSE.txt +52 -0
  89. data/tools/fop/lib/xalan.runtime.LICENSE.txt +20 -0
  90. data/tools/fop/lib/xerces.LICENSE.txt +56 -0
  91. data/tools/fop/lib/xercesImpl-2.9.1.jar +0 -0
  92. data/tools/fop/lib/xercesImpl.LICENSE.txt +201 -0
  93. data/tools/fop/lib/xercesImpl.NOTICE.txt +14 -0
  94. data/tools/fop/lib/xml-apis-1.3.04.jar +0 -0
  95. data/tools/fop/lib/xml-apis-ext-1.3.04.jar +0 -0
  96. data/tools/fop/lib/xml-apis-ext.LICENSE.dom-documentation.txt +73 -0
  97. data/tools/fop/lib/xml-apis-ext.LICENSE.dom-software.txt +61 -0
  98. data/tools/fop/lib/xml-apis-ext.LICENSE.sac.html +75 -0
  99. data/tools/fop/lib/xml-apis-ext.LICENSE.txt +202 -0
  100. data/tools/fop/lib/xml-apis-ext.NOTICE.txt +16 -0
  101. data/tools/fop/lib/xml-apis-ext.README.dom.txt +56 -0
  102. data/tools/fop/lib/xml-apis.LICENSE-SAX.html +17 -0
  103. data/tools/fop/lib/xml-apis.LICENSE.DOM-documentation.html +74 -0
  104. data/tools/fop/lib/xml-apis.LICENSE.DOM-software.html +66 -0
  105. data/tools/fop/lib/xml-apis.LICENSE.txt +201 -0
  106. data/tools/fop/lib/xml-apis.NOTICE.txt +13 -0
  107. data/tools/fop/lib/xmlgraphics-commons-2.3.jar +0 -0
  108. data/tools/fop/lib/xmlgraphics-commons.LICENSE.txt +202 -0
  109. data/tools/fop/lib/xmlgraphics-commons.NOTICE.txt +5 -0
  110. data/tools/pdfbox/pdfbox-app-2.0.13.jar +0 -0
  111. data/tools/pdfbox/{pdfbox-app-1.8.10.jar → preflight-app-2.0.13.jar} +0 -0
  112. metadata +86 -246
  113. data/lib/libis/format/type_database.rb +0 -134
  114. data/lib/libis/format/type_database_impl.rb +0 -120
  115. data/spec/converter_audio_spec.rb +0 -66
  116. data/spec/converter_fop_spec.rb +0 -37
  117. data/spec/converter_image_spec.rb +0 -166
  118. data/spec/converter_office_spec.rb +0 -84
  119. data/spec/converter_pdf_spec.rb +0 -30
  120. data/spec/converter_repository_spec.rb +0 -97
  121. data/spec/converter_spreadsheet_spec.rb +0 -39
  122. data/spec/converter_video_spec.rb +0 -97
  123. data/spec/converter_xsl_spec.rb +0 -56
  124. data/spec/data/Cevennes2.bmp +0 -0
  125. data/spec/data/Cevennes2.jp2 +0 -0
  126. data/spec/data/Cevennes2.ppm +0 -22492
  127. data/spec/data/NikonRaw-CameraRaw.TIF +0 -0
  128. data/spec/data/NikonRaw-CaptureOne.tif +0 -0
  129. data/spec/data/audio/carlin_disappointed.aac +0 -0
  130. data/spec/data/audio/carlin_disappointed.ac3 +0 -0
  131. data/spec/data/audio/carlin_disappointed.aiff +0 -0
  132. data/spec/data/audio/carlin_disappointed.au +0 -0
  133. data/spec/data/audio/carlin_disappointed.flac +0 -0
  134. data/spec/data/audio/carlin_disappointed.m4a +0 -0
  135. data/spec/data/audio/carlin_disappointed.mka +0 -0
  136. data/spec/data/audio/carlin_disappointed.mp3 +0 -0
  137. data/spec/data/audio/carlin_disappointed.ogg +0 -0
  138. data/spec/data/audio/carlin_disappointed.ra +0 -0
  139. data/spec/data/audio/carlin_disappointed.voc +0 -0
  140. data/spec/data/audio/carlin_disappointed.wav +0 -0
  141. data/spec/data/audio/carlin_disappointed.wma +0 -0
  142. data/spec/data/audio/greensleeves.aac +0 -0
  143. data/spec/data/audio/greensleeves.ac3 +0 -0
  144. data/spec/data/audio/greensleeves.aiff +0 -0
  145. data/spec/data/audio/greensleeves.au +0 -0
  146. data/spec/data/audio/greensleeves.flac +0 -0
  147. data/spec/data/audio/greensleeves.m4a +0 -0
  148. data/spec/data/audio/greensleeves.mka +0 -0
  149. data/spec/data/audio/greensleeves.mp3 +0 -0
  150. data/spec/data/audio/greensleeves.ogg +0 -0
  151. data/spec/data/audio/greensleeves.ra +0 -0
  152. data/spec/data/audio/greensleeves.voc +0 -0
  153. data/spec/data/audio/greensleeves.wav +0 -0
  154. data/spec/data/audio/greensleeves.wma +0 -0
  155. data/spec/data/audio/king_nonviolence.aac +0 -0
  156. data/spec/data/audio/king_nonviolence.ac3 +0 -0
  157. data/spec/data/audio/king_nonviolence.aiff +0 -0
  158. data/spec/data/audio/king_nonviolence.au +0 -0
  159. data/spec/data/audio/king_nonviolence.flac +0 -0
  160. data/spec/data/audio/king_nonviolence.m4a +0 -0
  161. data/spec/data/audio/king_nonviolence.mka +0 -0
  162. data/spec/data/audio/king_nonviolence.mp3 +0 -0
  163. data/spec/data/audio/king_nonviolence.ogg +0 -0
  164. data/spec/data/audio/king_nonviolence.ra +0 -0
  165. data/spec/data/audio/king_nonviolence.voc +0 -0
  166. data/spec/data/audio/king_nonviolence.wav +0 -0
  167. data/spec/data/audio/king_nonviolence.wma +0 -0
  168. data/spec/data/audio/top_gun_secret.aac +0 -0
  169. data/spec/data/audio/top_gun_secret.ac3 +0 -0
  170. data/spec/data/audio/top_gun_secret.aiff +0 -0
  171. data/spec/data/audio/top_gun_secret.au +0 -0
  172. data/spec/data/audio/top_gun_secret.flac +0 -0
  173. data/spec/data/audio/top_gun_secret.m4a +0 -0
  174. data/spec/data/audio/top_gun_secret.mka +0 -0
  175. data/spec/data/audio/top_gun_secret.mp3 +0 -0
  176. data/spec/data/audio/top_gun_secret.ogg +0 -0
  177. data/spec/data/audio/top_gun_secret.ra +0 -0
  178. data/spec/data/audio/top_gun_secret.voc +0 -0
  179. data/spec/data/audio/top_gun_secret.wav +0 -0
  180. data/spec/data/audio/top_gun_secret.wma +0 -0
  181. data/spec/data/multipage.tif +0 -0
  182. data/spec/data/multipage.tif.jp2 +0 -0
  183. data/spec/data/test-ead.xml +0 -392
  184. data/spec/data/test-jpg.tif +0 -0
  185. data/spec/data/test-lzw.tif +0 -0
  186. data/spec/data/test-options.jpg +0 -0
  187. data/spec/data/test-options.png +0 -0
  188. data/spec/data/test.bmp +0 -0
  189. data/spec/data/test.doc +0 -0
  190. data/spec/data/test.docx +0 -0
  191. data/spec/data/test.gif +0 -0
  192. data/spec/data/test.jpg +0 -0
  193. data/spec/data/test.ods +0 -0
  194. data/spec/data/test.odt +0 -0
  195. data/spec/data/test.pdf +0 -0
  196. data/spec/data/test.pdf.tif +0 -0
  197. data/spec/data/test.png +0 -0
  198. data/spec/data/test.ps +0 -8631
  199. data/spec/data/test.psd +0 -0
  200. data/spec/data/test.rtf +0 -1455
  201. data/spec/data/test.tif +0 -0
  202. data/spec/data/test.txt +0 -12
  203. data/spec/data/test.xcf +0 -0
  204. data/spec/data/test.xls +0 -0
  205. data/spec/data/test.xlsx +0 -0
  206. data/spec/data/test.xml +0 -4
  207. data/spec/data/test_pdfa.pdf +0 -0
  208. data/spec/data/video/SampleVideo_1080x720_2mb.flv +0 -0
  209. data/spec/data/video/SampleVideo_1080x720_2mb.mkv +0 -0
  210. data/spec/data/video/SampleVideo_1080x720_2mb.mp4 +0 -0
  211. data/spec/data/video/SampleVideo_176x144_2mb.3gp +0 -0
  212. data/spec/data/video/SampleVideo_320x240_2mb.3gp +0 -0
  213. data/spec/data/video/SampleVideo_360x240_2mb.flv +0 -0
  214. data/spec/data/video/SampleVideo_360x240_2mb.mkv +0 -0
  215. data/spec/data/video/SampleVideo_360x240_2mb.mp4 +0 -0
  216. data/spec/data/video/copyright.png +0 -0
  217. data/spec/data/xml/134476_ead.XML +0 -1
  218. data/spec/data/xml/134476_ead.pdf +0 -0
  219. data/spec/data/xml/134476_fo.XML +0 -383
  220. data/spec/data/xml/134476_raw.XML +0 -141
  221. data/spec/data/xml/ead2fo_pdf.xsl +0 -1453
  222. data/spec/data/xml/header_nolink_pdf.xsl +0 -120
  223. data/spec/data/xml/lookupLists.xsl +0 -488
  224. data/spec/data/xml/scope_eadToHTML.xsl +0 -2376
  225. data/spec/data/xml/scope_xmlToEAD_dom.xsl +0 -952
  226. data/spec/identifier_spec.rb +0 -161
  227. data/spec/spec_helper.rb +0 -58
  228. data/spec/test_types.yml +0 -12
  229. data/spec/type_database_spec.rb +0 -140
  230. data/tools/bcpkix-jdk15on-1.49.jar +0 -0
  231. data/tools/bcprov-jdk15on-1.49.jar +0 -0
  232. data/tools/pdfbox/preflight-app-1.8.10.jar +0 -0
@@ -1,134 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'yaml'
4
-
5
- require 'backports/rails/hash'
6
-
7
- module Libis
8
- module Format
9
-
10
- # noinspection RubyClassVariableUsageInspection
11
- class TypeDatabase
12
- @implementation = Libis::Format::TypeDatabaseImpl.instance
13
-
14
- def self.implementation(impl)
15
- @implementation = impl
16
- end
17
-
18
- def self.enrich(info, map_keys = {})
19
- return {} unless info.is_a? Hash
20
- mapper = Hash.new {|hash,key| hash[key] = key}
21
- mapper.merge! map_keys
22
- unless (puid = info[mapper[:PUID]]).blank?
23
- info[mapper[:TYPE]] ||= puid_infos(puid).first[:TYPE] rescue nil
24
- end
25
- unless (mime = info[mapper[:MIME]]).blank?
26
- info[mapper[:TYPE]] ||= mime_infos(mime).first[:TYPE] rescue nil
27
- end
28
- unless (type_name = info[mapper[:TYPE]]).nil?
29
- mapper.keys.each do |key|
30
- info[mapper[key]] = get(type_name, key) || info[mapper[key]]
31
- end
32
- info[mapper[:GROUP]] = type_group(type_name)
33
- end
34
- info
35
- end
36
-
37
- def self.normalize(info, map_keys = {})
38
- return {} unless info.is_a? Hash
39
- mapper = Hash.new {|hash,key| hash[key] = key}
40
- mapper.merge! map_keys
41
- unless (puid = info[mapper[:PUID]]).blank?
42
- info[mapper[:TYPE]] ||= puid_infos(puid).first[:TYPE] rescue nil
43
- end
44
- unless (mime = info[mapper[:MIME]]).blank?
45
- info[mapper[:TYPE]] ||= mime_infos(mime).first[:TYPE] rescue nil
46
- end
47
- unless (type_name = info[mapper[:TYPE]]).nil?
48
- info[mapper[:MIME]] = type_mimetypes(type_name).first if type_mimetypes(type_name).first
49
- info[mapper[:GROUP]] = type_group(type_name)
50
- end
51
- info
52
- end
53
-
54
- def self.get(type_name, key)
55
- case key
56
- when :MIME
57
- type_mimetypes(type_name).first
58
- when :PUID
59
- type_puids(type_name).first
60
- when :EXTENSION
61
- type_extentions(type_name).first
62
- else
63
- typeinfo(type_name)[key]
64
- end
65
- end
66
-
67
- def self.type_group(t)
68
- typeinfo(t)[:GROUP]
69
- end
70
-
71
- def self.type_mimetypes(t)
72
- typeinfo(t)[:MIME] || []
73
- end
74
-
75
- def self.type_puids(t)
76
- typeinfo(t)[:PUID] || []
77
- end
78
-
79
- def self.type_extentions(t)
80
- typeinfo(t)[:EXTENSIONS] || []
81
- end
82
-
83
- def self.typeinfo(t)
84
- @implementation.typeinfo(t)
85
- end
86
-
87
- def self.group_types(group)
88
- @implementation.group_types(group)
89
- end
90
-
91
- def self.puid_infos(puid)
92
- @implementation.puid_infos(puid)
93
- end
94
-
95
- def self.puid_types(puid)
96
- @implementation.puid_types(puid)
97
- end
98
-
99
- def self.puid_groups(puid)
100
- puid_types(puid).map(&method(:type_group))
101
- end
102
-
103
- def self.mime_infos(mime)
104
- @implementation.mime_infos(mime)
105
- end
106
-
107
- def self.mime_types(mime)
108
- @implementation.mime_types(mime)
109
- end
110
-
111
- def self.mime_groups(mime)
112
- mime_types(mime).map(&method(:type_group))
113
- end
114
-
115
- def self.ext_infos(ext)
116
- @implementation.ext_infos(ext)
117
- end
118
-
119
- def self.ext_types(ext)
120
- @implementation.ext_types(ext)
121
- end
122
-
123
- def self.puid_typeinfo(puid)
124
- @implementation.puid_typeinfo(puid)
125
- end
126
-
127
- def self.known_mime?(mime)
128
- @implementation.known_mime?(mime)
129
- end
130
-
131
- end
132
-
133
- end
134
- end
@@ -1,120 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'singleton'
4
- require 'yaml'
5
-
6
- require 'backports/rails/hash'
7
- require 'libis/tools/logger'
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
@@ -1,66 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- require 'libis/format/converter/audio_converter'
5
-
6
- describe 'Converters' do
7
-
8
- let(:repository) {Libis::Format::Converter::Repository}
9
- let(:file_dir) {File.dirname(__FILE__)}
10
-
11
- before(:all) {
12
- Libis::Tools::Config.logger.level = 'off'
13
- }
14
-
15
- context 'Audio Converter' do
16
-
17
- let(:converter) {Libis::Format::Converter::AudioConverter.new}
18
- extensions = %w'aac aiff au flac m4a mka mp3 ra voc wav wma'
19
- confidence = {
20
- aac: 0.86,
21
- aiff: 0.99,
22
- au: 0.99,
23
- flac: 0.99,
24
- m4a: 0.93,
25
- mka: 0.94,
26
- mp3: 0.95,
27
- ra: 0.92,
28
- voc: 0.99,
29
- wav: 0.99,
30
- wma: 0.9
31
- }
32
- targets = %w'mp3 flac wav'
33
- sources = %w'carlin_disappointed greensleeves king_nonviolence top_gun_secret'
34
- quality = {
35
- carlin_disappointed: 1.0,
36
- greensleeves: 0.95,
37
- king_nonviolence: 1.0,
38
- top_gun_secret: 0.95
39
- }
40
-
41
- let(:data_dir) {File.join(file_dir, 'data', 'audio')}
42
-
43
- context 'converts' do
44
- sources.each do |source|
45
- extensions.each do |ext|
46
- next unless (File.exists?(File.join(File.dirname(__FILE__), 'data', 'audio', "#{source}.#{ext}")))
47
- (targets - [ext]).each do |tgt|
48
- it "#{source} #{ext} to #{tgt}" do
49
- src_file = File.join(data_dir, "#{source}.#{ext}")
50
- ref_file = File.join(data_dir, "#{source}.#{tgt}")
51
- tgt_file = File.join('', 'tmp', "test.#{source}.#{ext}.#{tgt}")
52
- FileUtils.remove tgt_file, force: true
53
- FileUtils.mkdir_p File.dirname(tgt_file)
54
- result = converter.convert(src_file, tgt_file, tgt.upcase.to_sym)
55
- expect(result).to eq tgt_file
56
- expect(result).to sound_like ref_file, confidence[ext.to_sym] * quality[source.to_sym], 11025, 1
57
- FileUtils.remove tgt_file, force: true
58
- end
59
- end
60
- end
61
- end
62
- end
63
-
64
- end
65
-
66
- end
@@ -1,37 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- require 'fileutils'
5
- require 'rspec/matchers'
6
-
7
- require 'libis/format/converter/fop_pdf_converter'
8
-
9
- describe 'Converters' do
10
-
11
- let(:repository) {Libis::Format::Converter::Repository}
12
- let(:file_dir) {File.dirname(__FILE__)}
13
-
14
- before(:all) {
15
- Libis::Tools::Config.logger.level = 'error'
16
- }
17
-
18
- context 'Apache FOP-PDF Converter' do
19
-
20
- let(:converter) {Libis::Format::Converter::FopPdfConverter.new}
21
- let(:data_dir) {File.join(file_dir, 'data', 'xml')}
22
-
23
- it 'converts XML-FO to PDF' do
24
- if File.exist?(Libis::Format::Config[:fop_jar])
25
- src_file = File.join data_dir, '134476_fo.XML'
26
- tgt_file = File.join '', 'tmp', '134476_ead.pdf'
27
- cmp_file = File.join data_dir, '134476_ead.pdf'
28
- FileUtils.remove tgt_file, force: true
29
- FileUtils.mkdir_p File.dirname(tgt_file)
30
- result = converter.convert src_file, tgt_file, :PDF
31
- expect(result).to eq tgt_file
32
- end
33
- end
34
-
35
- end
36
-
37
- end
@@ -1,166 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- require 'libis/format/converter/image_converter'
5
- require 'libis/format/converter/jp2_converter'
6
-
7
- describe 'Converters' do
8
-
9
- let(:repository) {Libis::Format::Converter::Repository}
10
- let(:file_dir) {File.dirname(__FILE__)}
11
-
12
- before(:all) {
13
- Libis::Tools::Config.logger.level = 'off'
14
- }
15
-
16
- context 'Image Converter' do
17
-
18
- let(:converter) {Libis::Format::Converter::ImageConverter.new}
19
- let(:diff_file) {File.join('', 'tmp', 'diff.jpg')}
20
-
21
- it 'converts TIFF to JPEG' do
22
- src_file = File.join(file_dir, 'data', 'test.tif')
23
- ref_file = File.join(file_dir, 'data', 'test.jpg')
24
- tgt_file = File.join('', 'tmp', 'test.jpg')
25
- FileUtils.mkdir_p File.dirname(tgt_file)
26
- converter.delete_date
27
- result = converter.convert(src_file, tgt_file, :JPG)
28
- expect(result).to eq tgt_file
29
- compare = MiniMagick::Tool::Compare.new
30
- compare << ref_file << tgt_file
31
- compare.metric << 'MAE'
32
- compare.fuzz << '1%'
33
- compare << diff_file
34
- compare.call {|_, _, status| expect(status).to be 0}
35
- FileUtils.rm tgt_file, force: true
36
- FileUtils.rm diff_file, force: true
37
- end
38
-
39
- it 'converts TIFF to PNG' do
40
- src_file = File.join(file_dir, 'data', 'test.tif')
41
- ref_file = File.join(file_dir, 'data', 'test.png')
42
- tgt_file = File.join('', 'tmp', 'test.png')
43
- FileUtils.mkdir_p File.dirname(tgt_file)
44
- converter.delete_date
45
- converter.page(0)
46
- result = converter.convert(src_file, tgt_file, :PNG)
47
- expect(result).to eq tgt_file
48
- compare = MiniMagick::Tool::Compare.new
49
- compare << ref_file << tgt_file
50
- compare.metric << 'MAE'
51
- compare << diff_file
52
- compare.call {|_, _, status| expect(status).to be 0}
53
- FileUtils.rm tgt_file, force: true
54
- FileUtils.rm diff_file, force: true
55
- end
56
-
57
- it 'converts PDF to TIFF' do
58
- src_file = File.join(file_dir, 'data', 'test.pdf')
59
- ref_file = File.join(file_dir, 'data', 'test.pdf.tif')
60
- tgt_file = File.join('', 'tmp', 'test.pdf.tif')
61
- FileUtils.mkdir_p File.dirname(tgt_file)
62
- converter.delete_date
63
- result = converter.convert(src_file, tgt_file, :TIFF)
64
- expect(result).to eq tgt_file
65
- compare = MiniMagick::Tool::Compare.new
66
- compare << ref_file << tgt_file
67
- compare.metric << 'AE'
68
- compare.fuzz << '100%'
69
- compare << diff_file
70
- compare.call {|_, _, status| expect(status).to be 0}
71
- FileUtils.rm tgt_file, force: true
72
- FileUtils.rm diff_file, force: true
73
- end
74
-
75
- it 'converts TIFF to PNG with many options' do
76
- src_file = File.join(file_dir, 'data', 'test.tif')
77
- ref_file = File.join(file_dir, 'data', 'test-options.png')
78
- tgt_file = File.join('', 'tmp', 'test-options.png')
79
- FileUtils.mkdir_p File.dirname(tgt_file)
80
- converter.watermark(text: 'RSPEC', size: 5, opacity: 0.1, rotation: 15, gap: 0.5, composition: 'modulate')
81
- converter.delete_date
82
- result = converter.convert(src_file, tgt_file, :PNG, options: {scale: '150%'})
83
- expect(result).to eq tgt_file
84
- compare = MiniMagick::Tool::Compare.new
85
- compare << ref_file << tgt_file
86
- compare.metric << 'AE'
87
- compare.fuzz << '100%'
88
- compare << diff_file
89
- compare.call do |_stdin, _stdout, status|
90
- expect(status).to be 0
91
- end
92
- FileUtils.rm tgt_file, force: true
93
- FileUtils.rm diff_file, force: true
94
- end
95
-
96
- it 'converts only first page of multipage TIFF to JP2' do
97
- src_file = File.join(file_dir, 'data', 'multipage.tif')
98
- ref_file = File.join(file_dir, 'data', 'multipage.tif.jp2')
99
- tgt_file = File.join('', 'tmp', 'test.jp2')
100
- FileUtils.mkdir_p File.dirname(tgt_file)
101
- converter.delete_date
102
- converter.quiet(true)
103
- converter.page(0)
104
- result = converter.convert(src_file, tgt_file, :JP2)
105
- expect(result).to eq tgt_file
106
- expect(File.exist?(tgt_file)).to be_truthy
107
- compare = MiniMagick::Tool::Compare.new
108
- compare << ref_file << tgt_file
109
- compare.metric << 'MAE'
110
- compare.fuzz << '10%'
111
- compare << diff_file
112
- compare.call {|_, _, status| expect(status).to be 0}
113
- FileUtils.rm tgt_file, force: true
114
- FileUtils.rm diff_file, force: true
115
- end
116
-
117
- it 'converts TIFF to JP2' do
118
- src_file = File.join(file_dir, 'data', 'test.tif')
119
- tgt_file = File.join('', 'tmp', 'test.jp2')
120
- FileUtils.mkdir_p File.dirname(tgt_file)
121
- converter.delete_date
122
- result = converter.convert(src_file, tgt_file, :JP2)
123
- expect(result).to eq tgt_file
124
- expect(File.exist?(tgt_file)).to be_truthy
125
- FileUtils.rm tgt_file, force: true
126
- end
127
-
128
-
129
- end
130
-
131
- context 'JP2 Converter', if: File.exists?(Libis::Format::Config[:j2kdriver]) do
132
-
133
- let(:converter) {Libis::Format::Converter::Jp2Converter.new}
134
- let(:diff_file) {File.join('', 'tmp', 'diff.jpg')}
135
-
136
- it 'converts TIFF to JP2' do
137
- src_file = File.join(file_dir, 'data', 'test.tif')
138
- tgt_file = File.join('', 'tmp', 'test.jp2')
139
- FileUtils.mkdir_p File.dirname(tgt_file)
140
- result = converter.convert(src_file, tgt_file, :JP2)
141
- expect(result).to eq tgt_file
142
- expect(File.exist?(tgt_file)).to be_truthy
143
- FileUtils.rm tgt_file, force: true
144
- end
145
-
146
- it 'converts only first page of multipage TIFF to JP2' do
147
- src_file = File.join(file_dir, 'data', 'multipage.tif')
148
- ref_file = File.join(file_dir, 'data', 'multipage.tif.jp2')
149
- tgt_file = File.join('', 'tmp', 'test.jp2')
150
- FileUtils.mkdir_p File.dirname(tgt_file)
151
- result = converter.convert(src_file, tgt_file, :JP2)
152
- expect(result).to eq tgt_file
153
- expect(File.exist?(tgt_file)).to be_truthy
154
- compare = MiniMagick::Tool::Compare.new
155
- compare << ref_file << tgt_file
156
- compare.metric << 'MAE'
157
- compare.fuzz << '10%'
158
- compare << diff_file
159
- compare.call {|_, _, status| expect(status).to be 0}
160
- FileUtils.rm tgt_file, force: true
161
- FileUtils.rm diff_file, force: true
162
- end
163
-
164
- end
165
-
166
- end