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,161 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'libis/format/identifier'
4
- require 'awesome_print'
5
-
6
- # noinspection RubyStringKeysInHashInspection
7
- formatlist =
8
- {
9
- 'Cevennes2.ppm' => {mimetype: 'image/x-portable-pixmap', puid: 'fmt/408'},
10
- 'Cevennes2.bmp' => {mimetype: 'image/bmp', puid: 'fmt/116'},
11
- 'Cevennes2.jp2' => {mimetype: 'image/jp2', puid: 'x-fmt/392'},
12
- 'test.odt' => {mimetype: 'application/vnd.oasis.opendocument.text', puid: 'fmt/291'},
13
- 'test.doc' => {mimetype: 'application/msword', puid: 'fmt/40'},
14
- 'test.docx' => {mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', puid: 'fmt/412'},
15
- 'test.pdf' => {mimetype: 'application/pdf', puid: 'fmt/276'},
16
- 'test.rtf' => {mimetype: 'application/rtf', puid: 'fmt/45'},
17
- 'test.txt' => {mimetype: 'text/plain', puid: 'x-fmt/111'},
18
- 'test.ods' => {mimetype: 'application/vnd.oasis.opendocument.spreadsheet', puid: 'fmt/295'},
19
- 'test.xls' => {mimetype: 'application/vnd.ms-excel', puid: 'fmt/61'},
20
- 'test.xlsx' => {mimetype: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', puid: 'fmt/214'},
21
- 'test.psd' => {mimetype: 'image/vnd.adobe.photoshop', puid: 'x-fmt/92'},
22
- 'test.bmp' => {mimetype: 'image/bmp', puid: 'fmt/119'},
23
- 'test.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
24
- 'test-jpg.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
25
- 'test-lzw.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
26
- 'test.ps' => {mimetype: 'application/postscript', puid: 'x-fmt/408'},
27
- 'test.png' => {mimetype: 'image/png', puid: 'fmt/11'},
28
- 'test.jpg' => {mimetype: 'image/jpeg', puid: 'fmt/43'},
29
- 'test.gif' => {mimetype: 'image/gif', puid: 'fmt/4'},
30
- 'test.xml' => {mimetype: 'text/xml', puid: 'fmt/101'},
31
- 'test-ead.xml' => {mimetype: 'archive/ead', puid: 'fmt/101'},
32
- 'NikonRaw-CaptureOne.tif' => {mimetype: 'image/tiff', puid: 'x-fmt/387'},
33
- 'NikonRaw-CameraRaw.TIF' => {mimetype: 'image/tiff', puid: 'fmt/353'},
34
- }
35
-
36
- # noinspection RubyStringKeysInHashInspection
37
- fidolist =
38
- {
39
- 'Cevennes2.ppm' => {mimetype: 'image/x-portable-pixmap', puid: 'fmt/408'},
40
- 'Cevennes2.bmp' => {mimetype: 'image/bmp', puid: 'fmt/116'},
41
- 'Cevennes2.jp2' => {mimetype: 'image/jp2', puid: 'x-fmt/392'},
42
- 'test.odt' => {mimetype: 'application/vnd.oasis.opendocument.text', puid: 'fmt/290'},
43
- 'test.doc' => {mimetype: nil, puid: 'fmt/111'},
44
- 'test.docx' => {mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', puid: 'fmt/412'},
45
- 'test.pdf' => {mimetype: 'application/pdf', puid: 'fmt/276'},
46
- 'test.rtf' => {mimetype: 'application/rtf', puid: 'fmt/45'},
47
- 'test.txt' => {mimetype: 'text/plain', puid: 'x-fmt/111'},
48
- 'test.ods' => {mimetype: 'application/vnd.oasis.opendocument.spreadsheet', puid: 'fmt/294'},
49
- 'test.xls' => {mimetype: 'application/vnd.ms-excel', puid: 'fmt/61'},
50
- 'test.xlsx' => {mimetype: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', puid: 'fmt/214'},
51
- 'test.psd' => {mimetype: 'image/vnd.adobe.photoshop', puid: 'x-fmt/92'},
52
- 'test.bmp' => {mimetype: 'image/bmp', puid: 'fmt/119'},
53
- 'test.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
54
- 'test-jpg.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
55
- 'test-lzw.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
56
- 'test.ps' => {mimetype: 'application/postscript', puid: 'x-fmt/408'},
57
- 'test.png' => {mimetype: 'image/png', puid: 'fmt/11'},
58
- 'test.jpg' => {mimetype: 'image/jpeg', puid: 'fmt/43'},
59
- 'test.gif' => {mimetype: 'image/gif', puid: 'fmt/4'},
60
- 'test.xml' => {mimetype: 'text/xml', puid: 'fmt/101'},
61
- 'test-ead.xml' => {mimetype: 'text/xml', puid: 'fmt/101'},
62
- 'NikonRaw-CaptureOne.tif' => {mimetype: 'image/tiff', puid: 'fmt/353'},
63
- 'NikonRaw-CameraRaw.TIF' => {mimetype: 'image/tiff', puid: 'fmt/353'},
64
- }
65
-
66
- describe 'Identfier' do
67
-
68
- before :all do
69
- ::Libis::Tools::Config.logger.appenders =
70
- ::Logging::Appenders.string_io('StringIO', layout: ::Libis::Tools::Config.get_log_formatter)
71
- ::Libis::Tools::Config.logger.level = :all
72
- end
73
-
74
- let (:identifier) {::Libis::Format::Identifier}
75
- let (:logoutput) {::Libis::Tools::Config.logger.appenders.last.sio}
76
- let (:dir) {File.join File.absolute_path(File.dirname(__FILE__)), 'data'}
77
-
78
- it 'should initialize correctly' do
79
- expect(identifier.xml_validations.size).to be 1
80
- expect(File.basename identifier.xml_validations['archive/ead']).to eq 'ead.xsd'
81
- end
82
-
83
- # noinspection RubyResolve
84
- it 'should not attempt to identify a non-existing file or directory' do
85
- result = identifier.get (File.join(dir, 'abcdef'))
86
- expect(result[:output]).to be_empty
87
- expect(result[:formats]).to be_empty
88
- expect(result[:messages]).not_to be_empty
89
- expect(result[:messages].all? do |x|
90
- x[0] == :error &&
91
- x[1] =~ /^Error running (Droid|Fido|File): IdentificationTool: file argument should be a path to an existing file or directory or a list of those/
92
- end).to be_truthy
93
- end
94
-
95
- context 'Fido and Droid', if: (File.exists?(Libis::Format::Config[:droid_path]) &&
96
- File.exists?(Libis::Format::Config[:fido_path])) do
97
-
98
- it 'should identify all files in a folder at once' do
99
- result = identifier.get(dir)
100
- expect(result[:formats].size).to be >= formatlist.size
101
- formatlist.each do |file, format|
102
- expect(result[:formats][File.join(dir, file)]).to include format
103
- end
104
- end
105
-
106
- it 'should identify all files in a folder with base_dir option' do
107
- result = identifier.get(dir, base_dir: dir, keep_output: true)
108
- expect(result[:formats].size).to be >= formatlist.size
109
- formatlist.each do |file, format|
110
- expect(result[:formats][file]).to include format
111
- end
112
- end
113
-
114
- it 'should identify all files in a list at once' do
115
- filelist = fidolist.keys.map {|file| File.join(dir, file)}
116
- result = identifier.get (filelist)
117
- expect(result[:formats].size).to be >= formatlist.size
118
- formatlist.each do |file, format|
119
- expect(result[:formats][File.join(dir, file)]).to include format
120
- end
121
- end
122
-
123
- it 'should identify all files in a list with base_dir option' do
124
- filelist = fidolist.keys.map {|file| File.join(dir, file)}
125
- result = identifier.get(filelist, base_dir: dir)
126
- expect(result[:formats].size).to be >= formatlist.size
127
- formatlist.each do |file, format|
128
- expect(result[:formats][file]).to include format
129
- end
130
- end
131
-
132
- end
133
-
134
- context 'Fido', if: File.exists?(Libis::Format::Config[:fido_path]) do
135
-
136
- # expect(identifier.fido_formats.size).to be 1
137
- # expect(File.basename(identifier.fido_formats.first)).to eq 'lias_formats.xml'
138
- it 'should identify list of test documents' do
139
- filelist = formatlist.keys.map {|file| File.join(dir, file)}
140
- fido_result = ::Libis::Format::Tool::Fido.instance.run_list(filelist)
141
- filelist.each do |filename|
142
- result = fido_result[filename]
143
- result = result[0] if result
144
- # noinspection RubyResolve
145
- expect(result).to include fidolist[File.basename(filename)]
146
- end
147
- end
148
-
149
- it 'should identify dir of test documents' do
150
- filelist = fidolist.keys.map {|file| File.join(dir, file)}
151
- fido_result = ::Libis::Format::Tool::Fido.instance.run_dir(dir, false)
152
- filelist.each do |filename|
153
- result = fido_result[filename]
154
- result = result[0] if result
155
- # noinspection RubyResolve
156
- expect(result).to include fidolist[File.basename(filename)]
157
- end
158
- end
159
-
160
- end
161
- end
data/spec/spec_helper.rb DELETED
@@ -1,58 +0,0 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
-
4
- require 'bundler/setup'
5
- Bundler.setup
6
-
7
- require 'rspec'
8
- require 'libis-format'
9
- require 'libis-tools'
10
-
11
- require 'chromaprint'
12
-
13
- RSpec::Matchers.define(:be_same_file_as) do |exected_file_path|
14
- match do |actual_file_path|
15
- expect(md5_hash(actual_file_path)).to eq md5_hash(exected_file_path)
16
- end
17
-
18
- def md5_hash(file_path)
19
- Digest::MD5.hexdigest(File.read(file_path))
20
- end
21
- end
22
-
23
- RSpec::Matchers.define :sound_like do |exp_file, threshold, rate, channels|
24
- match do |tgt_file|
25
- rate ||= 96000
26
- channels ||= 1
27
- threshold ||= 0.9
28
-
29
- if File.exists?(exp_file) && File.exists?(tgt_file)
30
- # Convert input files into raw 16-bit signed audio (WAV) to process with Chramaprint
31
- exp_raw = File.join('','tmp', File.basename(exp_file) + '.wav')
32
- tgt_raw = File.join('','tmp', File.basename(tgt_file) + '.wav')
33
- FileUtils.rm(exp_raw, force: true)
34
- FileUtils.rm(tgt_raw, force: true)
35
- cvt_cmd = "sox %s -e signed -b 16 -t wav %s rate #{rate} channels #{channels}"
36
- %x"#{cvt_cmd % [exp_file,exp_raw]}"
37
- %x"#{cvt_cmd % [tgt_file,tgt_raw]}"
38
- exp_audio = File.binread(exp_raw)
39
- tgt_audio = File.binread(tgt_raw)
40
-
41
- # Get audio fingerprints
42
- chromaprint = Chromaprint::Context.new(rate, channels, Chromaprint::ALGORITHM_TEST3)
43
- exp_fp = chromaprint.get_fingerprint(exp_audio)
44
- tgt_fp = chromaprint.get_fingerprint(tgt_audio)
45
-
46
- # Cleanup files
47
- FileUtils.rm(exp_raw, force: true)
48
- FileUtils.rm(tgt_raw, force: true)
49
-
50
- # Compare fingerprints and compare result against threshold
51
- cmp = exp_fp.compare(tgt_fp)
52
- # puts "Threshold[#{File.basename(exp_file)},#{File.basename(tgt_file)}: #{cmp}"
53
- cmp > threshold
54
- else
55
- false
56
- end
57
- end
58
- end
data/spec/test_types.yml DELETED
@@ -1,12 +0,0 @@
1
- TESTMEDIUM:
2
- TESTDATA:
3
- NAME: Test data format
4
- MIME: test/data, application/test/data
5
- PUID: test-fmt/001 spec-fmt/101
6
- EXTENSIONS: dat data
7
-
8
- TESTSPEC:
9
- NEW: Test specification format
10
- MIME: test/spec application/test/spec
11
- PUID: test-fmt/002 spec-fmt/102
12
- EXTENSIONS: spc,spec
@@ -1,140 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'Type Databse' do
5
-
6
- before :all do
7
- ::Libis::Format::TypeDatabaseImpl.instance.load_types File.join(File.dirname(__FILE__), 'test_types.yml')
8
- end
9
-
10
- it 'should load types from file' do
11
-
12
- expect(::Libis::Format::TypeDatabase.typeinfo :TESTDATA).to eq GROUP: :TESTMEDIUM,
13
- TYPE: :TESTDATA,
14
- NAME: 'Test data format',
15
- PUID: %w'test-fmt/001 spec-fmt/101',
16
- MIME: %w'test/data application/test/data',
17
- EXTENSIONS: %w'dat data'
18
- expect(::Libis::Format::TypeDatabase.typeinfo :TESTSPEC).to eq GROUP: :TESTMEDIUM,
19
- TYPE: :TESTSPEC,
20
- NEW: 'Test specification format',
21
- PUID: %w'test-fmt/002 spec-fmt/102',
22
- MIME: %w'test/spec application/test/spec',
23
- EXTENSIONS: %w'spc spec'
24
- end
25
-
26
- it 'should get the type\'s group' do
27
-
28
- expect(::Libis::Format::TypeDatabase.type_group :TESTDATA).to eq :TESTMEDIUM
29
- expect(::Libis::Format::TypeDatabase.type_group :TESTSPEC).to eq :TESTMEDIUM
30
-
31
- end
32
-
33
- it 'should get the type\'s puids' do
34
-
35
- expect(::Libis::Format::TypeDatabase.type_puids :TESTDATA).to eq %w'test-fmt/001 spec-fmt/101'
36
- expect(::Libis::Format::TypeDatabase.type_puids :TESTSPEC).to eq %w'test-fmt/002 spec-fmt/102'
37
-
38
- end
39
-
40
- it 'should get the type\'s mimetypes' do
41
-
42
- expect(::Libis::Format::TypeDatabase.type_mimetypes :TESTDATA).to eq %w'test/data application/test/data'
43
- expect(::Libis::Format::TypeDatabase.type_mimetypes :TESTSPEC).to eq %w'test/spec application/test/spec'
44
-
45
- end
46
-
47
- it 'should get the type\'s extensions' do
48
-
49
- expect(::Libis::Format::TypeDatabase.type_extentions :TESTDATA).to eq %w'dat data'
50
- expect(::Libis::Format::TypeDatabase.type_extentions :TESTSPEC).to eq %w'spc spec'
51
-
52
- end
53
-
54
- it 'should get the group\'s types' do
55
-
56
- expect(::Libis::Format::TypeDatabase.group_types :TESTMEDIUM).to eq [:TESTDATA, :TESTSPEC]
57
-
58
- end
59
-
60
- it 'should get the mimetype\'s types' do
61
-
62
- expect(::Libis::Format::TypeDatabase.mime_types 'test/data').to eq [:TESTDATA]
63
- expect(::Libis::Format::TypeDatabase.mime_types 'application/test/data').to eq [:TESTDATA]
64
- expect(::Libis::Format::TypeDatabase.mime_types 'test/spec').to eq [:TESTSPEC]
65
- expect(::Libis::Format::TypeDatabase.mime_types 'application/test/spec').to eq [:TESTSPEC]
66
-
67
- end
68
-
69
- it 'should get the mimetype\'s groups' do
70
-
71
- expect(::Libis::Format::TypeDatabase.mime_groups 'test/data').to eq [:TESTMEDIUM]
72
- expect(::Libis::Format::TypeDatabase.mime_groups 'application/test/data').to eq [:TESTMEDIUM]
73
- expect(::Libis::Format::TypeDatabase.mime_groups 'test/spec').to eq [:TESTMEDIUM]
74
- expect(::Libis::Format::TypeDatabase.mime_groups 'application/test/spec').to eq [:TESTMEDIUM]
75
-
76
- end
77
-
78
- it 'should get the extension\'s types' do
79
-
80
- expect(::Libis::Format::TypeDatabase.ext_types 'dat').to eq [:TESTDATA]
81
- expect(::Libis::Format::TypeDatabase.ext_types 'data').to eq [:TESTDATA]
82
- expect(::Libis::Format::TypeDatabase.ext_types 'spc').to eq [:TESTSPEC]
83
- expect(::Libis::Format::TypeDatabase.ext_types 'spec').to eq [:TESTSPEC]
84
-
85
- end
86
-
87
- it 'should check if mimetype is known' do
88
-
89
- expect(::Libis::Format::TypeDatabase.known_mime? 'test/data').to be_truthy
90
- expect(::Libis::Format::TypeDatabase.known_mime? 'test/spec').to be_truthy
91
-
92
- end
93
-
94
- it 'should load types from hash' do
95
-
96
- ::Libis::Format::TypeDatabaseImpl.instance.load_types TESTMEDIUM: {
97
- TESTREPORT: {
98
- NAME: 'Test report format',
99
- MIME: 'test/report application/test/report',
100
- EXTENSIONS: 'rep'
101
- }
102
- }
103
-
104
- expect(::Libis::Format::TypeDatabase.typeinfo :TESTREPORT).to eq GROUP: :TESTMEDIUM,
105
- TYPE: :TESTREPORT,
106
- NAME: 'Test report format',
107
- MIME: %w'test/report application/test/report',
108
- EXTENSIONS: %w'rep'
109
-
110
- end
111
-
112
- it 'should merge types from hash' do
113
-
114
- ::Libis::Format::TypeDatabaseImpl.instance.load_types TESTMEDIUM: {
115
- TESTREPORT: {
116
- EXTENSIONS: 'rpt'
117
- }
118
- }
119
-
120
- expect(::Libis::Format::TypeDatabase.typeinfo :TESTREPORT).to eq GROUP: :TESTMEDIUM,
121
- TYPE: :TESTREPORT,
122
- NAME: 'Test report format',
123
- MIME: %w'test/report application/test/report',
124
- EXTENSIONS: %w'rep rpt'
125
-
126
- ::Libis::Format::TypeDatabaseImpl.instance.load_types({TESTMEDIUM: {
127
- TESTREPORT: {
128
- EXTENSIONS: 'report'
129
- }
130
- }}, false)
131
-
132
- expect(::Libis::Format::TypeDatabase.typeinfo :TESTREPORT).to eq GROUP: :TESTMEDIUM,
133
- TYPE: :TESTREPORT,
134
- NAME: 'Test report format',
135
- MIME: %w'test/report application/test/report',
136
- EXTENSIONS: %w'report rep rpt'
137
-
138
- end
139
-
140
- end
Binary file
Binary file
Binary file