dcc 0.2.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 (336) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +16 -0
  5. data/.rubocop_todo.yml +10 -0
  6. data/CHANGELOG.adoc +54 -0
  7. data/CONTRIBUTING.adoc +64 -0
  8. data/Gemfile +25 -0
  9. data/LICENSE +21 -0
  10. data/README.adoc +69 -0
  11. data/Rakefile +13 -0
  12. data/dcc.gemspec +41 -0
  13. data/docs/cli-reference.adoc +67 -0
  14. data/docs/getting-started.adoc +117 -0
  15. data/docs/schema-versions.adoc +65 -0
  16. data/examples/build_minimal_dcc.rb +23 -0
  17. data/examples/convert_all_formats.rb +19 -0
  18. data/examples/parse_and_inspect.rb +19 -0
  19. data/examples/quantity_math_demo.rb +32 -0
  20. data/examples/validate_full.rb +27 -0
  21. data/exe/dcc +7 -0
  22. data/lib/dcc/base/administrative_data.rb +43 -0
  23. data/lib/dcc/base/byte_data.rb +36 -0
  24. data/lib/dcc/base/calibration_laboratory.rb +29 -0
  25. data/lib/dcc/base/comment.rb +23 -0
  26. data/lib/dcc/base/condition.rb +34 -0
  27. data/lib/dcc/base/contact.rb +38 -0
  28. data/lib/dcc/base/contact_not_strict.rb +38 -0
  29. data/lib/dcc/base/core_data.rb +44 -0
  30. data/lib/dcc/base/data.rb +42 -0
  31. data/lib/dcc/base/digital_calibration_certificate.rb +32 -0
  32. data/lib/dcc/base/equipment_class.rb +24 -0
  33. data/lib/dcc/base/formula.rb +33 -0
  34. data/lib/dcc/base/hash_type.rb +34 -0
  35. data/lib/dcc/base/identification.rb +27 -0
  36. data/lib/dcc/base/identifications.rb +27 -0
  37. data/lib/dcc/base/influence_condition.rb +16 -0
  38. data/lib/dcc/base/influence_condition_list.rb +40 -0
  39. data/lib/dcc/base/item.rb +38 -0
  40. data/lib/dcc/base/item_list.rb +38 -0
  41. data/lib/dcc/base/list.rb +44 -0
  42. data/lib/dcc/base/location.rb +36 -0
  43. data/lib/dcc/base/measurement_meta_data.rb +15 -0
  44. data/lib/dcc/base/measurement_meta_data_list.rb +27 -0
  45. data/lib/dcc/base/measurement_result.rb +41 -0
  46. data/lib/dcc/base/measurement_result_list.rb +28 -0
  47. data/lib/dcc/base/measuring_equipment.rb +41 -0
  48. data/lib/dcc/base/measuring_equipment_list.rb +38 -0
  49. data/lib/dcc/base/quantity.rb +61 -0
  50. data/lib/dcc/base/ref_type_definition.rb +36 -0
  51. data/lib/dcc/base/ref_type_definition_list.rb +21 -0
  52. data/lib/dcc/base/resp_person.rb +38 -0
  53. data/lib/dcc/base/resp_person_list.rb +27 -0
  54. data/lib/dcc/base/result.rb +31 -0
  55. data/lib/dcc/base/result_list.rb +27 -0
  56. data/lib/dcc/base/rich_content.rb +34 -0
  57. data/lib/dcc/base/software.rb +35 -0
  58. data/lib/dcc/base/software_list.rb +27 -0
  59. data/lib/dcc/base/statement.rb +50 -0
  60. data/lib/dcc/base/statement_list.rb +27 -0
  61. data/lib/dcc/base/string_with_lang.rb +24 -0
  62. data/lib/dcc/base/text.rb +33 -0
  63. data/lib/dcc/base/used_method.rb +31 -0
  64. data/lib/dcc/base/used_method_list.rb +27 -0
  65. data/lib/dcc/base/xml_blob.rb +20 -0
  66. data/lib/dcc/base.rb +58 -0
  67. data/lib/dcc/builder/dsl.rb +10 -0
  68. data/lib/dcc/builder/session.rb +170 -0
  69. data/lib/dcc/builder.rb +34 -0
  70. data/lib/dcc/cli/cli.rb +149 -0
  71. data/lib/dcc/cli/formatters.rb +77 -0
  72. data/lib/dcc/cli.rb +7 -0
  73. data/lib/dcc/common_elements.rb +20 -0
  74. data/lib/dcc/context_configuration.rb +167 -0
  75. data/lib/dcc/context_options.rb +47 -0
  76. data/lib/dcc/convert/csv.rb +129 -0
  77. data/lib/dcc/convert/html.rb +127 -0
  78. data/lib/dcc/convert/json.rb +62 -0
  79. data/lib/dcc/convert/result.rb +51 -0
  80. data/lib/dcc/convert/yaml.rb +21 -0
  81. data/lib/dcc/convert.rb +14 -0
  82. data/lib/dcc/diff/change.rb +21 -0
  83. data/lib/dcc/diff/result.rb +58 -0
  84. data/lib/dcc/diff.rb +83 -0
  85. data/lib/dcc/error.rb +54 -0
  86. data/lib/dcc/extract/file.rb +143 -0
  87. data/lib/dcc/extract/ring.rb +28 -0
  88. data/lib/dcc/extract.rb +9 -0
  89. data/lib/dcc/i18n/text_lookup.rb +67 -0
  90. data/lib/dcc/i18n.rb +12 -0
  91. data/lib/dcc/inspect/report.rb +139 -0
  92. data/lib/dcc/inspect.rb +9 -0
  93. data/lib/dcc/migrate.rb +41 -0
  94. data/lib/dcc/namespace/dcc.rb +30 -0
  95. data/lib/dcc/namespace/dsig.rb +15 -0
  96. data/lib/dcc/namespace/math_ml.rb +14 -0
  97. data/lib/dcc/namespace/qudt.rb +15 -0
  98. data/lib/dcc/namespace/si.rb +26 -0
  99. data/lib/dcc/namespace.rb +18 -0
  100. data/lib/dcc/plugin/registry.rb +45 -0
  101. data/lib/dcc/plugin.rb +42 -0
  102. data/lib/dcc/quantity_format/formatter.rb +90 -0
  103. data/lib/dcc/quantity_format.rb +10 -0
  104. data/lib/dcc/quantity_math/quantity.rb +46 -0
  105. data/lib/dcc/quantity_math/real.rb +116 -0
  106. data/lib/dcc/quantity_math.rb +14 -0
  107. data/lib/dcc/schema/resources/dcc/dsi/v1.0.1.xsd +415 -0
  108. data/lib/dcc/schema/resources/dcc/dsi/v1.3.0.xsd +814 -0
  109. data/lib/dcc/schema/resources/dcc/dsi/v1.3.1.xsd +814 -0
  110. data/lib/dcc/schema/resources/dcc/dsi/v2.0.0.xsd +869 -0
  111. data/lib/dcc/schema/resources/dcc/dsi/v2.1.0.xsd +1031 -0
  112. data/lib/dcc/schema/resources/dcc/dsi/v2.2.1.xsd +1574 -0
  113. data/lib/dcc/schema/resources/dcc/qudt/v2.2.1.xsd +44 -0
  114. data/lib/dcc/schema/resources/dcc/v2.1.0/dcc.xsd +650 -0
  115. data/lib/dcc/schema/resources/dcc/v2.1.1/dcc.xsd +669 -0
  116. data/lib/dcc/schema/resources/dcc/v2.2.0/dcc.xsd +730 -0
  117. data/lib/dcc/schema/resources/dcc/v2.3.0/dcc.xsd +708 -0
  118. data/lib/dcc/schema/resources/dcc/v2.4.0/dcc.xsd +725 -0
  119. data/lib/dcc/schema/resources/dcc/v3.0.0/dcc.xsd +749 -0
  120. data/lib/dcc/schema/resources/dcc/v3.1.0/dcc.xsd +843 -0
  121. data/lib/dcc/schema/resources/dcc/v3.1.1/dcc.xsd +843 -0
  122. data/lib/dcc/schema/resources/dcc/v3.1.2/dcc.xsd +844 -0
  123. data/lib/dcc/schema/resources/dcc/v3.2.0/dcc.xsd +940 -0
  124. data/lib/dcc/schema/resources/dcc/v3.2.1/dcc.xsd +963 -0
  125. data/lib/dcc/schema/resources/dcc/v3.3.0/dcc.xsd +1008 -0
  126. data/lib/dcc/schema/resources/dcc/xmldsig-core-schema.xsd +312 -0
  127. data/lib/dcc/schema/resources/dsi/qudt/v2.2.1.xsd +44 -0
  128. data/lib/dcc/schema/resources/dsi/v1.0.1/SI_Format.xsd +415 -0
  129. data/lib/dcc/schema/resources/dsi/v1.3.0/SI_Format.xsd +814 -0
  130. data/lib/dcc/schema/resources/dsi/v1.3.1/SI_Format.xsd +814 -0
  131. data/lib/dcc/schema/resources/dsi/v2.0.0/SI_Format.xsd +869 -0
  132. data/lib/dcc/schema/resources/dsi/v2.1.0/SI_Format.xsd +1031 -0
  133. data/lib/dcc/schema/resources/dsi/v2.2.1/SI_Format.xsd +1574 -0
  134. data/lib/dcc/schema/resources/qudt/qudt.xsd +44 -0
  135. data/lib/dcc/schema/resources/schematron/dcc.sch +523 -0
  136. data/lib/dcc/schema/resources/schematron/dcc.svrl +2302 -0
  137. data/lib/dcc/schema/resources/xmldsig/xmldsig-core-schema.xsd +312 -0
  138. data/lib/dcc/schema/version.rb +94 -0
  139. data/lib/dcc/schema.rb +35 -0
  140. data/lib/dcc/server/app.rb +133 -0
  141. data/lib/dcc/server/storage/entry.rb +15 -0
  142. data/lib/dcc/server/storage/memory.rb +57 -0
  143. data/lib/dcc/server/storage.rb +13 -0
  144. data/lib/dcc/server.rb +33 -0
  145. data/lib/dcc/si/base/complex.rb +43 -0
  146. data/lib/dcc/si/base/complex_list_xml_list.rb +39 -0
  147. data/lib/dcc/si/base/constant.rb +39 -0
  148. data/lib/dcc/si/base/coverage_interval_mu.rb +31 -0
  149. data/lib/dcc/si/base/expanded_mu.rb +29 -0
  150. data/lib/dcc/si/base/expanded_unc_xml_list.rb +30 -0
  151. data/lib/dcc/si/base/hybrid.rb +42 -0
  152. data/lib/dcc/si/base/measurement_uncertainty_univariate.rb +28 -0
  153. data/lib/dcc/si/base/real.rb +48 -0
  154. data/lib/dcc/si/base/real_list_xml_list.rb +45 -0
  155. data/lib/dcc/si/base/si_list.rb +37 -0
  156. data/lib/dcc/si/base/standard_mu.rb +25 -0
  157. data/lib/dcc/si/base.rb +24 -0
  158. data/lib/dcc/si/common_elements.rb +13 -0
  159. data/lib/dcc/si/namespace.rb +7 -0
  160. data/lib/dcc/si/v1/common_elements.rb +13 -0
  161. data/lib/dcc/si/v1/complex.rb +8 -0
  162. data/lib/dcc/si/v1/complex_list_xml_list.rb +8 -0
  163. data/lib/dcc/si/v1/configuration.rb +13 -0
  164. data/lib/dcc/si/v1/constant.rb +8 -0
  165. data/lib/dcc/si/v1/coverage_interval_mu.rb +8 -0
  166. data/lib/dcc/si/v1/expanded_mu.rb +8 -0
  167. data/lib/dcc/si/v1/expanded_unc.rb +23 -0
  168. data/lib/dcc/si/v1/expanded_unc_xml_list.rb +8 -0
  169. data/lib/dcc/si/v1/hybrid.rb +8 -0
  170. data/lib/dcc/si/v1/measurement_uncertainty_univariate.rb +8 -0
  171. data/lib/dcc/si/v1/namespace.rb +9 -0
  172. data/lib/dcc/si/v1/real.rb +8 -0
  173. data/lib/dcc/si/v1/real_list_xml_list.rb +8 -0
  174. data/lib/dcc/si/v1/si_list.rb +8 -0
  175. data/lib/dcc/si/v1/standard_mu.rb +8 -0
  176. data/lib/dcc/si/v1.rb +46 -0
  177. data/lib/dcc/si/v2/common_elements.rb +13 -0
  178. data/lib/dcc/si/v2/complex.rb +8 -0
  179. data/lib/dcc/si/v2/complex_list_xml_list.rb +8 -0
  180. data/lib/dcc/si/v2/configuration.rb +13 -0
  181. data/lib/dcc/si/v2/constant.rb +8 -0
  182. data/lib/dcc/si/v2/coverage_interval_mu.rb +8 -0
  183. data/lib/dcc/si/v2/coverage_interval_mu_xml_list.rb +24 -0
  184. data/lib/dcc/si/v2/expanded_mu.rb +8 -0
  185. data/lib/dcc/si/v2/expanded_mu_xml_list.rb +22 -0
  186. data/lib/dcc/si/v2/expanded_unc_xml_list.rb +8 -0
  187. data/lib/dcc/si/v2/hybrid.rb +8 -0
  188. data/lib/dcc/si/v2/measurement_uncertainty_univariate.rb +8 -0
  189. data/lib/dcc/si/v2/namespace.rb +9 -0
  190. data/lib/dcc/si/v2/real.rb +8 -0
  191. data/lib/dcc/si/v2/real_list_xml_list.rb +8 -0
  192. data/lib/dcc/si/v2/si_list.rb +8 -0
  193. data/lib/dcc/si/v2/standard_mu.rb +8 -0
  194. data/lib/dcc/si/v2/standard_mu_xml_list.rb +18 -0
  195. data/lib/dcc/si/v2.rb +49 -0
  196. data/lib/dcc/si.rb +34 -0
  197. data/lib/dcc/signature/result.rb +43 -0
  198. data/lib/dcc/signature/signer.rb +36 -0
  199. data/lib/dcc/signature/verifier.rb +41 -0
  200. data/lib/dcc/signature.rb +13 -0
  201. data/lib/dcc/transform/result.rb +24 -0
  202. data/lib/dcc/transform/xslt.rb +72 -0
  203. data/lib/dcc/transform.rb +12 -0
  204. data/lib/dcc/type/base64_binary.rb +55 -0
  205. data/lib/dcc/type/decimal_xml_list.rb +47 -0
  206. data/lib/dcc/type/iso_country_code.rb +23 -0
  207. data/lib/dcc/type/iso_language_code.rb +23 -0
  208. data/lib/dcc/type/schema_version.rb +37 -0
  209. data/lib/dcc/type/si_unit.rb +26 -0
  210. data/lib/dcc/type.rb +16 -0
  211. data/lib/dcc/type_guards.rb +140 -0
  212. data/lib/dcc/v2/administrative_data.rb +8 -0
  213. data/lib/dcc/v2/byte_data.rb +8 -0
  214. data/lib/dcc/v2/calibration_laboratory.rb +8 -0
  215. data/lib/dcc/v2/comment.rb +8 -0
  216. data/lib/dcc/v2/common_elements.rb +13 -0
  217. data/lib/dcc/v2/condition.rb +8 -0
  218. data/lib/dcc/v2/configuration.rb +17 -0
  219. data/lib/dcc/v2/contact.rb +8 -0
  220. data/lib/dcc/v2/contact_not_strict.rb +8 -0
  221. data/lib/dcc/v2/core_data.rb +8 -0
  222. data/lib/dcc/v2/data.rb +8 -0
  223. data/lib/dcc/v2/digital_calibration_certificate.rb +8 -0
  224. data/lib/dcc/v2/equipment_class.rb +8 -0
  225. data/lib/dcc/v2/formula.rb +8 -0
  226. data/lib/dcc/v2/hash_type.rb +8 -0
  227. data/lib/dcc/v2/identification.rb +8 -0
  228. data/lib/dcc/v2/identifications.rb +8 -0
  229. data/lib/dcc/v2/influence_condition.rb +7 -0
  230. data/lib/dcc/v2/influence_condition_list.rb +8 -0
  231. data/lib/dcc/v2/item.rb +8 -0
  232. data/lib/dcc/v2/item_list.rb +8 -0
  233. data/lib/dcc/v2/list.rb +8 -0
  234. data/lib/dcc/v2/location.rb +8 -0
  235. data/lib/dcc/v2/measurement_meta_data.rb +8 -0
  236. data/lib/dcc/v2/measurement_meta_data_list.rb +8 -0
  237. data/lib/dcc/v2/measurement_result.rb +8 -0
  238. data/lib/dcc/v2/measurement_result_list.rb +8 -0
  239. data/lib/dcc/v2/measuring_equipment.rb +8 -0
  240. data/lib/dcc/v2/measuring_equipment_list.rb +8 -0
  241. data/lib/dcc/v2/namespace.rb +8 -0
  242. data/lib/dcc/v2/quantity.rb +49 -0
  243. data/lib/dcc/v2/ref_type_definition.rb +11 -0
  244. data/lib/dcc/v2/ref_type_definition_list.rb +15 -0
  245. data/lib/dcc/v2/resp_person.rb +8 -0
  246. data/lib/dcc/v2/resp_person_list.rb +8 -0
  247. data/lib/dcc/v2/result.rb +8 -0
  248. data/lib/dcc/v2/result_list.rb +8 -0
  249. data/lib/dcc/v2/rich_content.rb +12 -0
  250. data/lib/dcc/v2/software.rb +8 -0
  251. data/lib/dcc/v2/software_list.rb +8 -0
  252. data/lib/dcc/v2/statement.rb +8 -0
  253. data/lib/dcc/v2/statement_list.rb +8 -0
  254. data/lib/dcc/v2/string_with_lang.rb +8 -0
  255. data/lib/dcc/v2/text.rb +8 -0
  256. data/lib/dcc/v2/used_method.rb +8 -0
  257. data/lib/dcc/v2/used_method_list.rb +8 -0
  258. data/lib/dcc/v2/xml_blob.rb +8 -0
  259. data/lib/dcc/v2.rb +84 -0
  260. data/lib/dcc/v3/administrative_data.rb +8 -0
  261. data/lib/dcc/v3/byte_data.rb +8 -0
  262. data/lib/dcc/v3/calibration_laboratory.rb +8 -0
  263. data/lib/dcc/v3/comment.rb +8 -0
  264. data/lib/dcc/v3/common_elements.rb +11 -0
  265. data/lib/dcc/v3/condition.rb +8 -0
  266. data/lib/dcc/v3/configuration.rb +17 -0
  267. data/lib/dcc/v3/contact.rb +8 -0
  268. data/lib/dcc/v3/contact_not_strict.rb +8 -0
  269. data/lib/dcc/v3/core_data.rb +8 -0
  270. data/lib/dcc/v3/data.rb +8 -0
  271. data/lib/dcc/v3/digital_calibration_certificate.rb +8 -0
  272. data/lib/dcc/v3/equipment_class.rb +8 -0
  273. data/lib/dcc/v3/formula.rb +8 -0
  274. data/lib/dcc/v3/hash_type.rb +8 -0
  275. data/lib/dcc/v3/identification.rb +8 -0
  276. data/lib/dcc/v3/identifications.rb +8 -0
  277. data/lib/dcc/v3/influence_condition.rb +7 -0
  278. data/lib/dcc/v3/influence_condition_list.rb +8 -0
  279. data/lib/dcc/v3/item.rb +8 -0
  280. data/lib/dcc/v3/item_list.rb +8 -0
  281. data/lib/dcc/v3/list.rb +8 -0
  282. data/lib/dcc/v3/location.rb +8 -0
  283. data/lib/dcc/v3/measurement_meta_data.rb +8 -0
  284. data/lib/dcc/v3/measurement_meta_data_list.rb +8 -0
  285. data/lib/dcc/v3/measurement_result.rb +8 -0
  286. data/lib/dcc/v3/measurement_result_list.rb +8 -0
  287. data/lib/dcc/v3/measuring_equipment.rb +8 -0
  288. data/lib/dcc/v3/measuring_equipment_list.rb +8 -0
  289. data/lib/dcc/v3/namespace.rb +7 -0
  290. data/lib/dcc/v3/quantity.rb +49 -0
  291. data/lib/dcc/v3/ref_type_definition.rb +8 -0
  292. data/lib/dcc/v3/ref_type_definition_list.rb +8 -0
  293. data/lib/dcc/v3/resp_person.rb +8 -0
  294. data/lib/dcc/v3/resp_person_list.rb +8 -0
  295. data/lib/dcc/v3/result.rb +8 -0
  296. data/lib/dcc/v3/result_list.rb +8 -0
  297. data/lib/dcc/v3/rich_content.rb +8 -0
  298. data/lib/dcc/v3/software.rb +8 -0
  299. data/lib/dcc/v3/software_list.rb +8 -0
  300. data/lib/dcc/v3/statement.rb +8 -0
  301. data/lib/dcc/v3/statement_list.rb +8 -0
  302. data/lib/dcc/v3/string_with_lang.rb +8 -0
  303. data/lib/dcc/v3/text.rb +8 -0
  304. data/lib/dcc/v3/used_method.rb +8 -0
  305. data/lib/dcc/v3/used_method_list.rb +8 -0
  306. data/lib/dcc/v3/xml_blob.rb +8 -0
  307. data/lib/dcc/v3.rb +111 -0
  308. data/lib/dcc/validate/business_rules.rb +121 -0
  309. data/lib/dcc/validate/issue.rb +56 -0
  310. data/lib/dcc/validate/result.rb +105 -0
  311. data/lib/dcc/validate/schematron/profile.rb +64 -0
  312. data/lib/dcc/validate/schematron/rule.rb +49 -0
  313. data/lib/dcc/validate/schematron/rules/administrative_data_completeness.rb +42 -0
  314. data/lib/dcc/validate/schematron/rules/base.rb +15 -0
  315. data/lib/dcc/validate/schematron/rules/date_range_check.rb +41 -0
  316. data/lib/dcc/validate/schematron/rules/id_refid_linking.rb +61 -0
  317. data/lib/dcc/validate/schematron/rules/influence_conditions_placement.rb +58 -0
  318. data/lib/dcc/validate/schematron/rules/iso_code_validation.rb +53 -0
  319. data/lib/dcc/validate/schematron/rules/language_code_dedup.rb +39 -0
  320. data/lib/dcc/validate/schematron/rules/non_si_declaration.rb +82 -0
  321. data/lib/dcc/validate/schematron/rules/release_format_check.rb +44 -0
  322. data/lib/dcc/validate/schematron/rules/schema_version_check.rb +31 -0
  323. data/lib/dcc/validate/schematron/rules/uncertainty_consistency.rb +58 -0
  324. data/lib/dcc/validate/schematron/rules/unit_format_check.rb +74 -0
  325. data/lib/dcc/validate/schematron/rules/used_methods_placement.rb +65 -0
  326. data/lib/dcc/validate/schematron/rules/used_software_placement.rb +43 -0
  327. data/lib/dcc/validate/schematron/rules/xml_list_spacing.rb +42 -0
  328. data/lib/dcc/validate/schematron/rules.rb +30 -0
  329. data/lib/dcc/validate/schematron.rb +22 -0
  330. data/lib/dcc/validate/severity.rb +39 -0
  331. data/lib/dcc/validate/xsd.rb +97 -0
  332. data/lib/dcc/validate.rb +15 -0
  333. data/lib/dcc/version.rb +5 -0
  334. data/lib/dcc/versioned_parser.rb +48 -0
  335. data/lib/dcc.rb +141 -0
  336. metadata +425 -0
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Demonstrate BigDecimal-based quantity math with uncertainty propagation.
5
+ #
6
+ # Usage:
7
+ # bundle exec examples/quantity_math_demo.rb
8
+
9
+ require "dcc"
10
+ require "bigdecimal"
11
+
12
+ ten_k = Dcc::QuantityMath::Real.new(value: BigDecimal("10"),
13
+ unit: "\\kelvin",
14
+ uncertainty: BigDecimal("0.1"))
15
+ twenty_k = Dcc::QuantityMath::Real.new(value: BigDecimal("20"),
16
+ unit: "\\kelvin",
17
+ uncertainty: BigDecimal("0.2"))
18
+
19
+ puts "ten: #{ten_k}"
20
+ puts "twenty: #{twenty_k}"
21
+ puts "sum: #{ten_k + twenty_k}"
22
+ puts "product: #{ten_k * twenty_k}"
23
+ puts "ratio: #{twenty_k / ten_k}"
24
+
25
+ # Pretty-print with SmartCom-style formats.
26
+ fmt = Dcc::QuantityFormat::Formatter.new(value: BigDecimal("42.00"),
27
+ uncertainty: BigDecimal("0.05"),
28
+ unit: "\\kelvin")
29
+ puts
30
+ puts "Short: #{fmt.to_short}"
31
+ puts "Long: #{fmt.to_long}"
32
+ puts "LaTeX: #{fmt.to_latex}"
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Validate a DCC against XSD, Schematron, and business rules in one shot.
5
+ #
6
+ # Usage:
7
+ # bundle exec examples/validate_full.rb path/to/dcc.xml
8
+
9
+ require "dcc"
10
+
11
+ path = ARGV[0] || File.expand_path("../spec/fixtures/dcclib/valid.xml", __dir__)
12
+ xml = File.read(path)
13
+
14
+ dcc = Dcc.parse(xml)
15
+
16
+ [Dcc::Validate::Xsd,
17
+ Dcc::Validate::Schematron,
18
+ Dcc::Validate::BusinessRules].each do |service|
19
+ result =
20
+ case service.name
21
+ when "Dcc::Validate::Xsd" then service.call(xml)
22
+ else service.call(dcc)
23
+ end
24
+ puts "== #{service.name} =="
25
+ puts result.to_s
26
+ puts
27
+ end
data/exe/dcc ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "dcc"
5
+ require "dcc/cli/cli"
6
+
7
+ Dcc::Cli::Cli.start(ARGV)
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:administrativeDataType` — top-level admin section. Uses `xs:all`
6
+ # ordering (children may appear in any order) so we keep the explicit
7
+ # `ordered` for serialization determinism.
8
+ module AdministrativeData
9
+ def self.included(klass)
10
+ klass.class_eval do
11
+ attribute :id, :string
12
+ attribute :ref_id, :string
13
+ attribute :ref_type, :string
14
+ attribute :dcc_software, :softwareList
15
+ attribute :ref_type_definitions, :refTypeDefinitions
16
+ attribute :core_data, :coreData
17
+ attribute :items, :items
18
+ attribute :calibration_laboratory, :calibrationLaboratory
19
+ attribute :resp_persons, :respPersons
20
+ attribute :customer, :contact
21
+ attribute :statements, :statements
22
+
23
+ xml do
24
+ namespace ::Dcc::Namespace::Dcc
25
+ element "administrativeData"
26
+ ordered
27
+ map_attribute "id", to: :id
28
+ map_attribute "refId", to: :ref_id
29
+ map_attribute "refType", to: :ref_type
30
+ map_element "dccSoftware", to: :dcc_software
31
+ map_element "refTypeDefinitions", to: :ref_type_definitions
32
+ map_element "coreData", to: :core_data
33
+ map_element "items", to: :items
34
+ map_element "calibrationLaboratory", to: :calibration_laboratory
35
+ map_element "respPersons", to: :resp_persons
36
+ map_element "customer", to: :customer
37
+ map_element "statements", to: :statements
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:byteDataType` — embedded binary file with name/description/filename/
6
+ # mime-type/base64 data.
7
+ module ByteData
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :id, :string
11
+ attribute :ref_id, :string
12
+ attribute :ref_type, :string
13
+ attribute :name, :text
14
+ attribute :description, :text
15
+ attribute :file_name, :string
16
+ attribute :mime_type, :string
17
+ attribute :data_base64, ::Dcc::Type::Base64Binary
18
+
19
+ xml do
20
+ namespace ::Dcc::Namespace::Dcc
21
+ element "byteData"
22
+ ordered
23
+ map_attribute "id", to: :id
24
+ map_attribute "refId", to: :ref_id
25
+ map_attribute "refType", to: :ref_type
26
+ map_element "name", to: :name
27
+ map_element "description", to: :description
28
+ map_element "fileName", to: :file_name
29
+ map_element "mimeType", to: :mime_type
30
+ map_element "dataBase64", to: :data_base64
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:calibrationLaboratoryType` — lab code plus contact info.
6
+ module CalibrationLaboratory
7
+ def self.included(klass)
8
+ klass.class_eval do
9
+ attribute :id, :string
10
+ attribute :ref_id, :string
11
+ attribute :ref_type, :string
12
+ attribute :calibration_laboratory_code, :string
13
+ attribute :contact, :contact, collection: true
14
+
15
+ xml do
16
+ namespace ::Dcc::Namespace::Dcc
17
+ element "calibrationLaboratory"
18
+ ordered
19
+ map_attribute "id", to: :id
20
+ map_attribute "refId", to: :ref_id
21
+ map_attribute "refType", to: :ref_type
22
+ map_element "calibrationLaboratoryCode", to: :calibration_laboratory_code
23
+ map_element "contact", to: :contact
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:comment` — wildcard (`xs:any namespace="##any"`) wrapper around
6
+ # arbitrary XML. The contents are preserved as a raw XML string; lutaml-model
7
+ # requires `map_all` to be the only mapping in a class, so the comment
8
+ # element lives in its own class referenced by `DigitalCalibrationCertificate`.
9
+ module Comment
10
+ def self.included(klass)
11
+ klass.class_eval do
12
+ attribute :raw, :string
13
+
14
+ xml do
15
+ namespace ::Dcc::Namespace::Dcc
16
+ element "comment"
17
+ map_all to: :raw
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:conditionType` — single influence condition: name + description +
6
+ # optional state enum (beforeAdjustment, etc.) + data.
7
+ module Condition
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :id, :string
11
+ attribute :ref_id, :string
12
+ attribute :ref_type, :string
13
+ attribute :name, :text
14
+ attribute :description, :text
15
+ attribute :status, :string
16
+ attribute :data, :data, collection: true
17
+
18
+ xml do
19
+ namespace ::Dcc::Namespace::Dcc
20
+ element "influenceCondition"
21
+ ordered
22
+ map_attribute "id", to: :id
23
+ map_attribute "refId", to: :ref_id
24
+ map_attribute "refType", to: :ref_type
25
+ map_element "name", to: :name
26
+ map_element "description", to: :description
27
+ map_element "state", to: :status
28
+ map_element "data", to: :data
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:contactType` — strict contact (location required). Used for
6
+ # calibrationLaboratory and customer.
7
+ module Contact
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :id, :string
11
+ attribute :ref_id, :string
12
+ attribute :ref_type, :string
13
+ attribute :name, :text
14
+ attribute :e_mail, :string
15
+ attribute :phone, :string
16
+ attribute :fax, :string
17
+ attribute :location, :location
18
+ attribute :description_data, :text
19
+
20
+ xml do
21
+ namespace ::Dcc::Namespace::Dcc
22
+ element "contact"
23
+ ordered
24
+ map_attribute "id", to: :id
25
+ map_attribute "refId", to: :ref_id
26
+ map_attribute "refType", to: :ref_type
27
+ map_element "name", to: :name
28
+ map_element "eMail", to: :e_mail
29
+ map_element "phone", to: :phone
30
+ map_element "fax", to: :fax
31
+ map_element "location", to: :location
32
+ map_element "descriptionData", to: :description_data
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:contactNotStrictType` — loose contact (location optional). Used for
6
+ # manufacturers and owners.
7
+ module ContactNotStrict
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :id, :string
11
+ attribute :ref_id, :string
12
+ attribute :ref_type, :string
13
+ attribute :name, :text
14
+ attribute :e_mail, :string
15
+ attribute :phone, :string
16
+ attribute :fax, :string
17
+ attribute :location, :location
18
+ attribute :description_data, :text
19
+
20
+ xml do
21
+ namespace ::Dcc::Namespace::Dcc
22
+ element "contactNotStrict"
23
+ ordered
24
+ map_attribute "id", to: :id
25
+ map_attribute "refId", to: :ref_id
26
+ map_attribute "refType", to: :ref_type
27
+ map_element "name", to: :name
28
+ map_element "eMail", to: :e_mail
29
+ map_element "phone", to: :phone
30
+ map_element "fax", to: :fax
31
+ map_element "location", to: :location
32
+ map_element "descriptionData", to: :description_data
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:coreDataType` — core administrative metadata: country, languages,
6
+ # unique identifier, dates, previous report, identifications.
7
+ module CoreData
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :id, :string
11
+ attribute :ref_id, :string
12
+ attribute :ref_type, :string
13
+ attribute :country_code_iso_3166_1, ::Dcc::Type::IsoCountryCode
14
+ attribute :used_lang_code_iso_639_1, ::Dcc::Type::IsoLanguageCode, collection: true
15
+ attribute :mandatory_lang_code_iso_639_1, ::Dcc::Type::IsoLanguageCode, collection: true
16
+ attribute :unique_identifier, :string
17
+ attribute :identifications, :identifications
18
+ attribute :receipt_date, :date
19
+ attribute :begin_performance_date, :date
20
+ attribute :end_performance_date, :date
21
+ attribute :previous_report, :previousReport
22
+
23
+ xml do
24
+ namespace ::Dcc::Namespace::Dcc
25
+ element "coreData"
26
+ ordered
27
+ map_attribute "id", to: :id
28
+ map_attribute "refId", to: :ref_id
29
+ map_attribute "refType", to: :ref_type
30
+ map_element "countryCodeISO3166_1", to: :country_code_iso_3166_1
31
+ map_element "usedLangCodeISO639_1", to: :used_lang_code_iso_639_1
32
+ map_element "mandatoryLangCodeISO639_1", to: :mandatory_lang_code_iso_639_1
33
+ map_element "uniqueIdentifier", to: :unique_identifier
34
+ map_element "identifications", to: :identifications
35
+ map_element "receiptDate", to: :receipt_date
36
+ map_element "beginPerformanceDate", to: :begin_performance_date
37
+ map_element "endPerformanceDate", to: :end_performance_date
38
+ map_element "previousReport", to: :previous_report
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:dataType` — the central xs:choice container. May hold any of:
6
+ # `text`, `formula`, `byteData`, `xml`, `quantity`, `list`. The XSD allows
7
+ # `maxOccurs="unbounded"` so any of the alternatives may repeat.
8
+ #
9
+ # We model each branch as a collection attribute; the version wrapper
10
+ # resolves `quantity` to the version-appropriate D-SI-aware type.
11
+ module Data
12
+ def self.included(klass)
13
+ klass.class_eval do
14
+ attribute :id, :string
15
+ attribute :ref_id, :string
16
+ attribute :ref_type, :string
17
+ attribute :text, :text, collection: true
18
+ attribute :formula, :formula, collection: true
19
+ attribute :byte_data, :byteData, collection: true
20
+ attribute :xml, :xml, collection: true
21
+ attribute :quantity, :quantity, collection: true
22
+ attribute :list, :list, collection: true
23
+
24
+ xml do
25
+ namespace ::Dcc::Namespace::Dcc
26
+ element "data"
27
+ ordered
28
+ map_attribute "id", to: :id
29
+ map_attribute "refId", to: :ref_id
30
+ map_attribute "refType", to: :ref_type
31
+ map_element "text", to: :text
32
+ map_element "formula", to: :formula
33
+ map_element "byteData", to: :byte_data
34
+ map_element "xml", to: :xml
35
+ map_element "quantity", to: :quantity
36
+ map_element "list", to: :list
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:digitalCalibrationCertificateType` — the root element of every DCC
6
+ # document. Carries `schemaVersion` attribute plus four "rings":
7
+ # administrativeData, measurementResults, optional comment, optional
8
+ # document. From v3.4 also optional `ds:Signature` collection.
9
+ module DigitalCalibrationCertificate
10
+ def self.included(klass)
11
+ klass.class_eval do
12
+ attribute :schema_version, ::Dcc::Type::SchemaVersion
13
+ attribute :administrative_data, :administrativeData
14
+ attribute :measurement_results, :measurementResults
15
+ attribute :comment, :comment
16
+ attribute :document, :byteData
17
+
18
+ xml do
19
+ namespace ::Dcc::Namespace::Dcc
20
+ element "digitalCalibrationCertificate"
21
+ ordered
22
+ map_attribute "schemaVersion", to: :schema_version
23
+ map_element "administrativeData", to: :administrative_data
24
+ map_element "measurementResults", to: :measurement_results
25
+ map_element "comment", to: :comment
26
+ map_element "document", to: :document
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:equipmentClassType` — classification reference for measuring
6
+ # equipment. Carries a reference (URI) and a classID.
7
+ module EquipmentClass
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :reference, :string
11
+ attribute :class_id, :string
12
+
13
+ xml do
14
+ namespace ::Dcc::Namespace::Dcc
15
+ element "equipmentClass"
16
+ ordered
17
+ map_element "reference", to: :reference
18
+ map_element "classID", to: :class_id
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mml"
4
+
5
+ module Dcc
6
+ module Base
7
+ # `dcc:formulaType` — formula expression. Contains `latex` string,
8
+ # `mathml` (a typed `Mml::V3::Math` model), or legacy `siunitx`.
9
+ module Formula
10
+ def self.included(klass)
11
+ klass.class_eval do
12
+ attribute :id, :string
13
+ attribute :ref_id, :string
14
+ attribute :ref_type, :string
15
+ attribute :latex, :string
16
+ attribute :mathml, ::Mml::V3::Math
17
+ attribute :siunitx, :string
18
+
19
+ xml do
20
+ namespace ::Dcc::Namespace::Dcc
21
+ element "formula"
22
+ map_attribute "id", to: :id
23
+ map_attribute "refId", to: :ref_id
24
+ map_attribute "refType", to: :ref_type
25
+ map_element "latex", to: :latex
26
+ map_element "mathml", to: :mathml
27
+ map_element "siunitx", to: :siunitx
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:hashType` — reference to a previous report. Used by `previousReport`
6
+ # in `coreData`.
7
+ module HashType
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :referral, :string
11
+ attribute :referral_id, :string
12
+ attribute :procedure, :string
13
+ attribute :value, :string
14
+ attribute :description, :text
15
+ attribute :traceable, :boolean
16
+ attribute :in_validity_range, :boolean
17
+
18
+ xml do
19
+ namespace ::Dcc::Namespace::Dcc
20
+ element "previousReport"
21
+ ordered
22
+ map_element "referral", to: :referral
23
+ map_element "referralID", to: :referral_id
24
+ map_element "procedure", to: :procedure
25
+ map_element "value", to: :value
26
+ map_element "description", to: :description
27
+ map_element "traceable", to: :traceable
28
+ map_element "inValidityRange", to: :in_validity_range
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:identificationType` — single identifier (issuer, value, optional
6
+ # description). Issuer enum: manufacturer, calibrationLaboratory, customer,
7
+ # owner, other.
8
+ module Identification
9
+ def self.included(klass)
10
+ klass.class_eval do
11
+ attribute :issuer, :string
12
+ attribute :value, :string
13
+ attribute :description, :text
14
+
15
+ xml do
16
+ namespace ::Dcc::Namespace::Dcc
17
+ element "identification"
18
+ ordered
19
+ map_element "issuer", to: :issuer
20
+ map_element "value", to: :value
21
+ map_element "description", to: :description
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:identificationListType` — collection of identifications.
6
+ module Identifications
7
+ def self.included(klass)
8
+ klass.class_eval do
9
+ attribute :id, :string
10
+ attribute :ref_id, :string
11
+ attribute :ref_type, :string
12
+ attribute :identification, :identification, collection: true
13
+
14
+ xml do
15
+ namespace ::Dcc::Namespace::Dcc
16
+ element "identifications"
17
+ ordered
18
+ map_attribute "id", to: :id
19
+ map_attribute "refId", to: :ref_id
20
+ map_attribute "refType", to: :ref_type
21
+ map_element "identification", to: :identification
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # Alias: an individual `dcc:influenceCondition` element IS a Condition.
6
+ # The XSD uses `conditionType` for the inner element. We expose both names
7
+ # for readability at the call site.
8
+ module InfluenceCondition
9
+ def self.included(klass)
10
+ klass.class_eval do
11
+ include ::Dcc::Base::Condition
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dcc
4
+ module Base
5
+ # `dcc:influenceConditionListType` — collection of `dcc:influenceCondition`
6
+ # plus shared name/description/methods/software/equipment.
7
+ module InfluenceConditionList
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ attribute :id, :string
11
+ attribute :ref_id, :string
12
+ attribute :ref_type, :string
13
+ attribute :name, :text
14
+ attribute :description, :text
15
+ attribute :used_methods, :usedMethods
16
+ attribute :used_software, :softwareList
17
+ attribute :measuring_equipments, :measuringEquipments
18
+ attribute :influence_condition, :influenceCondition, collection: true
19
+ attribute :data, :data, collection: true
20
+
21
+ xml do
22
+ namespace ::Dcc::Namespace::Dcc
23
+ element "influenceConditions"
24
+ ordered
25
+ map_attribute "id", to: :id
26
+ map_attribute "refId", to: :ref_id
27
+ map_attribute "refType", to: :ref_type
28
+ map_element "name", to: :name
29
+ map_element "description", to: :description
30
+ map_element "usedMethods", to: :used_methods
31
+ map_element "usedSoftware", to: :used_software
32
+ map_element "measuringEquipments", to: :measuring_equipments
33
+ map_element "influenceCondition", to: :influence_condition
34
+ map_element "data", to: :data
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end