aspera-cli 4.29.1 → 4.30.0

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.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +4 -4
  3. data/CHANGELOG.md +119 -0
  4. data/CONTRIBUTING.md +8 -1
  5. data/README.md +2 -0
  6. data/TODO.md +4 -5
  7. data/bin/asession +2 -2
  8. data/docs/README.md +616 -86
  9. data/docs/test-mcp-with-ai.md +4 -0
  10. data/lib/aspera/agent/base.rb +62 -6
  11. data/lib/aspera/agent/factory.rb +127 -20
  12. data/lib/aspera/ascp/data_repository.rb +71 -0
  13. data/lib/aspera/ascp/installation.rb +16 -11
  14. data/lib/aspera/ascp/log_analyzer/lines.rb +4 -4
  15. data/lib/aspera/ascp/log_analyzer/log_file.rb +5 -3
  16. data/lib/aspera/ascp/log_analyzer/records.rb +11 -6
  17. data/lib/aspera/ascp/log_analyzer.rb +43 -18
  18. data/lib/aspera/ascp/log_locations.rb +2 -2
  19. data/lib/aspera/assert.rb +8 -0
  20. data/lib/aspera/bundle_registry.rb +528 -0
  21. data/lib/aspera/cli/argument.rb +110 -0
  22. data/lib/aspera/cli/bool_value.rb +41 -0
  23. data/lib/aspera/cli/bootstrapper.rb +31 -24
  24. data/lib/aspera/cli/command/mount.rb +53 -0
  25. data/lib/aspera/cli/command/registry.rb +434 -0
  26. data/lib/aspera/cli/command.rb +95 -0
  27. data/lib/aspera/cli/command_line.rb +91 -91
  28. data/lib/aspera/cli/complete.rb +22 -0
  29. data/lib/aspera/cli/completion_actions.rb +28 -26
  30. data/lib/aspera/cli/context.rb +29 -6
  31. data/lib/aspera/cli/error.rb +39 -0
  32. data/lib/aspera/cli/extended_value.rb +25 -4
  33. data/lib/aspera/cli/formatter.rb +8 -8
  34. data/lib/aspera/cli/hints.rb +17 -52
  35. data/lib/aspera/cli/http.rb +17 -12
  36. data/lib/aspera/cli/mailer.rb +7 -24
  37. data/lib/aspera/cli/mcp/tool.rb +10 -2
  38. data/lib/aspera/cli/option/declarator.rb +80 -0
  39. data/lib/aspera/cli/option/registry.rb +74 -0
  40. data/lib/aspera/cli/option/source.rb +38 -0
  41. data/lib/aspera/cli/option/type.rb +37 -0
  42. data/lib/aspera/cli/option/value.rb +376 -0
  43. data/lib/aspera/cli/option.rb +78 -0
  44. data/lib/aspera/cli/options.schema.yaml +28 -783
  45. data/lib/aspera/cli/parser.rb +73 -41
  46. data/lib/aspera/cli/plugins/base.rb +122 -42
  47. data/lib/aspera/cli/plugins/basic_auth.rb +13 -2
  48. data/lib/aspera/cli/plugins/config.rb +101 -167
  49. data/lib/aspera/cli/plugins/factory.rb +139 -43
  50. data/lib/aspera/cli/plugins/mcp.rb +61 -54
  51. data/lib/aspera/cli/plugins/oauth.rb +19 -6
  52. data/lib/aspera/cli/poll.rb +14 -20
  53. data/lib/aspera/cli/preset_actions.rb +11 -3
  54. data/lib/aspera/cli/preset_manager.rb +16 -6
  55. data/lib/aspera/cli/result.rb +2 -2
  56. data/lib/aspera/cli/runner.rb +71 -99
  57. data/lib/aspera/cli/secret_finder.rb +1 -1
  58. data/lib/aspera/cli/security.rb +102 -4
  59. data/lib/aspera/{preview/terminal.rb → cli/terminal_image.rb} +93 -94
  60. data/lib/aspera/cli/vault_manager.rb +3 -3
  61. data/lib/aspera/cli/version.rb +1 -1
  62. data/lib/aspera/cli/wizard.rb +9 -3
  63. data/lib/aspera/coverage.rb +1 -2
  64. data/lib/aspera/line_logger.rb +35 -6
  65. data/lib/aspera/log.rb +3 -2
  66. data/lib/aspera/oauth/client/base.rb +19 -1
  67. data/lib/aspera/oauth/client/factory.rb +1 -7
  68. data/lib/aspera/plugin.schema.yaml +178 -0
  69. data/lib/aspera/plugins/alee/api.rb +25 -0
  70. data/lib/aspera/{cli/plugins/alee.rb → plugins/alee/commands.rb} +10 -8
  71. data/lib/aspera/plugins/alee/plugin.yaml +3 -0
  72. data/lib/aspera/plugins/aoc/admin_resources.rb +148 -0
  73. data/lib/aspera/plugins/aoc/api.rb +783 -0
  74. data/lib/aspera/{cli/plugins/aoc.rb → plugins/aoc/commands.rb} +404 -330
  75. data/lib/aspera/plugins/aoc/graphql.rb +45 -0
  76. data/lib/aspera/plugins/aoc/plugin.yaml +31 -0
  77. data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +15042 -7076
  78. data/lib/aspera/plugins/aoc/schemas/options.yaml +47 -0
  79. data/lib/aspera/plugins/ats/api.rb +51 -0
  80. data/lib/aspera/{cli/plugins/ats.rb → plugins/ats/commands.rb} +33 -33
  81. data/lib/aspera/plugins/ats/plugin.yaml +6 -0
  82. data/lib/aspera/plugins/connect/agent.rb +199 -0
  83. data/lib/aspera/plugins/connect/plugin.yaml +11 -0
  84. data/lib/aspera/plugins/connect/schemas/agent_options.yaml +6 -0
  85. data/lib/aspera/{cli/plugins/console.rb → plugins/console/commands.rb} +41 -33
  86. data/lib/aspera/plugins/console/plugin.yaml +8 -0
  87. data/lib/aspera/plugins/cos/api.rb +114 -0
  88. data/lib/aspera/{cli/plugins/cos.rb → plugins/cos/commands.rb} +19 -16
  89. data/lib/aspera/plugins/cos/plugin.yaml +9 -0
  90. data/lib/aspera/plugins/cos/schemas/options.yaml +30 -0
  91. data/lib/aspera/plugins/desktop/agent.rb +165 -0
  92. data/lib/aspera/plugins/desktop/plugin.yaml +11 -0
  93. data/lib/aspera/plugins/desktop/schemas/agent_options.yaml +6 -0
  94. data/lib/aspera/plugins/direct/agent.rb +518 -0
  95. data/lib/aspera/plugins/direct/plugin.yaml +11 -0
  96. data/lib/aspera/plugins/direct/schemas/agent_options.yaml +86 -0
  97. data/lib/aspera/plugins/faspex4/gateway_options.rb +18 -0
  98. data/lib/aspera/plugins/faspex4/gw_servlet.rb +122 -0
  99. data/lib/aspera/plugins/faspex4/plugin.yaml +7 -0
  100. data/lib/aspera/plugins/faspex4/schemas/options.yaml +57 -0
  101. data/lib/aspera/plugins/faspex5/api.rb +269 -0
  102. data/lib/aspera/{cli/plugins/faspex5.rb → plugins/faspex5/commands.rb} +152 -114
  103. data/lib/aspera/plugins/faspex5/faspex4_post_proc_servlet.rb +241 -0
  104. data/lib/aspera/plugins/faspex5/plugin.yaml +14 -0
  105. data/lib/aspera/{schema → plugins/faspex5/schemas}/IBM Aspera Faspex API-5.0-enhanced.yaml +279 -76
  106. data/lib/aspera/plugins/faspex5/schemas/options.yaml +87 -0
  107. data/lib/aspera/{cli/plugins/faspio.rb → plugins/faspio/commands.rb} +11 -7
  108. data/lib/aspera/plugins/faspio/plugin.yaml +8 -0
  109. data/lib/aspera/{schema → plugins/faspio/schemas}/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +4 -2
  110. data/lib/aspera/plugins/httpgw/agent.rb +126 -0
  111. data/lib/aspera/plugins/httpgw/api.rb +411 -0
  112. data/lib/aspera/{cli/plugins/httpgw.rb → plugins/httpgw/commands.rb} +9 -9
  113. data/lib/aspera/plugins/httpgw/plugin.yaml +12 -0
  114. data/lib/aspera/plugins/httpgw/schemas/agent_options.yaml +24 -0
  115. data/lib/aspera/plugins/node/agent.rb +184 -0
  116. data/lib/aspera/plugins/node/api.rb +699 -0
  117. data/lib/aspera/{cli/plugins/node.rb → plugins/node/commands.rb} +166 -141
  118. data/lib/aspera/plugins/node/emulator.rb +774 -0
  119. data/lib/aspera/plugins/node/plugin.yaml +20 -0
  120. data/lib/aspera/plugins/node/schemas/agent_options.yaml +20 -0
  121. data/lib/aspera/plugins/node/schemas/options.yaml +190 -0
  122. data/lib/aspera/{cli/plugins/orchestrator.rb → plugins/orchestrator/commands.rb} +139 -110
  123. data/lib/aspera/plugins/orchestrator/plugin.yaml +34 -0
  124. data/lib/aspera/{schema → plugins/orchestrator/schemas}/IBM Aspera Orchestrator API-v1-enhanced.yaml +486 -16
  125. data/lib/aspera/plugins/orchestrator/schemas/options.yaml +143 -0
  126. data/lib/aspera/plugins/orchestrator/workflow_checker.rb +692 -0
  127. data/lib/aspera/{cli/plugins/preview.rb → plugins/preview/commands.rb} +53 -51
  128. data/lib/aspera/plugins/preview/file_types.rb +121 -0
  129. data/lib/aspera/plugins/preview/generator.rb +350 -0
  130. data/lib/aspera/plugins/preview/plugin.yaml +12 -0
  131. data/lib/aspera/{preview/options.schema.yaml → plugins/preview/schemas/options.yaml} +1 -1
  132. data/lib/aspera/plugins/preview/utils.rb +213 -0
  133. data/lib/aspera/plugins/server/ascmd.rb +374 -0
  134. data/lib/aspera/{cli/plugins/server.rb → plugins/server/commands.rb} +48 -32
  135. data/lib/aspera/plugins/server/plugin.yaml +9 -0
  136. data/lib/aspera/plugins/server/schemas/options.yaml +30 -0
  137. data/lib/aspera/{cli/plugins/shares.rb → plugins/shares/commands.rb} +29 -21
  138. data/lib/aspera/plugins/shares/plugin.yaml +10 -0
  139. data/lib/aspera/plugins/shares/shares_web.rb +97 -0
  140. data/lib/aspera/plugins/transferd/agent.rb +258 -0
  141. data/lib/aspera/plugins/transferd/api.rb +180 -0
  142. data/lib/aspera/plugins/transferd/client.rb +67 -0
  143. data/lib/aspera/{cli/plugins/transferd.rb → plugins/transferd/commands.rb} +43 -42
  144. data/lib/aspera/plugins/transferd/config_commands.rb +38 -0
  145. data/lib/aspera/plugins/transferd/plugin.yaml +27 -0
  146. data/lib/aspera/plugins/transferd/product.rb +146 -0
  147. data/lib/aspera/plugins/transferd/schemas/agent_options.yaml +31 -0
  148. data/lib/aspera/plugins/transferd/schemas/options.yaml +80 -0
  149. data/lib/aspera/plugins/transferd/service.rb +617 -0
  150. data/lib/aspera/plugins/xfer/ascp_actions.rb +131 -0
  151. data/lib/aspera/plugins/xfer/ascp_logs_actions.rb +198 -0
  152. data/lib/aspera/plugins/xfer/async_transfer_store.rb +131 -0
  153. data/lib/aspera/plugins/xfer/config_commands.rb +119 -0
  154. data/lib/aspera/plugins/xfer/helper.rb +19 -0
  155. data/lib/aspera/plugins/xfer/plugin.yaml +42 -0
  156. data/lib/aspera/plugins/xfer/schemas/agent_extension.schema.yaml +26 -0
  157. data/lib/aspera/plugins/xfer/schemas/options.yaml +125 -0
  158. data/lib/aspera/plugins/xfer/sync_actions.rb +253 -0
  159. data/lib/aspera/plugins/xfer/transfer_actions.rb +176 -0
  160. data/lib/aspera/plugins/xfer/transfer_agent.rb +505 -0
  161. data/lib/aspera/products/cli_v3.rb +34 -0
  162. data/lib/aspera/products/connect.rb +1 -1
  163. data/lib/aspera/products/drive.rb +29 -0
  164. data/lib/aspera/products/hsts.rb +34 -0
  165. data/lib/aspera/products/transferd.rb +25 -3
  166. data/lib/aspera/products.rb +54 -0
  167. data/lib/aspera/prompt.rb +184 -0
  168. data/lib/aspera/proxy_auto_config.rb +3 -3
  169. data/lib/aspera/rest/aspera_errors.rb +4 -38
  170. data/lib/aspera/rest/error_analyzer.rb +6 -2
  171. data/lib/aspera/rest/list.rb +4 -5
  172. data/lib/aspera/schema/reader.rb +15 -0
  173. data/lib/aspera/schema/registry.rb +239 -45
  174. data/lib/aspera/schema/validator.rb +63 -17
  175. data/lib/aspera/sealed_hash.rb +4 -0
  176. data/lib/aspera/secret/hider.rb +159 -24
  177. data/lib/aspera/secret/reference.rb +8 -0
  178. data/lib/aspera/secret/resolver.rb +8 -4
  179. data/lib/aspera/secret/store/base.rb +10 -9
  180. data/lib/aspera/secret/store/encrypted_hash.rb +6 -6
  181. data/lib/aspera/secret/store/hashicorp_vault.rb +3 -3
  182. data/lib/aspera/secret/store/keeper.rb +2 -2
  183. data/lib/aspera/secret/store/macos_security.rb +2 -3
  184. data/lib/aspera/secret/store/one_password_api.rb +2 -2
  185. data/lib/aspera/secret/store/one_password_cli.rb +3 -3
  186. data/lib/aspera/secret/store/secret_service.rb +2 -2
  187. data/lib/aspera/ssl.rb +3 -3
  188. data/lib/aspera/standard_input.rb +20 -0
  189. data/lib/aspera/{schema → sync}/async_tables.yaml +1 -1
  190. data/lib/aspera/sync/database.rb +7 -0
  191. data/lib/aspera/sync/log_parser.rb +138 -0
  192. data/lib/aspera/sync/operations.rb +59 -34
  193. data/lib/aspera/transfer/command_line_builder.rb +248 -0
  194. data/lib/aspera/transfer/command_line_converter.rb +37 -0
  195. data/lib/aspera/transfer/faux_file.rb +2 -2
  196. data/lib/aspera/transfer/parameters.rb +9 -10
  197. data/lib/aspera/transfer/spec.rb +28 -1
  198. data/lib/aspera/transfer/spec.schema.yaml +30 -5
  199. data/lib/aspera/units/decimal.rb +1 -1
  200. data/lib/aspera/units/timestamp.rb +84 -0
  201. data/lib/aspera/uri_reader.rb +2 -2
  202. data/lib/aspera/web_auth/paste.rb +2 -2
  203. data/lib/aspera/web_server_simple.rb +10 -4
  204. data.tar.gz.sig +0 -0
  205. metadata +137 -80
  206. metadata.gz.sig +0 -0
  207. data/lib/aspera/agent/connect.rb +0 -188
  208. data/lib/aspera/agent/desktop.rb +0 -154
  209. data/lib/aspera/agent/direct.rb +0 -496
  210. data/lib/aspera/agent/httpgw.rb +0 -100
  211. data/lib/aspera/agent/node.rb +0 -166
  212. data/lib/aspera/agent/transferd.rb +0 -341
  213. data/lib/aspera/api/alee.rb +0 -19
  214. data/lib/aspera/api/aoc.rb +0 -776
  215. data/lib/aspera/api/ats.rb +0 -49
  216. data/lib/aspera/api/cos_node.rb +0 -107
  217. data/lib/aspera/api/faspex.rb +0 -258
  218. data/lib/aspera/api/httpgw.rb +0 -409
  219. data/lib/aspera/api/node.rb +0 -684
  220. data/lib/aspera/ascmd.rb +0 -248
  221. data/lib/aspera/cli/ascp_actions.rb +0 -113
  222. data/lib/aspera/cli/ascp_logs_actions.rb +0 -188
  223. data/lib/aspera/cli/async_transfer_store.rb +0 -129
  224. data/lib/aspera/cli/command_registry.rb +0 -371
  225. data/lib/aspera/cli/command_spec.rb +0 -273
  226. data/lib/aspera/cli/option_declarator.rb +0 -74
  227. data/lib/aspera/cli/option_registry.rb +0 -72
  228. data/lib/aspera/cli/option_types.rb +0 -120
  229. data/lib/aspera/cli/option_value.rb +0 -345
  230. data/lib/aspera/cli/prompt.rb +0 -186
  231. data/lib/aspera/cli/sync_actions.rb +0 -181
  232. data/lib/aspera/cli/transfer_actions.rb +0 -98
  233. data/lib/aspera/cli/transfer_agent.rb +0 -348
  234. data/lib/aspera/command_line_builder.rb +0 -244
  235. data/lib/aspera/command_line_converter.rb +0 -35
  236. data/lib/aspera/data_repository.rb +0 -69
  237. data/lib/aspera/faspex_gw.rb +0 -172
  238. data/lib/aspera/faspex_postproc.rb +0 -237
  239. data/lib/aspera/graphql.rb +0 -41
  240. data/lib/aspera/node_emulator.rb +0 -758
  241. data/lib/aspera/oauth/client/shares_web.rb +0 -94
  242. data/lib/aspera/orchestrator_workflow_checker.rb +0 -688
  243. data/lib/aspera/preview/file_types.rb +0 -119
  244. data/lib/aspera/preview/generator.rb +0 -345
  245. data/lib/aspera/preview/utils.rb +0 -211
  246. data/lib/aspera/products/other.rb +0 -92
  247. data/lib/aspera/products/transferd_service.rb +0 -610
  248. /data/lib/aspera/{data → ascp/data}/1 +0 -0
  249. /data/lib/aspera/{data → ascp/data}/2 +0 -0
  250. /data/lib/aspera/{data → ascp/data}/3 +0 -0
  251. /data/lib/aspera/{data → ascp/data}/4 +0 -0
  252. /data/lib/aspera/{data → ascp/data}/5 +0 -0
  253. /data/lib/aspera/{data → ascp/data}/6 +0 -0
  254. /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_account.graphql +0 -0
  255. /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_usage.graphql +0 -0
  256. /data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +0 -0
  257. /data/lib/aspera/{schema → plugins/console/schemas}/IBM Aspera Console-enhanced.yaml +0 -0
  258. /data/lib/aspera/{schema → plugins/node/schemas}/IBM Aspera Node API-4.4.6.yaml +0 -0
  259. /data/lib/aspera/{preview → plugins/preview}/image_error.png +0 -0
  260. /data/lib/aspera/{preview → plugins/preview}/video_error.png +0 -0
  261. /data/lib/aspera/{schema → plugins/shares/schemas}/IBM_Aspera_Shares.yaml +0 -0
  262. /data/lib/{transferd_pb.rb → aspera/plugins/transferd/grpc/transferd_pb.rb} +0 -0
  263. /data/lib/{transferd_services_pb.rb → aspera/plugins/transferd/grpc/transferd_services_pb.rb} +0 -0
  264. /data/lib/aspera/{schema → plugins/transferd/schemas}/transferd-config.schema.json +0 -0
@@ -1,119 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: IBM Corp.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- require_relative '../log'
7
- require_relative '../assert'
8
- require 'singleton'
9
- require 'marcel'
10
-
11
- module Aspera
12
- module Preview
13
- # function conversion_type returns one of the types: CONVERSION_TYPES
14
- #
15
- # @!method self.instance
16
- # Returns the singleton instance of FileTypes
17
- # @return [FileTypes] the singleton instance
18
- class FileTypes
19
- include Singleton
20
-
21
- # values for conversion_type : input format
22
- CONVERSION_TYPES = %i[image office pdf plaintext video].freeze
23
-
24
- # Special cases for MIME types
25
- # spellchecker:disable
26
- SUPPORTED_MIME_TYPES = {
27
- 'application/json' => :plaintext,
28
- 'text/plain' => :plaintext,
29
- 'application/pdf' => :pdf,
30
- 'audio/ogg' => :video,
31
- 'application/mxf' => :video,
32
- 'application/mac-binhex40' => :office,
33
- 'application/msword' => :office,
34
- 'application/vnd.ms-excel' => :office,
35
- 'application/vnd.ms-powerpoint' => :office,
36
- 'application/rtf' => :office,
37
- 'application/x-abiword' => :office,
38
- 'application/x-mspublisher' => :office,
39
- 'image/vnd.dxf' => :office,
40
- 'image/x-cmx' => :office,
41
- 'image/x-freehand' => :office,
42
- 'image/x-pict' => :office,
43
- 'text/csv' => :office,
44
- 'text/html' => :office,
45
- 'application/dicom' => :image,
46
- 'application/postscript' => :image,
47
- 'application/vnd.3gpp.pic-bw-small' => :image,
48
- 'application/vnd.hp-hpgl' => :image,
49
- 'application/vnd.hp-pcl' => :image,
50
- 'application/vnd.mobius.msl' => :image,
51
- 'application/vnd.mophun.certificate' => :image,
52
- 'application/x-director' => :image,
53
- 'application/x-font-type1' => :image,
54
- 'application/x-msmetafile' => :image,
55
- 'application/x-xfig' => :image,
56
- 'font/ttf' => :image,
57
- 'text/troff' => :image,
58
- 'video/x-mng' => :image
59
- }.freeze
60
-
61
- private_constant :SUPPORTED_MIME_TYPES
62
-
63
- # @attr detect_mime [Boolean] `true` to determine real mime type based on file content
64
- attr_accessor :detect_mime
65
-
66
- def initialize
67
- @detect_mime = false
68
- end
69
-
70
- # @param mimetype [String] mime type
71
- # @return [NilClass,Symbol] file type, one of enum CONVERSION_TYPES, or nil if not found
72
- def mime_to_type(mimetype)
73
- Aspera.assert_type(mimetype, String)
74
- return SUPPORTED_MIME_TYPES[mimetype] if SUPPORTED_MIME_TYPES.key?(mimetype)
75
- return :office if mimetype.start_with?('application/vnd.ms-')
76
- return :office if mimetype.start_with?('application/vnd.openxmlformats-officedocument')
77
- return :video if mimetype.start_with?('video/')
78
- return :image if mimetype.start_with?('image/')
79
- return
80
- end
81
-
82
- # @param filepath [String] Full path to file
83
- # @param mimetype [String] MIME typre provided by node API
84
- # @return [Symbol] file type, one of enum CONVERSION_TYPES
85
- # @raise [RuntimeError] if no conversion type found
86
- def conversion_type(filepath, mimetype)
87
- Log.log.debug { "conversion_type(#{filepath},mime=#{mimetype},magic=#{@detect_mime})" }
88
- # Default type or empty means no type
89
- mimetype = TYPE_NOT_FOUND if mimetype.nil? || (mimetype.is_a?(String) && mimetype.empty?)
90
- mimetype = Marcel::MimeType.for(Pathname.new(filepath), name: File.basename(filepath), declared_type: mimetype)
91
- mimetype = 'text/plain' if mimetype.eql?(TYPE_NOT_FOUND) && ascii_text_file?(filepath)
92
- Aspera.assert(!mimetype.eql?(TYPE_NOT_FOUND)) { "no MIME type found for #{File.basename(filepath)}" }
93
- conversion_type = mime_to_type(mimetype)
94
- Aspera.assert(!conversion_type.nil?) { "no conversion type found for #{File.basename(filepath)}" }
95
- Log.log.trace1 { "conversion_type(#{File.basename(filepath)}): #{conversion_type.class.name} [#{conversion_type}]" }
96
- return conversion_type
97
- end
98
-
99
- private
100
-
101
- TYPE_NOT_FOUND = 'application/octet-stream'
102
- ACCEPT_CTRL_CHARS = [9, 10, 13].freeze
103
-
104
- # Returns true if the file looks like ASCII text (printable ASCII + \t, \r, \n, space).
105
- # It reads only a small prefix (default: 64KB) and fails fast on the first bad byte.
106
- def ascii_text_file?(path, sample_size: 64 * 1024)
107
- File.open(path, 'rb') do |f|
108
- sample = f.read(sample_size) || ''.b
109
- sample.each_byte do |b|
110
- next if b.between?(32, 126) || ACCEPT_CTRL_CHARS.include?(b)
111
- # Any other control character => not ASCII text
112
- return false
113
- end
114
- true
115
- end
116
- end
117
- end
118
- end
119
- end
@@ -1,345 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: IBM Corp.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- # ffmpeg options:
7
- # spellchecker:ignore soffice pauseframes libx264 trunc bufsize muxer apng libmp3lame maxrate posterize movflags faststart
8
- # spellchecker:ignore palettegen paletteuse pointsize bordercolor repage lanczos unoconv optipng reencode conv transframes
9
-
10
- require_relative 'utils'
11
- require_relative 'file_types'
12
- require_relative '../schema/registry'
13
- require_relative '../log'
14
- require_relative '../assert'
15
- require 'fileutils'
16
-
17
- module Aspera
18
- module Preview
19
- # Generates one preview file for one format for one file at a time.
20
- class Generator
21
- # Values for preview_format: output format.
22
- PREVIEW_FORMATS = %i[png mp4].freeze
23
-
24
- # List of valid ffmpeg option keys for reencode configuration.
25
- FFMPEG_OPTIONS_LIST = %w[in out].freeze
26
-
27
- # Generator options, members defined in `options.schema.yaml`.
28
- Options = Struct.new(*Schema::Registry.instance.reader(Schema::Registry::PREVIEW_OPTIONS).current['properties'].keys.map(&:to_sym))
29
-
30
- # CLI needs to know conversion type to know if need skip it.
31
- # One of CONVERSION_TYPES.
32
- attr_reader :conversion_type, :destination
33
-
34
- # Node API MIME types are from: http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types.
35
- # The resulting preview file type is taken from destination file extension.
36
- # Conversion methods are provided by private methods: convert_<conversion_type>_to_<preview_format>.
37
- # conversion_type: one of FileTypes::CONVERSION_TYPES.
38
- # preview_format: one of Generator::PREVIEW_FORMATS.
39
- # The conversion video->mp4 is implemented in methods: convert_video_to_mp4_using_<video_conversion>.
40
- # conversion method: one of Generator::VIDEO_CONVERSION_METHODS.
41
- # @param src [String] Source file path.
42
- # @param dst [String] Destination file path.
43
- # @param options [Options] All conversion options.
44
- # @param main_temp_dir [String] Main temp folder, sub folder will be created for generation.
45
- # @param mime [String, nil] Optional MIME type as provided by node api (or nil).
46
- def initialize(src, dst, options, main_temp_dir, mime: nil)
47
- # Source file path
48
- @source = src
49
- # Destination file path
50
- @destination = dst
51
- @options = options
52
- # temp folder name based on source file
53
- @temp_folder = File.join(main_temp_dir, @source.split('/').last.gsub(/\s/, '_').gsub(/\W/, ''))
54
- # Extract preview format from extension of target file.
55
- @preview_format_sym = File.extname(@destination).gsub(/^\./, '').to_sym
56
- conversion_type = FileTypes.instance.conversion_type(@source, mime)
57
- @processing_method = "convert_#{conversion_type}_to_#{@preview_format_sym}"
58
- if conversion_type.eql?(:video)
59
- case @preview_format_sym
60
- when :mp4
61
- @processing_method = "#{@processing_method}_using_#{@options.video_conversion}"
62
- when :png
63
- @processing_method = "#{@processing_method}_using_#{@options.video_png_conv}"
64
- end
65
- end
66
- @processing_method = @processing_method.to_sym
67
- Log.log.debug { "method: #{@processing_method}" }
68
- Aspera.assert(respond_to?(@processing_method, true)) { "no processing known for #{conversion_type} -> #{@preview_format_sym}" }
69
- command = [:magick] + %w[identify -list font]
70
- magick_fonts = Utils.parse_magick_fonts(Utils.execute(*command, mode: :capture).first)
71
- Aspera.assert(magick_fonts[:fonts].any? { |f| f[:name].eql?(@options.thumb_text_font) }) { "Missing font #{@options.thumb_text_font} in #{command}" }
72
- end
73
-
74
- # Creates preview as specified in constructor.
75
- def generate
76
- Log.log.debug { "#{@source}->#{@destination} (#{@processing_method})" }
77
- begin
78
- send(@processing_method)
79
- # Check that generated size does not exceed maximum.
80
- result_size = File.size(@destination)
81
- Log.log.warn { "preview size exceeds maximum allowed #{result_size} > #{@options.max_size}" } if result_size > @options.max_size
82
- ensure
83
- FileUtils.rm_rf(@temp_folder)
84
- end
85
- end
86
-
87
- # Path to error image corresponding to preview type.
88
- # @return [String] The path to the error image.
89
- def error_asset
90
- File.expand_path(@preview_format_sym.eql?(:mp4) ? 'video_error.png' : 'image_error.png', File.dirname(__FILE__))
91
- end
92
-
93
- private
94
-
95
- # Creates a unique temp folder for file.
96
- # @return [String] The temporary folder path.
97
- def this_tmpdir
98
- FileUtils.mkdir_p(@temp_folder)
99
- return @temp_folder
100
- end
101
-
102
- # Calculates offset in seconds for video frame extraction.
103
- # @param duration [Float] Duration of video in seconds.
104
- # @param start_offset [Numeric] Start offset of parts in seconds.
105
- # @param total_count [Integer] Total count of parts.
106
- # @param index [Integer] Index of part (starts at 1).
107
- # @return [Float] Offset in seconds suitable for ffmpeg -ss option.
108
- def get_offset(duration, start_offset, total_count, index)
109
- Aspera.assert_type(duration, Float) { 'duration' }
110
- return start_offset + ((index - 1) * (duration - start_offset) / total_count)
111
- end
112
-
113
- # Converts video to MP4 using blend method.
114
- # Extracts key frames and blends them with transitions.
115
- def convert_video_to_mp4_using_blend
116
- p_duration = Utils.video_get_duration(@source)
117
- p_start_offset = @options.video_start_sec.to_i
118
- p_key_frame_count = @options.blend_keyframes.to_i
119
- last_keyframe = nil
120
- current_index = 1
121
- frame_rate_hz = 30
122
- 1.upto(p_key_frame_count) do |i|
123
- Utils.video_dump_frame(
124
- @source,
125
- get_offset(p_duration, p_start_offset, p_key_frame_count, i),
126
- @options.video_scale,
127
- Utils.get_tmp_num_filepath(this_tmpdir, current_index)
128
- )
129
- Utils.video_dupe_frame(this_tmpdir, current_index, @options.blend_pauseframes)
130
- Utils.video_blend_frames(this_tmpdir, last_keyframe, current_index) unless last_keyframe.nil?
131
- # Go to last dupe frame.
132
- last_keyframe = current_index + @options.blend_pauseframes
133
- # Go after last dupe frame and keep space to blend.
134
- current_index = last_keyframe + 1 + @options.blend_transframes
135
- end
136
- Utils.ffmpeg(
137
- in: [
138
- Utils.ffmpeg_fmt(this_tmpdir),
139
- '-framerate', @options.blend_fps
140
- ],
141
- out: [
142
- @destination,
143
- '-filter:v', "scale='trunc(iw/2)*2:trunc(ih/2)*2'",
144
- '-codec:v', 'libx264',
145
- '-r', frame_rate_hz,
146
- '-pix_fmt', 'yuv420p'
147
- ]
148
- )
149
- end
150
-
151
- # Converts video to MP4 using clips method.
152
- # Generates n clips starting at offset and concatenates them.
153
- def convert_video_to_mp4_using_clips
154
- p_duration = Utils.video_get_duration(@source)
155
- file_list_file = File.join(this_tmpdir, 'clip_files.txt')
156
- File.open(file_list_file, 'w+') do |f|
157
- 1.upto(@options.clips_count.to_i) do |i|
158
- offset_seconds = get_offset(p_duration, @options.video_start_sec.to_i, @options.clips_count.to_i, i)
159
- tmp_file_name = format('clip%04d.mp4', i)
160
- Utils.ffmpeg(
161
- in: [
162
- @source,
163
- '-ss', offset_seconds * 0.9
164
- ],
165
- out: [
166
- File.join(this_tmpdir, tmp_file_name),
167
- '-ss', offset_seconds * 0.1,
168
- '-t', @options.clips_length,
169
- '-filter:v', "scale='#{@options.video_scale}'",
170
- '-codec:a', 'libmp3lame'
171
- ]
172
- )
173
- f.puts("file '#{tmp_file_name}'")
174
- end
175
- end
176
- # Concat clips.
177
- Utils.ffmpeg(
178
- in: [file_list_file, '-f', 'concat'],
179
- out: [@destination, '-codec', 'copy']
180
- )
181
- File.delete(file_list_file)
182
- end
183
-
184
- # Converts video to MP4 using re-encoding method.
185
- # Performs a simple re-encoding with configurable ffmpeg options.
186
- def convert_video_to_mp4_using_reencode
187
- options = @options.reencode_ffmpeg
188
- Aspera.assert_type(options, Hash) { 'reencode_ffmpeg' }
189
- options.each do |k, v|
190
- Aspera.assert_values(k, FFMPEG_OPTIONS_LIST) { 'key' }
191
- Aspera.assert_type(v, Array) { k }
192
- end
193
- codec = @options.video_codec || Utils.available_h264_encoder
194
- in_opts = options['in'] || ['-ss', @options.video_start_sec.to_i * 0.9]
195
- out_opts = options['out'] || [
196
- '-t', 60,
197
- '-codec:v', codec,
198
- '-profile:v', 'high',
199
- '-pix_fmt', 'yuv420p',
200
- '-preset', 'slow',
201
- '-b:v', '500k',
202
- '-maxrate', '500k',
203
- '-bufsize', '1000k',
204
- '-filter:v', "scale='#{@options.video_scale}'",
205
- '-threads', '0',
206
- '-codec:a', 'libmp3lame',
207
- '-ac', '2',
208
- '-b:a', '128k',
209
- '-movflags', 'faststart'
210
- ]
211
- Utils.ffmpeg(
212
- in: [@source, *in_opts],
213
- out: [@destination, *out_opts]
214
- )
215
- end
216
-
217
- # Converts video to PNG using fixed frame method.
218
- # Generates a static thumbnail at a specific time offset.
219
- def convert_video_to_png_using_fixed
220
- Utils.video_dump_frame(
221
- @source,
222
- Utils.video_get_duration(@source) * @options.thumb_vid_fraction,
223
- @options.thumb_vid_scale,
224
- @destination
225
- )
226
- end
227
-
228
- # Converts video to animated PNG (APNG).
229
- # Creates an animated thumbnail with looping.
230
- # @see https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2015#AnimatedPortableNetworkGraphicsAPNG
231
- def convert_video_to_png_using_animated
232
- p_duration = Utils.video_get_duration(@source)
233
- p_start_offset = @options.video_start_sec.to_i
234
- p_max_duration = @options.clips_length.to_i
235
- # If video is shorter than start offset + duration, adjust to capture from start.
236
- if p_duration <= (p_start_offset + p_max_duration)
237
- p_start_offset = 0
238
- p_max_duration = p_duration
239
- end
240
- Utils.ffmpeg(
241
- in: [
242
- @source,
243
- '-ss', p_start_offset,
244
- '-t', p_max_duration
245
- ],
246
- out: [
247
- @destination,
248
- '-vf', 'fps=5,scale=120:-1:flags=lanczos',
249
- '-plays', 0, # Loop forever (0 = infinite loop for APNG).
250
- '-f', 'apng'
251
- ]
252
- )
253
- end
254
-
255
- # Converts office document to PNG.
256
- # First converts to PDF, then to PNG image.
257
- def convert_office_to_png
258
- tmp_pdf_file = File.join(this_tmpdir, "#{File.basename(@source, File.extname(@source))}.pdf")
259
- case @options.office_conversion
260
- when :unoconv
261
- # `unoconv` is a python wrapper over `soffice`
262
- Utils.silent_execute(
263
- :unoconv,
264
- '-f', 'pdf',
265
- '-o', tmp_pdf_file,
266
- @source
267
- )
268
- when :soffice
269
- Utils.silent_execute(
270
- :soffice,
271
- '--headless',
272
- '--invisible',
273
- '--nocrashreport',
274
- '--nodefault',
275
- '--nofirststartwizard',
276
- '--nologo',
277
- '--norestore',
278
- '--convert-to', 'pdf',
279
- '--outdir', File.dirname(tmp_pdf_file),
280
- @source
281
- )
282
- # soffice creates the file with the source name, so we need to rename it if needed.
283
- generated_pdf = File.join(File.dirname(tmp_pdf_file), "#{File.basename(@source, File.extname(@source))}.pdf")
284
- FileUtils.mv(generated_pdf, tmp_pdf_file) if generated_pdf != tmp_pdf_file
285
- else Aspera.error_unexpected_value(@options.office_conversion) { 'office_conversion' }
286
- end
287
- convert_pdf_to_png(tmp_pdf_file)
288
- end
289
-
290
- # Converts PDF to PNG image.
291
- # @param source_file_path [String, nil] Optional source file path, defaults to @source.
292
- def convert_pdf_to_png(source_file_path = nil)
293
- source_file_path ||= @source
294
- Utils.silent_execute(
295
- :magick,
296
- 'convert',
297
- '-size', "x#{@options.thumb_img_size}",
298
- '-background', 'white',
299
- '-flatten',
300
- "#{source_file_path}[0]",
301
- @destination
302
- )
303
- end
304
-
305
- # Converts image to PNG thumbnail.
306
- # Applies auto-orientation, resizing, and optimization.
307
- def convert_image_to_png
308
- Utils.silent_execute(
309
- :magick,
310
- 'convert',
311
- '-auto-orient',
312
- '-thumbnail', "#{@options.thumb_img_size}x#{@options.thumb_img_size}>",
313
- '-quality', 95,
314
- '+dither',
315
- '-posterize', 40,
316
- "#{@source}[0]",
317
- @destination
318
- )
319
- Utils.silent_execute(:optipng, @destination)
320
- end
321
-
322
- # Converts plain text to PNG image.
323
- # Renders first 100 lines of text file as an image.
324
- def convert_plaintext_to_png
325
- # Get 100 first lines of text file.
326
- first_lines = File.foreach(@source).first(100).join
327
- Utils.silent_execute(
328
- :magick,
329
- 'convert',
330
- '-size', "#{@options.thumb_img_size}x#{@options.thumb_img_size}",
331
- 'xc:white', # Define canvas with background color (xc, or canvas) of preceding size.
332
- '-font', @options.thumb_text_font,
333
- '-pointsize', 12,
334
- '-fill', 'black', # Font color.
335
- '-annotate', '+0+0', first_lines,
336
- '-trim', # Avoid large blank regions.
337
- '-bordercolor', 'white',
338
- '-border', 8,
339
- '+repage',
340
- @destination
341
- )
342
- end
343
- end
344
- end
345
- end
@@ -1,211 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: IBM Corp.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- require_relative '../log'
7
- require_relative '../assert'
8
- require 'English'
9
- require 'tmpdir'
10
- require 'fileutils'
11
- require 'open3'
12
-
13
- module Aspera
14
- module Preview
15
- class Utils
16
- # External binaries used
17
- EXTERNAL_TOOLS = %i[ffmpeg ffprobe magick optipng unoconv soffice].freeze
18
- # File name format for temporary files, used by both ffmpeg and ruby(Kernel.format)
19
- TEMP_FORMAT = 'img%04d.jpg'
20
- # default parameters for ffmpeg
21
- FFMPEG_DEFAULT_PARAMS = [
22
- '-y', # overwrite output without asking
23
- '-loglevel', 'error' # show only errors and up
24
- ].freeze
25
- # Preferred H.264 encoders in order: best quality/compatibility first.
26
- H264_ENCODER_PREFERENCE = %w[libx264 libopenh264 h264_nvenc h264_amf h264_qsv h264_vaapi h264_v4l2m2m].freeze
27
- private_constant :EXTERNAL_TOOLS, :TEMP_FORMAT, :FFMPEG_DEFAULT_PARAMS, :H264_ENCODER_PREFERENCE
28
-
29
- class << self
30
- # @param tool [Symbol] either `unoconv` or `soffice`
31
- attr_accessor :office_tool
32
-
33
- # Return the first H.264 encoder available in the local ffmpeg installation.
34
- # Result is memoized after the first call.
35
- # @return [String] encoder name (e.g. 'libx264', 'libopenh264')
36
- # @raise [RuntimeError] if no supported H.264 encoder is found
37
- def available_h264_encoder
38
- return @available_h264_encoder if defined?(@available_h264_encoder)
39
- stdout, = execute(:ffmpeg, '-encoders', mode: :capture, exception: false)
40
- available = stdout.lines.grep(/h264/i).map { |l| l.split[1] }
41
- @available_h264_encoder = H264_ENCODER_PREFERENCE.find { |enc| available.include?(enc) }
42
- Aspera.assert(@available_h264_encoder) { "No supported H.264 encoder found in ffmpeg. Available: #{available.join(', ')}" }
43
- @available_h264_encoder
44
- end
45
-
46
- # Check that external tools can be executed.
47
- # @param skip_types [Array<Symbol>] list of tools to skip
48
- # @raise [RuntimeError] if a required tool binary is missing
49
- # @return [nil]
50
- def check_tools(skip_types = [])
51
- tools_to_check = EXTERNAL_TOOLS.dup
52
- tools_to_check.delete(:unoconv) if skip_types.include?(:office) || office_tool.eql?(:soffice)
53
- tools_to_check.delete(:soffice) if skip_types.include?(:office) || office_tool.eql?(:unoconv)
54
- # Check for binaries
55
- tools_to_check.each do |command_sym|
56
- silent_execute(command_sym, '-h')
57
- rescue Errno::ENOENT => e
58
- raise "missing #{command_sym} binary: #{e}"
59
- rescue
60
- nil
61
- end
62
- end
63
-
64
- # Execute external command, verify it is in the supported list.
65
- # @param args [Array] command name followed by CLI arguments
66
- # @param kwargs [Hash] execution options passed to {Environment.secure_execute}
67
- # @raise [Aspera::AssertError] if the command is not in {EXTERNAL_TOOLS}
68
- # @return [Array<String>] captured stdout and stderr lines depending on mode
69
- def execute(*args, **kwargs)
70
- Aspera.assert_values(args.first, EXTERNAL_TOOLS) { 'command' }
71
- Environment.secure_execute(*args, **kwargs)
72
- end
73
-
74
- # Execute external command, capturing and discarding output unless it fails.
75
- # On failure, the captured stderr is included in the raised exception message.
76
- # @param args [Array] command name followed by CLI arguments
77
- # @return [nil]
78
- def silent_execute(*args)
79
- execute(*args, mode: :capture)
80
- nil
81
- end
82
-
83
- # Execute `ffmpeg`, capturing output.
84
- # On failure, the ffmpeg stderr is logged at debug level and re-raised.
85
- # @param in [Array] input file path followed by input options
86
- # @param out [Array] output file path followed by output options
87
- # @param global [Array<String>] global options for ffmpeg
88
- # @return [nil]
89
- def ffmpeg(in:, out:, global: FFMPEG_DEFAULT_PARAMS)
90
- Aspera.assert_type(global, Array)
91
- # NOTE: cannot use just "in", as it is a reserved word in ruby
92
- in_args = binding.local_variable_get(:in).dup
93
- out_args = out.dup
94
- Aspera.assert_type(in_args, Array)
95
- Aspera.assert_type(out_args, Array)
96
- in_file = in_args.shift
97
- out_file = out_args.shift
98
- execute(:ffmpeg, *global, *in_args, '-i', in_file, *out_args, out_file, mode: :capture)
99
- nil
100
- end
101
-
102
- # Get duration of a video file using `ffprobe`.
103
- # @param input_file [String] path to video file
104
- # @return [Float] duration in seconds
105
- def video_get_duration(input_file)
106
- return execute(
107
- :ffprobe,
108
- '-loglevel', 'error',
109
- '-show_entries', 'format=duration',
110
- '-print_format', 'default=noprint_wrappers=1:nokey=1',
111
- input_file,
112
- mode: :capture
113
- ).first.to_f
114
- end
115
-
116
- # File output pattern for ffmpeg, including temp folder.
117
- # @param temp_folder [String] path to temp folder
118
- # @return [String] file path pattern
119
- def ffmpeg_fmt(temp_folder)
120
- return File.join(temp_folder, TEMP_FORMAT)
121
- end
122
-
123
- # Get numbered temporary file path.
124
- # @param temp_folder [String] path to temp folder
125
- # @param file_number [Integer] frame index
126
- # @return [String] file path
127
- def get_tmp_num_filepath(temp_folder, file_number)
128
- return File.join(temp_folder, format(TEMP_FORMAT, file_number))
129
- end
130
-
131
- # Duplicate a video frame by creating symlinks.
132
- # @param temp_folder [String] path to temp folder
133
- # @param index [Integer] frame index to duplicate
134
- # @param count [Integer] number of duplicate frames to create
135
- # @return [nil]
136
- def video_dupe_frame(temp_folder, index, count)
137
- input_file = get_tmp_num_filepath(temp_folder, index)
138
- 1.upto(count) do |i|
139
- FileUtils.ln_s(input_file, get_tmp_num_filepath(temp_folder, index + i))
140
- end
141
- nil
142
- end
143
-
144
- # Blend transition frames between two keyframes using ImageMagick.
145
- # @param temp_folder [String] path to temp folder
146
- # @param index_begin [Integer] starting frame index
147
- # @param index_end [Integer] ending frame index
148
- # @return [nil]
149
- def video_blend_frames(temp_folder, index_begin, index_end)
150
- img1 = get_tmp_num_filepath(temp_folder, index_begin)
151
- img2 = get_tmp_num_filepath(temp_folder, index_end)
152
- count = index_end - index_begin - 1
153
- 1.upto(count) do |i|
154
- percent = i * 100 / (count + 1)
155
- filename = get_tmp_num_filepath(temp_folder, index_begin + i)
156
- silent_execute(:magick, 'composite', '-blend', percent, img2, img1, filename)
157
- end
158
- nil
159
- end
160
-
161
- # Dump a frame from a video file
162
- # @param input_file [String] the input file path
163
- # @param offset_seconds [Integer] the offset in seconds
164
- # @param scale [String] the scale of the output frame
165
- # @param output_file [String] the output file path
166
- # @return [nil]
167
- def video_dump_frame(input_file, offset_seconds, scale, output_file)
168
- ffmpeg(
169
- in: [input_file, '-ss', offset_seconds],
170
- out: [output_file, '-frames:v', 1, '-filter:v', "scale='#{scale}'"]
171
- )
172
- end
173
-
174
- # Parse the output of `magick identify -list font` command
175
- # @param output [String] the output from `magick -list font`
176
- # @return [Hash] with keys :path and :fonts
177
- # :path [String] the path to the type.xml file
178
- # :fonts [Array<Hash>] array of font hashes with keys:
179
- # :name, :family, :style, :stretch, :weight, :metrics, :glyphs, :index
180
- def parse_magick_fonts(output)
181
- result = {path: nil, fonts: []}
182
- current_font = nil
183
- output.each_line do |line|
184
- line = line.strip
185
- # Parse the Path line
186
- if line.start_with?('Path:')
187
- result[:path] = line.sub(/^Path:\s*/, '')
188
- # Parse Font name
189
- elsif line.start_with?('Font:')
190
- # Save previous font if exists
191
- result[:fonts] << current_font if current_font
192
- # Start new font
193
- current_font = {name: line.sub(/^Font:\s*/, '')}
194
- # Parse font properties
195
- elsif current_font && line.include?(':')
196
- key, value = line.split(':', 2)
197
- key = key.strip.gsub(/\s+/, '_').to_sym
198
- value = value.strip
199
- # Convert numeric values
200
- value = value.to_i if key == :weight || key == :index
201
- current_font[key] = value
202
- end
203
- end
204
- # Don't forget the last font
205
- result[:fonts] << current_font if current_font
206
- result
207
- end
208
- end
209
- end
210
- end
211
- end