xmp_toolkit_ruby 0.0.2

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 (183) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.gitignore +8 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +88 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/AGENTS.md +72 -0
  8. data/CHANGELOG.md +45 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +287 -0
  11. data/Rakefile +25 -0
  12. data/cliff.toml +138 -0
  13. data/docker/Dockerfile +87 -0
  14. data/docker/ProductConfig.cmake.patch +11 -0
  15. data/docker/ToolchainGCC.cmake.patch +11 -0
  16. data/exe/xmp_toolkit_ruby +8 -0
  17. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/LICENSE +31 -0
  18. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/build/XMP_BuildInfo.h +17 -0
  19. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/TXMPFiles.hpp +853 -0
  20. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/TXMPIterator.hpp +234 -0
  21. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/TXMPMeta.hpp +1753 -0
  22. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/TXMPUtils.hpp +967 -0
  23. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMP.hpp +98 -0
  24. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMP.incl_cpp +69 -0
  25. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/BaseInterfaces/IConfigurable.h +225 -0
  26. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/BaseInterfaces/ISharedObject.h +71 -0
  27. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/BaseInterfaces/IThreadSafe.h +76 -0
  28. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/BaseInterfaces/IVersionable.h +71 -0
  29. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/IConfigurationManager.h +167 -0
  30. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/IError.h +377 -0
  31. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/IErrorNotifier.h +52 -0
  32. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/IMemoryAllocator.h +65 -0
  33. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/IObjectFactory.h +90 -0
  34. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Interfaces/IUTF8String.h +504 -0
  35. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Utilities/TWrapperFunctions.h +252 -0
  36. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/Utilities/TWrapperFunctions2.h +564 -0
  37. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/XMPCommonDefines.h +194 -0
  38. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/XMPCommonErrorCodes.h +114 -0
  39. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/XMPCommonFwdDeclarations.h +158 -0
  40. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/XMPCommonLatestInterfaceVersions.h +51 -0
  41. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/source/IConfigurable.cpp +204 -0
  42. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/source/IConfigurationManager.cpp +92 -0
  43. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/source/IError.cpp +207 -0
  44. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/source/IErrorNotifier.cpp +26 -0
  45. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCommon/source/IUTF8String.cpp +299 -0
  46. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IArrayNode.h +303 -0
  47. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IClientDOMParser.h +88 -0
  48. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IClientDOMSerializer.h +94 -0
  49. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/ICompositeNode.h +331 -0
  50. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/ICoreConfigurationManager.h +107 -0
  51. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/ICoreObjectFactory.h +279 -0
  52. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IDOMImplementationRegistry.h +150 -0
  53. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IDOMParser.h +181 -0
  54. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IDOMSerializer.h +120 -0
  55. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IMetadata.h +145 -0
  56. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IMetadataConverterUtils.h +116 -0
  57. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/INameSpacePrefixMap.h +236 -0
  58. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/INode.h +582 -0
  59. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/INodeIterator.h +193 -0
  60. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IPath.h +212 -0
  61. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IPathSegment.h +225 -0
  62. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/ISimpleNode.h +150 -0
  63. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/Interfaces/IStructureNode.h +306 -0
  64. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/XMPCoreDefines.h +94 -0
  65. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/XMPCoreErrorCodes.h +116 -0
  66. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/XMPCoreFwdDeclarations.h +325 -0
  67. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/XMPCoreLatestInterfaceVersions.h +97 -0
  68. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IArrayNode.cpp +163 -0
  69. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IClientDOMParser.cpp +76 -0
  70. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IClientDOMSerializer.cpp +73 -0
  71. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/ICompositeNode.cpp +121 -0
  72. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/ICoreConfigurationManager.cpp +88 -0
  73. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/ICoreObjectFactory.cpp +83 -0
  74. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IDOMImplementationRegistry.cpp +122 -0
  75. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IDOMParser.cpp +116 -0
  76. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IDOMSerializer.cpp +109 -0
  77. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IMetadata.cpp +113 -0
  78. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IMetadataConverterUtils.cpp +92 -0
  79. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/INameSpacePrefixMap.cpp +187 -0
  80. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/INode.cpp +377 -0
  81. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/INodeIterator.cpp +105 -0
  82. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IPath.cpp +157 -0
  83. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IPathSegment.cpp +146 -0
  84. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/ISimpleNode.cpp +111 -0
  85. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMPCore/source/IStructureNode.cpp +104 -0
  86. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMP_Const.h +1590 -0
  87. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMP_Environment.h +223 -0
  88. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMP_IO.hpp +169 -0
  89. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/XMP_Version.h +52 -0
  90. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/TXMPFiles.incl_cpp +484 -0
  91. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/TXMPIterator.incl_cpp +223 -0
  92. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/TXMPMeta.incl_cpp +917 -0
  93. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/TXMPUtils.incl_cpp +445 -0
  94. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/WXMPFiles.hpp +281 -0
  95. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/WXMPIterator.hpp +74 -0
  96. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/WXMPMeta.hpp +635 -0
  97. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/WXMPUtils.hpp +314 -0
  98. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/include/client-glue/WXMP_Common.hpp +132 -0
  99. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/libraries/i80386linux_x64/debug/libXMPCore.so +0 -0
  100. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/libraries/i80386linux_x64/debug/libXMPCoreStatic.a +0 -0
  101. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/libraries/i80386linux_x64/debug/libXMPFiles.so +0 -0
  102. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/libraries/i80386linux_x64/debug/libXMPFilesStatic.a +0 -0
  103. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/libraries/macintosh/universal/Debug/libXMPCoreStatic.a +0 -0
  104. data/ext/xmp_toolkit_ruby/XMP-Toolkit-SDK/public/libraries/macintosh/universal/Debug/libXMPFilesStatic.a +0 -0
  105. data/ext/xmp_toolkit_ruby/extconf.rb +101 -0
  106. data/ext/xmp_toolkit_ruby/xmp_toolkit.cpp +321 -0
  107. data/ext/xmp_toolkit_ruby/xmp_toolkit.hpp +69 -0
  108. data/ext/xmp_toolkit_ruby/xmp_toolkit_ruby.cpp +44 -0
  109. data/lib/xmp_toolkit_ruby/cli.rb +95 -0
  110. data/lib/xmp_toolkit_ruby/namespaces.rb +77 -0
  111. data/lib/xmp_toolkit_ruby/plugins/LICENSE +31 -0
  112. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux/PDF_Handler.resources/MODULE_IDENTIFIER.txt +1 -0
  113. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux/PDF_Handler.resources/XMPPLUGINUIDS.txt +31 -0
  114. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux/PDF_Handler.xpi +0 -0
  115. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux/libMiniPDFL.so +0 -0
  116. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux_x64/PDF_Handler.resources/MODULE_IDENTIFIER.txt +1 -0
  117. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux_x64/PDF_Handler.resources/XMPPLUGINUIDS.txt +31 -0
  118. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux_x64/PDF_Handler.xpi +0 -0
  119. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux_x64/libMiniPDFL.so +0 -0
  120. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/PDF_Handler +0 -0
  121. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/Info.plist +52 -0
  122. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MODULE_IDENTIFIER.txt +1 -0
  123. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/MiniPDFL +0 -0
  124. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Resources/English.lproj/InfoPlist.strings +0 -0
  125. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Resources/Info.plist +35 -0
  126. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/A/MiniPDFL +0 -0
  127. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/A/Resources/English.lproj/InfoPlist.strings +0 -0
  128. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/A/Resources/Info.plist +35 -0
  129. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/A/_CodeSignature/CodeResources +146 -0
  130. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/Current/MiniPDFL +0 -0
  131. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/Current/Resources/English.lproj/InfoPlist.strings +0 -0
  132. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/Current/Resources/Info.plist +35 -0
  133. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/MiniPDFL.framework/Versions/Current/_CodeSignature/CodeResources +146 -0
  134. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Resources/XMPPLUGINUIDS.txt +31 -0
  135. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/PDF_Handler +0 -0
  136. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/Info.plist +52 -0
  137. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MODULE_IDENTIFIER.txt +1 -0
  138. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/MiniPDFL +0 -0
  139. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Resources/English.lproj/InfoPlist.strings +0 -0
  140. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Resources/Info.plist +35 -0
  141. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/A/MiniPDFL +0 -0
  142. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/A/Resources/English.lproj/InfoPlist.strings +0 -0
  143. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/A/Resources/Info.plist +35 -0
  144. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/A/_CodeSignature/CodeResources +146 -0
  145. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/Current/MiniPDFL +0 -0
  146. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/Current/Resources/English.lproj/InfoPlist.strings +0 -0
  147. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/Current/Resources/Info.plist +35 -0
  148. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/MiniPDFL.framework/Versions/Current/_CodeSignature/CodeResources +146 -0
  149. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/Resources/XMPPLUGINUIDS.txt +31 -0
  150. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/A/_CodeSignature/CodeResources +216 -0
  151. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/PDF_Handler +0 -0
  152. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/Info.plist +52 -0
  153. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MODULE_IDENTIFIER.txt +1 -0
  154. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/MiniPDFL +0 -0
  155. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Resources/English.lproj/InfoPlist.strings +0 -0
  156. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Resources/Info.plist +35 -0
  157. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/A/MiniPDFL +0 -0
  158. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/A/Resources/English.lproj/InfoPlist.strings +0 -0
  159. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/A/Resources/Info.plist +35 -0
  160. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/A/_CodeSignature/CodeResources +146 -0
  161. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/Current/MiniPDFL +0 -0
  162. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/Current/Resources/English.lproj/InfoPlist.strings +0 -0
  163. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/Current/Resources/Info.plist +35 -0
  164. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/MiniPDFL.framework/Versions/Current/_CodeSignature/CodeResources +146 -0
  165. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/Resources/XMPPLUGINUIDS.txt +31 -0
  166. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/PDF_Handler.xpi/Versions/Current/_CodeSignature/CodeResources +216 -0
  167. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/linux/PDF_Handler.exp +11 -0
  168. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/mac/PDF_Handler.exp +2 -0
  169. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/mac/PDF_Handler.plist +28 -0
  170. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/mac/PDF_HandlerPList.h +12 -0
  171. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/win/CopyPDFL.bat +14 -0
  172. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/win/PDF_Handler-32.rc +8 -0
  173. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/win/PDF_Handler-64.rc +8 -0
  174. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/resource/win/PDF_Handler.def +9 -0
  175. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/windows/windows_x64/MiniPDFL.dll +0 -0
  176. data/lib/xmp_toolkit_ruby/plugins/PDF_Handler/windows/windows_x64/PDF_Handler.xpi +0 -0
  177. data/lib/xmp_toolkit_ruby/version.rb +5 -0
  178. data/lib/xmp_toolkit_ruby/xmp_file_format.rb +87 -0
  179. data/lib/xmp_toolkit_ruby/xmp_file_handler_flags.rb +49 -0
  180. data/lib/xmp_toolkit_ruby.rb +237 -0
  181. data/sig/xmp_toolkit_ruby.rbs +4 -0
  182. data/tasks/changelog.rake +29 -0
  183. metadata +357 -0
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleExecutable</key>
6
+ <string>PDF_Handler</string>
7
+ <key>CFBundleIdentifier</key>
8
+ <string>com.xmp.PDF_Handler</string>
9
+ <key>CFBundleName</key>
10
+ <string>PDF_Handler</string>
11
+ <key>CFBundleGetInfoString</key>
12
+ <string>PDF Handler kBasicVersion, kXMP_Copyright</string>
13
+ <key>CFBundleShortVersionString</key>
14
+ <string>PDF Handler kBasicVersion</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleSignature</key>
18
+ <string>XMP </string>
19
+ <key>Configuration</key>
20
+ <string>kConfig</string>
21
+ <key>FileVersion</key>
22
+ <string>kBasicVersion</string>
23
+ <key>ProductName</key>
24
+ <string>PDF Handler</string>
25
+ <key>ProductVersion</key>
26
+ <string>PDF_HANDLER_VERSION</string>
27
+ </dict>
28
+ </plist>
@@ -0,0 +1,12 @@
1
+ #include "../../../../build/XMP_BuildInfo.h"
2
+ #define PDF_HANDLER_VERSION 1.0
3
+ #if NDEBUG // Can't use XMP_Environment.h, it seems to mess up the PList compiler.
4
+ #define kConfig Release
5
+ #define kDebugSuffix
6
+ #define kBasicVersion PDF_HANDLER_VERSION
7
+ #else
8
+ #define kConfig Debug
9
+ #define kDebugSuffix (debug)
10
+ #define kBasicVersion PDF_HANDLER_VERSION kDebugSuffix
11
+ #endif
12
+
@@ -0,0 +1,14 @@
1
+ @ECHO OFF
2
+ @rem Copy the needed PDFL to the public folder.
3
+ @rem Usage: CopyPDFL <mode> <platform>
4
+ @rem <mode> is debug or release
5
+ @rem <platform> is windows or windows_x64. defaults to "windows" (32-bit)
6
+
7
+ set workingDir=%~dp0%
8
+ set mode=%1
9
+ if "%1" == "" set mode=release
10
+ set platform=%2
11
+ if "%2" == "" set platform=windows
12
+
13
+ mkdir %workingDir%\..\..\..\public\%platform%\%mode%\PDF_Handler
14
+ xcopy /y /r %workingDir%\..\..\third-party\MiniPDFL\libraries\%platform%\release\MiniPDFL.dll %workingDir%\..\..\..\public\%platform%\%mode%\PDF_Handler
@@ -0,0 +1,8 @@
1
+
2
+ /////////////////////////////////////////////////////////////////////////////
3
+ //
4
+ // TXT
5
+ //
6
+
7
+ XMPPLUGINUIDS TXT "../../../resource/txt/XMPPLUGINUIDS-32.txt"
8
+ MODULE_IDENTIFIER TXT "../../../resource/txt/MODULE_IDENTIFIER.txt"
@@ -0,0 +1,8 @@
1
+
2
+ /////////////////////////////////////////////////////////////////////////////
3
+ //
4
+ // TXT
5
+ //
6
+
7
+ XMPPLUGINUIDS TXT "../../../resource/txt/XMPPLUGINUIDS-64.txt"
8
+ MODULE_IDENTIFIER TXT "../../../resource/txt/MODULE_IDENTIFIER.txt"
@@ -0,0 +1,9 @@
1
+ ; Declares the entry points for the DLL.
2
+ ; Highest index: 2 - InitializePlugin2
3
+
4
+ LIBRARY PDF_Handler
5
+
6
+ EXPORTS
7
+
8
+ InitializePlugin @1
9
+ InitializePlugin2 @2
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XmpToolkitRuby
4
+ VERSION = "0.0.2"
5
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XmpToolkitRuby
4
+ module XmpFileFormat
5
+ # Mapping from constant name (as a Symbol) to its 32‐bit hexadecimal value
6
+ FORMATS = {
7
+ # Public file formats
8
+ kXMP_PDFFile: 0x50444620,
9
+ kXMP_PostScriptFile: 0x50532020,
10
+ kXMP_EPSFile: 0x45505320,
11
+ kXMP_JPEGFile: 0x4A504547,
12
+ kXMP_JPEG2KFile: 0x4A505820,
13
+ kXMP_TIFFFile: 0x54494646,
14
+ kXMP_GIFFile: 0x47494620,
15
+ kXMP_PNGFile: 0x504E4720,
16
+ kXMP_SWFFile: 0x53574620,
17
+ kXMP_FLAFile: 0x464C4120,
18
+ kXMP_FLVFile: 0x464C5620,
19
+ kXMP_MOVFile: 0x4D4F5620,
20
+ kXMP_AVIFile: 0x41564920,
21
+ kXMP_CINFile: 0x43494E20,
22
+ kXMP_WAVFile: 0x57415620,
23
+ kXMP_MP3File: 0x4D503320,
24
+ kXMP_SESFile: 0x53455320,
25
+ kXMP_CELFile: 0x43454C20,
26
+ kXMP_MPEGFile: 0x4D504547,
27
+ kXMP_MPEG2File: 0x4D503220,
28
+ kXMP_MPEG4File: 0x4D503420,
29
+ kXMP_MXFFile: 0x4D584620,
30
+ kXMP_WMAVFile: 0x574D4156,
31
+ kXMP_AIFFFile: 0x41494646,
32
+ kXMP_REDFile: 0x52454420,
33
+ kXMP_ARRIFile: 0x41525249,
34
+ kXMP_HEIFFile: 0x48454946,
35
+ kXMP_P2File: 0x50322020,
36
+ kXMP_XDCAM_FAMFile: 0x58444346,
37
+ kXMP_XDCAM_SAMFile: 0x58444353,
38
+ kXMP_XDCAM_EXFile: 0x58444358,
39
+ kXMP_AVCHDFile: 0x41564844,
40
+ kXMP_SonyHDVFile: 0x53484456,
41
+ kXMP_CanonXFFile: 0x434E5846,
42
+ kXMP_AVCUltraFile: 0x41564355,
43
+ kXMP_HTMLFile: 0x48544D4C,
44
+ kXMP_XMLFile: 0x584D4C20,
45
+ kXMP_TextFile: 0x74657874,
46
+ kXMP_SVGFile: 0x53564720,
47
+
48
+ # Adobe application file formats
49
+ kXMP_PhotoshopFile: 0x50534420,
50
+ kXMP_IllustratorFile: 0x41492020,
51
+ kXMP_InDesignFile: 0x494E4444,
52
+ kXMP_AEProjectFile: 0x41455020,
53
+ kXMP_AEProjTemplateFile: 0x41455420,
54
+ kXMP_AEFilterPresetFile: 0x46465820,
55
+ kXMP_EncoreProjectFile: 0x4E434F52,
56
+ kXMP_PremiereProjectFile: 0x5052504A,
57
+ kXMP_PremiereTitleFile: 0x5052544C,
58
+ kXMP_UCFFile: 0x55434620,
59
+
60
+ # Others
61
+ kXMP_UnknownFile: 0x20202020
62
+ }.freeze
63
+
64
+ # Inverted mapping from hex value to constant name (Symbol)
65
+ FORMATS_BY_VALUE = FORMATS.invert.freeze
66
+
67
+ class << self
68
+ # Retrieve the hex value for a given constant name (Symbol or String).
69
+ #
70
+ # Example:
71
+ # XMPFileFormat.value_for(:kXMP_JPEGFile) # => 0x4A504547
72
+ # XMPFileFormat.value_for("kXMP_PNGFile") # => 0x504E4720
73
+ def value_for(name)
74
+ key = name.is_a?(String) ? name.to_sym : name
75
+ FORMATS[key]
76
+ end
77
+
78
+ # Retrieve the constant name (Symbol) for a given hex value (Integer).
79
+ #
80
+ # Example:
81
+ # XMPFileFormat.name_for(0x4D4F5620) # => :kXMP_MOVFile
82
+ def name_for(hex_value)
83
+ FORMATS_BY_VALUE[hex_value]
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XmpToolkitRuby
4
+ module XmpFileHandlerFlags
5
+ # The keys here are Ruby-style snake_case equivalents of the handler flag constants
6
+ # defined in Adobe's XMP Toolkit SDK (see XMP_Const.h, e.g. kXMPFiles_CanInjectXMP, etc).
7
+ # For details on what each flag means, refer to the SDK's C++ header documentation.
8
+ FLAGS = {
9
+ can_inject_xmp: 0x0000_0001, # kXMPFiles_CanInjectXMP
10
+ can_expand: 0x0000_0002, # kXMPFiles_CanExpand
11
+ can_rewrite: 0x0000_0004, # kXMPFiles_CanRewrite
12
+ prefers_in_place: 0x0000_0008, # kXMPFiles_PrefersInPlace
13
+ can_reconcile: 0x0000_0010, # kXMPFiles_CanReconcile
14
+ allows_only_xmp: 0x0000_0020, # kXMPFiles_AllowsOnlyXMP
15
+ returns_raw_packet: 0x0000_0040, # kXMPFiles_ReturnsRawPacket
16
+ handler_owns_file: 0x0000_0100, # kXMPFiles_HandlerOwnsFile
17
+ allows_safe_update: 0x0000_0200, # kXMPFiles_AllowsSafeUpdate
18
+ needs_read_only_packet: 0x0000_0400, # kXMPFiles_NeedsReadOnlyPacket
19
+ uses_sidecar_xmp: 0x0000_0800, # kXMPFiles_UsesSidecarXMP
20
+ folder_based_format: 0x0000_1000, # kXMPFiles_FolderBasedFormat
21
+ can_notify_progress: 0x0000_2000, # kXMPFiles_CanNotifyProgress
22
+ needs_preloading: 0x0000_4000, # kXMPFiles_NeedsPreloading
23
+ needs_local_file_opened: 0x0001_0000 # kXMPFiles_NeedsLocalFileOpened
24
+ }.freeze
25
+
26
+ FLAGS_BY_VALUE = FLAGS.invert.freeze
27
+
28
+ class << self
29
+ # Retrieve the hex value for a given flag name (Symbol or String).
30
+ # Example: XmpFileHandlerFlags.value_for(:can_inject_xmp) #=> 0x00000001
31
+ def value_for(name)
32
+ key = name.is_a?(String) ? name.to_sym : name
33
+ FLAGS[key]
34
+ end
35
+
36
+ # Retrieve the flag name (Symbol) for a given hex value (Integer).
37
+ # Example: XmpFileHandlerFlags.name_for(0x00000008) #=> :prefers_in_place
38
+ def name_for(hex_value)
39
+ FLAGS_BY_VALUE[hex_value]
40
+ end
41
+
42
+ # Given a bitmask, return an array of all flag names that are set.
43
+ # Example: XmpFileHandlerFlags.flags_for(0x00000005) #=> [:can_inject_xmp, :can_rewrite]
44
+ def flags_for(bitmask)
45
+ FLAGS.select { |_, bit| bitmask.anybits?(bit) }.keys
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,237 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "xmp_toolkit_ruby/version"
4
+ require_relative "xmp_toolkit_ruby/xmp_toolkit_ruby"
5
+
6
+ require "nokogiri"
7
+ require "rbconfig"
8
+
9
+ # The `XmpToolkitRuby` module serves as a Ruby interface to Adobe's XMP Toolkit,
10
+ # a native C++ library. This module allows Ruby applications to read and write
11
+ # XMP (Extensible Metadata Platform) metadata from and to various file formats.
12
+ #
13
+ # It handles the initialization and termination of the underlying C++ toolkit,
14
+ # manages paths to necessary plugins (like PDF handlers), processes and cleans
15
+ # XMP XML data, and provides a user-friendly API for XMP operations.
16
+ #
17
+ # Key functionalities include:
18
+ # * Reading XMP metadata from files.
19
+ # * Writing XMP metadata to files, with options to override or update existing data.
20
+ # * Automatic management of the XMP Toolkit's lifecycle.
21
+ # * Platform-aware resolution of plugin paths, with environment variable override.
22
+ # * Parsing and cleaning of XMP packet data.
23
+ # * Mapping of numerical handler flags to descriptive representations.
24
+ #
25
+ # @example Reading XMP from a file
26
+ # metadata = XmpToolkitRuby.xmp_from_file("path/to/image.jpg")
27
+ # puts metadata["xmp_data"] # Access the cleaned XMP XML string
28
+ #
29
+ # @example Writing XMP to a file
30
+ # new_xmp_data = "<x:xmpmeta xmlns:x='adobe:ns:meta/'><rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'></rdf:RDF></x:xmpmeta>"
31
+ # XmpToolkitRuby.xmp_to_file("path/to/image.jpg", new_xmp_data, override: true)
32
+ #
33
+ module XmpToolkitRuby
34
+ require_relative "xmp_toolkit_ruby/xmp_file_format"
35
+ require_relative "xmp_toolkit_ruby/namespaces"
36
+ require_relative "xmp_toolkit_ruby/xmp_file_handler_flags"
37
+
38
+ # The `PLUGINS_PATH` constant defines the directory where the XMP Toolkit
39
+ # should look for its plugins, particularly the PDF handler.
40
+ # The path is determined based on the current operating system (macOS or Linux)
41
+ # and system architecture.
42
+ #
43
+ # This path can be overridden by setting the `XMP_TOOLKIT_PLUGINS_PATH`
44
+ # environment variable, which takes precedence if set and not empty.
45
+ #
46
+ # If the platform or architecture is unsupported, a warning will be issued,
47
+ # and the path may be empty, potentially affecting PDF handling capabilities.
48
+ #
49
+ # @return [String] The absolute path to the plugins directory.
50
+ PLUGINS_PATH = if ENV["XMP_TOOLKIT_PLUGINS_PATH"] && !ENV["XMP_TOOLKIT_PLUGINS_PATH"].empty?
51
+ ENV["XMP_TOOLKIT_PLUGINS_PATH"]
52
+ else
53
+ case RUBY_PLATFORM
54
+ when /darwin/ # macOS
55
+ File.expand_path("./xmp_toolkit_ruby/plugins/PDF_Handler/macintosh/universal/", __dir__)
56
+ when /linux/
57
+ if RbConfig::CONFIG["host_cpu"] =~ /x86_64|amd64/
58
+ File.expand_path("./xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux_x64/", __dir__)
59
+ elsif RbConfig::CONFIG["host_cpu"] =~ /i[3-6]86/ # Matches i386, i486, i586, i686
60
+ File.expand_path("./xmp_toolkit_ruby/plugins/PDF_Handler/i80386linux/i80386linux/", __dir__)
61
+ else
62
+ warn "Unsupported Linux architecture for PLUGINS_PATH: #{RbConfig::CONFIG["host_cpu"]}. PDF Handler might not work."
63
+ "" # Or some other default
64
+ end
65
+ else
66
+ # Fallback or error for unsupported platforms
67
+ warn "Unsupported platform for PLUGINS_PATH: #{RUBY_PLATFORM}. PDF Handler might not work."
68
+ "" # Or some other default that makes sense for your application
69
+ end
70
+ end
71
+
72
+ class Error < StandardError; end
73
+
74
+ class FileNotFoundError < Error; end
75
+
76
+ class << self
77
+ # Reads XMP metadata from a specified file.
78
+ #
79
+ # This method first checks if the file exists and is readable. It then
80
+ # initializes the XMP Toolkit, reads the XMP data using the native extension,
81
+ # cleans up the extracted XML, maps handler flags to a descriptive format,
82
+ # and ensures the toolkit is terminated.
83
+ #
84
+ # @param file_path [String] The absolute or relative path to the target file.
85
+ # @return [Hash] A hash containing the XMP metadata.
86
+ # The hash includes:
87
+ # - `"begin"`: The value of the `begin` attribute from the `xpacket` processing instruction.
88
+ # - `"packet_id"`: The value of the `id` attribute from the `xpacket` processing instruction.
89
+ # - `"xmp_data"`: The cleaned XMP XML string (core XMP metadata).
90
+ # - `"xmp_data_orig"`: The original, raw XMP data string as returned by the toolkit.
91
+ # - `"handler_flags"`: A descriptive representation of the handler flags (e.g., from {XmpFileHandlerFlags}).
92
+ # - `"handler_flags_orig"`: The original numerical handler flags from the toolkit.
93
+ # Returns an empty hash merged with cleanup and flag mapping results if the native call returns nil.
94
+ # @raise [FileNotFoundError] If the file does not exist, is not readable, or `file_path` is nil.
95
+ def xmp_from_file(file_path)
96
+ check_file! file_path, need_to_read: true, need_to_write: false
97
+
98
+ with_init do
99
+ result = XmpToolkitRuby::XmpToolkit.read_xmp(file_path)
100
+ result ||= {}
101
+ result.merge(cleanup_xmp(result["xmp_data"])).merge(map_handler_flags(result["handler_flags"]))
102
+ end
103
+ end
104
+
105
+ # Writes XMP metadata to a specified file.
106
+ #
107
+ # This method checks if the file exists, is readable, and is writable.
108
+ # It then initializes the XMP Toolkit, writes the provided XMP data
109
+ # (either as a Hash or an XML String) to the file using the native extension,
110
+ # and ensures the toolkit is terminated.
111
+ #
112
+ # The `override` parameter controls how existing XMP data in the file is handled:
113
+ # - If `true` (`:override`), existing XMP metadata is completely replaced.
114
+ # - If `false` (`:upsert`), the new XMP data is merged with existing metadata;
115
+ # new properties are added, and existing ones may be updated.
116
+ #
117
+ # @param file_path [String] The absolute or relative path to the target file.
118
+ # @param xmp_data [String] The XMP metadata to write.
119
+ # (which will be converted to XML by the native toolkit) or a pre-formatted XML String.
120
+ # @param override [Boolean] (false) If `true`, existing XMP metadata in the
121
+ # file will be replaced. If `false`, the new data will be upserted (merged).
122
+ # @raise [FileNotFoundError] If the file does not exist, is not readable/writable, or `file_path` is nil.
123
+ def xmp_to_file(file_path, xmp_data, override: false)
124
+ check_file! file_path, need_to_read: true, need_to_write: true
125
+
126
+ with_init { XmpToolkitRuby::XmpToolkit.write_xmp(file_path, xmp_data, override ? :override : :upsert) }
127
+ end
128
+
129
+ # Ensures the native XMP Toolkit is initialized before executing a block
130
+ # of code and terminated afterwards. This is crucial for managing the
131
+ # lifecycle of the underlying C++ library resources.
132
+ #
133
+ # This method should wrap any calls to the native `XmpToolkitRuby::XmpToolkit` methods.
134
+ #
135
+ # @yield The block of code to execute while the XMP Toolkit is initialized.
136
+ # @return The result of the yielded block.
137
+ def with_init(&block)
138
+ XmpToolkitRuby::XmpToolkit.initialize_xmp
139
+ block.call
140
+ ensure
141
+ XmpToolkitRuby::XmpToolkit.terminate
142
+ end
143
+
144
+ private
145
+
146
+ # Parses raw XMP data string to extract `xpacket` processing instruction
147
+ # attributes and the core XMP XML content.
148
+ #
149
+ # The `xpacket` processing instruction contains metadata about the XMP packet itself.
150
+ # This method isolates these attributes and provides the main XMP XML structure
151
+ # without these processing instructions.
152
+ #
153
+ # @param xmp_data [String, nil] The raw XMP data string, which may include
154
+ # `<?xpacket ...?>` processing instructions.
155
+ # @return [Hash] A hash containing extracted information:
156
+ # - `"begin"`: The value of the `begin` attribute from the `xpacket` PI.
157
+ # - `"packet_id"`: The value of the `id` attribute from the `xpacket` PI.
158
+ # - `"xmp_data"`: The XMP XML content as a string, with `xpacket` PIs removed.
159
+ # - `"xmp_data_orig"`: The original, unmodified `xmp_data` string.
160
+ # Returns an empty hash if `xmp_data` is nil or empty.
161
+ # @api private
162
+ # rubocop: disable Metrics/AbcSize
163
+ def cleanup_xmp(xmp_data)
164
+ return {} if xmp_data.nil? || xmp_data.empty?
165
+
166
+ doc = Nokogiri::XML(xmp_data)
167
+ pis = doc.xpath("//processing-instruction('xpacket')")
168
+
169
+ begin_pi = pis.find { |pi| pi.content =~ /\Abegin=/ }
170
+
171
+ begin_attrs = begin_pi.content.scan(/(\w+)="([^"]*)"/).to_h
172
+ begin_value = begin_attrs["begin"]
173
+ packet_id = begin_attrs["id"]
174
+
175
+ pis.remove
176
+ inner_xml = doc.root.to_xml
177
+
178
+ {
179
+ "begin" => begin_value,
180
+ "packet_id" => packet_id,
181
+ "xmp_data" => inner_xml,
182
+ "xmp_data_orig" => xmp_data
183
+ }
184
+ end
185
+
186
+ # Maps numerical handler flags from the XMP Toolkit to a more descriptive
187
+ # format, typically an Array of Symbols or Strings.
188
+ #
189
+ # This uses `XmpToolkitRuby::XmpFileHandlerFlags.flags_for` to perform the mapping.
190
+ #
191
+ # @param handler_flags [Integer, nil] The numerical handler flags returned by
192
+ # the native XMP Toolkit.
193
+ # @return [Hash] A hash containing:
194
+ # - `"handler_flags"`: The mapped, descriptive representation of the flags.
195
+ # - `"handler_flags_orig"`: The original numerical `handler_flags`.
196
+ # Returns an empty hash if `handler_flags` is nil.
197
+ # @api private
198
+ def map_handler_flags(handler_flags)
199
+ return {} if handler_flags.nil?
200
+
201
+ handler_flags_mapped = XmpToolkitRuby::XmpFileHandlerFlags.flags_for(handler_flags)
202
+
203
+ {
204
+ "handler_flags" => handler_flags_mapped,
205
+ "handler_flags_orig" => handler_flags
206
+ }
207
+ end
208
+
209
+ # rubocop: enable Metrics/AbcSize, Metrics/MethodLength
210
+
211
+ # Validates file accessibility before performing read or write operations.
212
+ #
213
+ # Checks for:
214
+ # - Nil file path.
215
+ # - File existence.
216
+ # - File readability (if `need_to_read` is true).
217
+ # - File writability (if `need_to_write` is true).
218
+ #
219
+ # @param file_path [String] The path to the file to check.
220
+ # @param need_to_read [Boolean] (true) Whether the file needs to be readable.
221
+ # @param need_to_write [Boolean] (false) Whether the file needs to be writable.
222
+ # @raise [FileNotFoundError] If any of the checks fail.
223
+ # @return [void]
224
+ # @api private
225
+ def check_file!(file_path, need_to_read: true, need_to_write: false)
226
+ if file_path.nil?
227
+ raise FileNotFoundError, "File path cannot be nil"
228
+ elsif !File.exist?(file_path)
229
+ raise FileNotFoundError, "File not found: #{file_path}"
230
+ elsif need_to_read && !File.readable?(file_path)
231
+ raise FileNotFoundError, "File exists but is not readable: #{file_path}"
232
+ elsif need_to_write && !File.writable?(file_path)
233
+ raise FileNotFoundError, "File exists but is not writable: #{file_path}"
234
+ end
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,4 @@
1
+ module XmpToolkitRuby
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ def cliff_installed?
4
+ system("which git-cliff > /dev/null 2>&1")
5
+ end
6
+
7
+ namespace :changelog do
8
+ desc "Generate unreleased section in CHANGELOG.md (requires git-cliff)"
9
+ task :update_unreleased do
10
+ unless cliff_installed?
11
+ puts "🚫 git-cliff is not installed!"
12
+ puts "👉 Install it here: https://git-cliff.org/docs/installation/"
13
+ exit 1
14
+ end
15
+
16
+ generated = `git cliff --unreleased`
17
+
18
+ changelog_path = "CHANGELOG.md"
19
+ changelog = File.read(changelog_path)
20
+
21
+ updated = changelog.sub(
22
+ /<!--.*generated\s+by\s+git-cliff\s+start\s+-->(.*?)<!--\s+generated\s+by\s+git-cliff\s+end\s+-->/m,
23
+ generated.strip
24
+ )
25
+
26
+ File.write(changelog_path, updated)
27
+ puts "✅ Replaced generated section in CHANGELOG.md"
28
+ end
29
+ end