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.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/.rubocop_todo.yml +10 -0
- data/CHANGELOG.adoc +54 -0
- data/CONTRIBUTING.adoc +64 -0
- data/Gemfile +25 -0
- data/LICENSE +21 -0
- data/README.adoc +69 -0
- data/Rakefile +13 -0
- data/dcc.gemspec +41 -0
- data/docs/cli-reference.adoc +67 -0
- data/docs/getting-started.adoc +117 -0
- data/docs/schema-versions.adoc +65 -0
- data/examples/build_minimal_dcc.rb +23 -0
- data/examples/convert_all_formats.rb +19 -0
- data/examples/parse_and_inspect.rb +19 -0
- data/examples/quantity_math_demo.rb +32 -0
- data/examples/validate_full.rb +27 -0
- data/exe/dcc +7 -0
- data/lib/dcc/base/administrative_data.rb +43 -0
- data/lib/dcc/base/byte_data.rb +36 -0
- data/lib/dcc/base/calibration_laboratory.rb +29 -0
- data/lib/dcc/base/comment.rb +23 -0
- data/lib/dcc/base/condition.rb +34 -0
- data/lib/dcc/base/contact.rb +38 -0
- data/lib/dcc/base/contact_not_strict.rb +38 -0
- data/lib/dcc/base/core_data.rb +44 -0
- data/lib/dcc/base/data.rb +42 -0
- data/lib/dcc/base/digital_calibration_certificate.rb +32 -0
- data/lib/dcc/base/equipment_class.rb +24 -0
- data/lib/dcc/base/formula.rb +33 -0
- data/lib/dcc/base/hash_type.rb +34 -0
- data/lib/dcc/base/identification.rb +27 -0
- data/lib/dcc/base/identifications.rb +27 -0
- data/lib/dcc/base/influence_condition.rb +16 -0
- data/lib/dcc/base/influence_condition_list.rb +40 -0
- data/lib/dcc/base/item.rb +38 -0
- data/lib/dcc/base/item_list.rb +38 -0
- data/lib/dcc/base/list.rb +44 -0
- data/lib/dcc/base/location.rb +36 -0
- data/lib/dcc/base/measurement_meta_data.rb +15 -0
- data/lib/dcc/base/measurement_meta_data_list.rb +27 -0
- data/lib/dcc/base/measurement_result.rb +41 -0
- data/lib/dcc/base/measurement_result_list.rb +28 -0
- data/lib/dcc/base/measuring_equipment.rb +41 -0
- data/lib/dcc/base/measuring_equipment_list.rb +38 -0
- data/lib/dcc/base/quantity.rb +61 -0
- data/lib/dcc/base/ref_type_definition.rb +36 -0
- data/lib/dcc/base/ref_type_definition_list.rb +21 -0
- data/lib/dcc/base/resp_person.rb +38 -0
- data/lib/dcc/base/resp_person_list.rb +27 -0
- data/lib/dcc/base/result.rb +31 -0
- data/lib/dcc/base/result_list.rb +27 -0
- data/lib/dcc/base/rich_content.rb +34 -0
- data/lib/dcc/base/software.rb +35 -0
- data/lib/dcc/base/software_list.rb +27 -0
- data/lib/dcc/base/statement.rb +50 -0
- data/lib/dcc/base/statement_list.rb +27 -0
- data/lib/dcc/base/string_with_lang.rb +24 -0
- data/lib/dcc/base/text.rb +33 -0
- data/lib/dcc/base/used_method.rb +31 -0
- data/lib/dcc/base/used_method_list.rb +27 -0
- data/lib/dcc/base/xml_blob.rb +20 -0
- data/lib/dcc/base.rb +58 -0
- data/lib/dcc/builder/dsl.rb +10 -0
- data/lib/dcc/builder/session.rb +170 -0
- data/lib/dcc/builder.rb +34 -0
- data/lib/dcc/cli/cli.rb +149 -0
- data/lib/dcc/cli/formatters.rb +77 -0
- data/lib/dcc/cli.rb +7 -0
- data/lib/dcc/common_elements.rb +20 -0
- data/lib/dcc/context_configuration.rb +167 -0
- data/lib/dcc/context_options.rb +47 -0
- data/lib/dcc/convert/csv.rb +129 -0
- data/lib/dcc/convert/html.rb +127 -0
- data/lib/dcc/convert/json.rb +62 -0
- data/lib/dcc/convert/result.rb +51 -0
- data/lib/dcc/convert/yaml.rb +21 -0
- data/lib/dcc/convert.rb +14 -0
- data/lib/dcc/diff/change.rb +21 -0
- data/lib/dcc/diff/result.rb +58 -0
- data/lib/dcc/diff.rb +83 -0
- data/lib/dcc/error.rb +54 -0
- data/lib/dcc/extract/file.rb +143 -0
- data/lib/dcc/extract/ring.rb +28 -0
- data/lib/dcc/extract.rb +9 -0
- data/lib/dcc/i18n/text_lookup.rb +67 -0
- data/lib/dcc/i18n.rb +12 -0
- data/lib/dcc/inspect/report.rb +139 -0
- data/lib/dcc/inspect.rb +9 -0
- data/lib/dcc/migrate.rb +41 -0
- data/lib/dcc/namespace/dcc.rb +30 -0
- data/lib/dcc/namespace/dsig.rb +15 -0
- data/lib/dcc/namespace/math_ml.rb +14 -0
- data/lib/dcc/namespace/qudt.rb +15 -0
- data/lib/dcc/namespace/si.rb +26 -0
- data/lib/dcc/namespace.rb +18 -0
- data/lib/dcc/plugin/registry.rb +45 -0
- data/lib/dcc/plugin.rb +42 -0
- data/lib/dcc/quantity_format/formatter.rb +90 -0
- data/lib/dcc/quantity_format.rb +10 -0
- data/lib/dcc/quantity_math/quantity.rb +46 -0
- data/lib/dcc/quantity_math/real.rb +116 -0
- data/lib/dcc/quantity_math.rb +14 -0
- data/lib/dcc/schema/resources/dcc/dsi/v1.0.1.xsd +415 -0
- data/lib/dcc/schema/resources/dcc/dsi/v1.3.0.xsd +814 -0
- data/lib/dcc/schema/resources/dcc/dsi/v1.3.1.xsd +814 -0
- data/lib/dcc/schema/resources/dcc/dsi/v2.0.0.xsd +869 -0
- data/lib/dcc/schema/resources/dcc/dsi/v2.1.0.xsd +1031 -0
- data/lib/dcc/schema/resources/dcc/dsi/v2.2.1.xsd +1574 -0
- data/lib/dcc/schema/resources/dcc/qudt/v2.2.1.xsd +44 -0
- data/lib/dcc/schema/resources/dcc/v2.1.0/dcc.xsd +650 -0
- data/lib/dcc/schema/resources/dcc/v2.1.1/dcc.xsd +669 -0
- data/lib/dcc/schema/resources/dcc/v2.2.0/dcc.xsd +730 -0
- data/lib/dcc/schema/resources/dcc/v2.3.0/dcc.xsd +708 -0
- data/lib/dcc/schema/resources/dcc/v2.4.0/dcc.xsd +725 -0
- data/lib/dcc/schema/resources/dcc/v3.0.0/dcc.xsd +749 -0
- data/lib/dcc/schema/resources/dcc/v3.1.0/dcc.xsd +843 -0
- data/lib/dcc/schema/resources/dcc/v3.1.1/dcc.xsd +843 -0
- data/lib/dcc/schema/resources/dcc/v3.1.2/dcc.xsd +844 -0
- data/lib/dcc/schema/resources/dcc/v3.2.0/dcc.xsd +940 -0
- data/lib/dcc/schema/resources/dcc/v3.2.1/dcc.xsd +963 -0
- data/lib/dcc/schema/resources/dcc/v3.3.0/dcc.xsd +1008 -0
- data/lib/dcc/schema/resources/dcc/xmldsig-core-schema.xsd +312 -0
- data/lib/dcc/schema/resources/dsi/qudt/v2.2.1.xsd +44 -0
- data/lib/dcc/schema/resources/dsi/v1.0.1/SI_Format.xsd +415 -0
- data/lib/dcc/schema/resources/dsi/v1.3.0/SI_Format.xsd +814 -0
- data/lib/dcc/schema/resources/dsi/v1.3.1/SI_Format.xsd +814 -0
- data/lib/dcc/schema/resources/dsi/v2.0.0/SI_Format.xsd +869 -0
- data/lib/dcc/schema/resources/dsi/v2.1.0/SI_Format.xsd +1031 -0
- data/lib/dcc/schema/resources/dsi/v2.2.1/SI_Format.xsd +1574 -0
- data/lib/dcc/schema/resources/qudt/qudt.xsd +44 -0
- data/lib/dcc/schema/resources/schematron/dcc.sch +523 -0
- data/lib/dcc/schema/resources/schematron/dcc.svrl +2302 -0
- data/lib/dcc/schema/resources/xmldsig/xmldsig-core-schema.xsd +312 -0
- data/lib/dcc/schema/version.rb +94 -0
- data/lib/dcc/schema.rb +35 -0
- data/lib/dcc/server/app.rb +133 -0
- data/lib/dcc/server/storage/entry.rb +15 -0
- data/lib/dcc/server/storage/memory.rb +57 -0
- data/lib/dcc/server/storage.rb +13 -0
- data/lib/dcc/server.rb +33 -0
- data/lib/dcc/si/base/complex.rb +43 -0
- data/lib/dcc/si/base/complex_list_xml_list.rb +39 -0
- data/lib/dcc/si/base/constant.rb +39 -0
- data/lib/dcc/si/base/coverage_interval_mu.rb +31 -0
- data/lib/dcc/si/base/expanded_mu.rb +29 -0
- data/lib/dcc/si/base/expanded_unc_xml_list.rb +30 -0
- data/lib/dcc/si/base/hybrid.rb +42 -0
- data/lib/dcc/si/base/measurement_uncertainty_univariate.rb +28 -0
- data/lib/dcc/si/base/real.rb +48 -0
- data/lib/dcc/si/base/real_list_xml_list.rb +45 -0
- data/lib/dcc/si/base/si_list.rb +37 -0
- data/lib/dcc/si/base/standard_mu.rb +25 -0
- data/lib/dcc/si/base.rb +24 -0
- data/lib/dcc/si/common_elements.rb +13 -0
- data/lib/dcc/si/namespace.rb +7 -0
- data/lib/dcc/si/v1/common_elements.rb +13 -0
- data/lib/dcc/si/v1/complex.rb +8 -0
- data/lib/dcc/si/v1/complex_list_xml_list.rb +8 -0
- data/lib/dcc/si/v1/configuration.rb +13 -0
- data/lib/dcc/si/v1/constant.rb +8 -0
- data/lib/dcc/si/v1/coverage_interval_mu.rb +8 -0
- data/lib/dcc/si/v1/expanded_mu.rb +8 -0
- data/lib/dcc/si/v1/expanded_unc.rb +23 -0
- data/lib/dcc/si/v1/expanded_unc_xml_list.rb +8 -0
- data/lib/dcc/si/v1/hybrid.rb +8 -0
- data/lib/dcc/si/v1/measurement_uncertainty_univariate.rb +8 -0
- data/lib/dcc/si/v1/namespace.rb +9 -0
- data/lib/dcc/si/v1/real.rb +8 -0
- data/lib/dcc/si/v1/real_list_xml_list.rb +8 -0
- data/lib/dcc/si/v1/si_list.rb +8 -0
- data/lib/dcc/si/v1/standard_mu.rb +8 -0
- data/lib/dcc/si/v1.rb +46 -0
- data/lib/dcc/si/v2/common_elements.rb +13 -0
- data/lib/dcc/si/v2/complex.rb +8 -0
- data/lib/dcc/si/v2/complex_list_xml_list.rb +8 -0
- data/lib/dcc/si/v2/configuration.rb +13 -0
- data/lib/dcc/si/v2/constant.rb +8 -0
- data/lib/dcc/si/v2/coverage_interval_mu.rb +8 -0
- data/lib/dcc/si/v2/coverage_interval_mu_xml_list.rb +24 -0
- data/lib/dcc/si/v2/expanded_mu.rb +8 -0
- data/lib/dcc/si/v2/expanded_mu_xml_list.rb +22 -0
- data/lib/dcc/si/v2/expanded_unc_xml_list.rb +8 -0
- data/lib/dcc/si/v2/hybrid.rb +8 -0
- data/lib/dcc/si/v2/measurement_uncertainty_univariate.rb +8 -0
- data/lib/dcc/si/v2/namespace.rb +9 -0
- data/lib/dcc/si/v2/real.rb +8 -0
- data/lib/dcc/si/v2/real_list_xml_list.rb +8 -0
- data/lib/dcc/si/v2/si_list.rb +8 -0
- data/lib/dcc/si/v2/standard_mu.rb +8 -0
- data/lib/dcc/si/v2/standard_mu_xml_list.rb +18 -0
- data/lib/dcc/si/v2.rb +49 -0
- data/lib/dcc/si.rb +34 -0
- data/lib/dcc/signature/result.rb +43 -0
- data/lib/dcc/signature/signer.rb +36 -0
- data/lib/dcc/signature/verifier.rb +41 -0
- data/lib/dcc/signature.rb +13 -0
- data/lib/dcc/transform/result.rb +24 -0
- data/lib/dcc/transform/xslt.rb +72 -0
- data/lib/dcc/transform.rb +12 -0
- data/lib/dcc/type/base64_binary.rb +55 -0
- data/lib/dcc/type/decimal_xml_list.rb +47 -0
- data/lib/dcc/type/iso_country_code.rb +23 -0
- data/lib/dcc/type/iso_language_code.rb +23 -0
- data/lib/dcc/type/schema_version.rb +37 -0
- data/lib/dcc/type/si_unit.rb +26 -0
- data/lib/dcc/type.rb +16 -0
- data/lib/dcc/type_guards.rb +140 -0
- data/lib/dcc/v2/administrative_data.rb +8 -0
- data/lib/dcc/v2/byte_data.rb +8 -0
- data/lib/dcc/v2/calibration_laboratory.rb +8 -0
- data/lib/dcc/v2/comment.rb +8 -0
- data/lib/dcc/v2/common_elements.rb +13 -0
- data/lib/dcc/v2/condition.rb +8 -0
- data/lib/dcc/v2/configuration.rb +17 -0
- data/lib/dcc/v2/contact.rb +8 -0
- data/lib/dcc/v2/contact_not_strict.rb +8 -0
- data/lib/dcc/v2/core_data.rb +8 -0
- data/lib/dcc/v2/data.rb +8 -0
- data/lib/dcc/v2/digital_calibration_certificate.rb +8 -0
- data/lib/dcc/v2/equipment_class.rb +8 -0
- data/lib/dcc/v2/formula.rb +8 -0
- data/lib/dcc/v2/hash_type.rb +8 -0
- data/lib/dcc/v2/identification.rb +8 -0
- data/lib/dcc/v2/identifications.rb +8 -0
- data/lib/dcc/v2/influence_condition.rb +7 -0
- data/lib/dcc/v2/influence_condition_list.rb +8 -0
- data/lib/dcc/v2/item.rb +8 -0
- data/lib/dcc/v2/item_list.rb +8 -0
- data/lib/dcc/v2/list.rb +8 -0
- data/lib/dcc/v2/location.rb +8 -0
- data/lib/dcc/v2/measurement_meta_data.rb +8 -0
- data/lib/dcc/v2/measurement_meta_data_list.rb +8 -0
- data/lib/dcc/v2/measurement_result.rb +8 -0
- data/lib/dcc/v2/measurement_result_list.rb +8 -0
- data/lib/dcc/v2/measuring_equipment.rb +8 -0
- data/lib/dcc/v2/measuring_equipment_list.rb +8 -0
- data/lib/dcc/v2/namespace.rb +8 -0
- data/lib/dcc/v2/quantity.rb +49 -0
- data/lib/dcc/v2/ref_type_definition.rb +11 -0
- data/lib/dcc/v2/ref_type_definition_list.rb +15 -0
- data/lib/dcc/v2/resp_person.rb +8 -0
- data/lib/dcc/v2/resp_person_list.rb +8 -0
- data/lib/dcc/v2/result.rb +8 -0
- data/lib/dcc/v2/result_list.rb +8 -0
- data/lib/dcc/v2/rich_content.rb +12 -0
- data/lib/dcc/v2/software.rb +8 -0
- data/lib/dcc/v2/software_list.rb +8 -0
- data/lib/dcc/v2/statement.rb +8 -0
- data/lib/dcc/v2/statement_list.rb +8 -0
- data/lib/dcc/v2/string_with_lang.rb +8 -0
- data/lib/dcc/v2/text.rb +8 -0
- data/lib/dcc/v2/used_method.rb +8 -0
- data/lib/dcc/v2/used_method_list.rb +8 -0
- data/lib/dcc/v2/xml_blob.rb +8 -0
- data/lib/dcc/v2.rb +84 -0
- data/lib/dcc/v3/administrative_data.rb +8 -0
- data/lib/dcc/v3/byte_data.rb +8 -0
- data/lib/dcc/v3/calibration_laboratory.rb +8 -0
- data/lib/dcc/v3/comment.rb +8 -0
- data/lib/dcc/v3/common_elements.rb +11 -0
- data/lib/dcc/v3/condition.rb +8 -0
- data/lib/dcc/v3/configuration.rb +17 -0
- data/lib/dcc/v3/contact.rb +8 -0
- data/lib/dcc/v3/contact_not_strict.rb +8 -0
- data/lib/dcc/v3/core_data.rb +8 -0
- data/lib/dcc/v3/data.rb +8 -0
- data/lib/dcc/v3/digital_calibration_certificate.rb +8 -0
- data/lib/dcc/v3/equipment_class.rb +8 -0
- data/lib/dcc/v3/formula.rb +8 -0
- data/lib/dcc/v3/hash_type.rb +8 -0
- data/lib/dcc/v3/identification.rb +8 -0
- data/lib/dcc/v3/identifications.rb +8 -0
- data/lib/dcc/v3/influence_condition.rb +7 -0
- data/lib/dcc/v3/influence_condition_list.rb +8 -0
- data/lib/dcc/v3/item.rb +8 -0
- data/lib/dcc/v3/item_list.rb +8 -0
- data/lib/dcc/v3/list.rb +8 -0
- data/lib/dcc/v3/location.rb +8 -0
- data/lib/dcc/v3/measurement_meta_data.rb +8 -0
- data/lib/dcc/v3/measurement_meta_data_list.rb +8 -0
- data/lib/dcc/v3/measurement_result.rb +8 -0
- data/lib/dcc/v3/measurement_result_list.rb +8 -0
- data/lib/dcc/v3/measuring_equipment.rb +8 -0
- data/lib/dcc/v3/measuring_equipment_list.rb +8 -0
- data/lib/dcc/v3/namespace.rb +7 -0
- data/lib/dcc/v3/quantity.rb +49 -0
- data/lib/dcc/v3/ref_type_definition.rb +8 -0
- data/lib/dcc/v3/ref_type_definition_list.rb +8 -0
- data/lib/dcc/v3/resp_person.rb +8 -0
- data/lib/dcc/v3/resp_person_list.rb +8 -0
- data/lib/dcc/v3/result.rb +8 -0
- data/lib/dcc/v3/result_list.rb +8 -0
- data/lib/dcc/v3/rich_content.rb +8 -0
- data/lib/dcc/v3/software.rb +8 -0
- data/lib/dcc/v3/software_list.rb +8 -0
- data/lib/dcc/v3/statement.rb +8 -0
- data/lib/dcc/v3/statement_list.rb +8 -0
- data/lib/dcc/v3/string_with_lang.rb +8 -0
- data/lib/dcc/v3/text.rb +8 -0
- data/lib/dcc/v3/used_method.rb +8 -0
- data/lib/dcc/v3/used_method_list.rb +8 -0
- data/lib/dcc/v3/xml_blob.rb +8 -0
- data/lib/dcc/v3.rb +111 -0
- data/lib/dcc/validate/business_rules.rb +121 -0
- data/lib/dcc/validate/issue.rb +56 -0
- data/lib/dcc/validate/result.rb +105 -0
- data/lib/dcc/validate/schematron/profile.rb +64 -0
- data/lib/dcc/validate/schematron/rule.rb +49 -0
- data/lib/dcc/validate/schematron/rules/administrative_data_completeness.rb +42 -0
- data/lib/dcc/validate/schematron/rules/base.rb +15 -0
- data/lib/dcc/validate/schematron/rules/date_range_check.rb +41 -0
- data/lib/dcc/validate/schematron/rules/id_refid_linking.rb +61 -0
- data/lib/dcc/validate/schematron/rules/influence_conditions_placement.rb +58 -0
- data/lib/dcc/validate/schematron/rules/iso_code_validation.rb +53 -0
- data/lib/dcc/validate/schematron/rules/language_code_dedup.rb +39 -0
- data/lib/dcc/validate/schematron/rules/non_si_declaration.rb +82 -0
- data/lib/dcc/validate/schematron/rules/release_format_check.rb +44 -0
- data/lib/dcc/validate/schematron/rules/schema_version_check.rb +31 -0
- data/lib/dcc/validate/schematron/rules/uncertainty_consistency.rb +58 -0
- data/lib/dcc/validate/schematron/rules/unit_format_check.rb +74 -0
- data/lib/dcc/validate/schematron/rules/used_methods_placement.rb +65 -0
- data/lib/dcc/validate/schematron/rules/used_software_placement.rb +43 -0
- data/lib/dcc/validate/schematron/rules/xml_list_spacing.rb +42 -0
- data/lib/dcc/validate/schematron/rules.rb +30 -0
- data/lib/dcc/validate/schematron.rb +22 -0
- data/lib/dcc/validate/severity.rb +39 -0
- data/lib/dcc/validate/xsd.rb +97 -0
- data/lib/dcc/validate.rb +15 -0
- data/lib/dcc/version.rb +5 -0
- data/lib/dcc/versioned_parser.rb +48 -0
- data/lib/dcc.rb +141 -0
- metadata +425 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 20194e78152501f174cc4043818c81319b23e7daf7cd18ab37277ea2cf1d8efe
|
|
4
|
+
data.tar.gz: a26781f5b6c988f2fa45b90c5ebc288e858513fc3e4a88d7a726df15269879c0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 19c04dbb79e6b417827093efe6f3304c88bf7bb8d4ff504669f19b33e4f0b78491f48675d4db885d84abf03feff78e7a51ac4f989f418a8ed0065a9d223fb1e9
|
|
7
|
+
data.tar.gz: 5b92f29ff4422d1f9c73ac60a7e2b1b6a2eb5c8405cd0e755ad38699df56c8327ef6325c3ef19b5f761b5bed836ffdf5fea284e9624c2dc8baa9eea1626c2684
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
|
|
3
|
+
- .rubocop_todo.yml
|
|
4
|
+
|
|
5
|
+
inherit_mode:
|
|
6
|
+
merge:
|
|
7
|
+
- Exclude
|
|
8
|
+
|
|
9
|
+
plugins:
|
|
10
|
+
- rubocop-rspec
|
|
11
|
+
- rubocop-performance
|
|
12
|
+
- rubocop-rake
|
|
13
|
+
|
|
14
|
+
AllCops:
|
|
15
|
+
TargetRubyVersion: 3.2
|
|
16
|
+
NewCops: enable
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2026-07-21 using RuboCop version 1.21+.
|
|
4
|
+
# The point is for the user to remove these records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 0
|
|
10
|
+
# Initially empty; populated by `rubocop --auto-gen-config`.
|
data/CHANGELOG.adoc
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
= Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog],
|
|
6
|
+
and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Versioning].
|
|
7
|
+
|
|
8
|
+
== [Unreleased]
|
|
9
|
+
|
|
10
|
+
=== Added
|
|
11
|
+
* YARD-style documentation throughout the public API
|
|
12
|
+
* Performance memoization for hot paths
|
|
13
|
+
* Plugin system for custom validators and converters
|
|
14
|
+
|
|
15
|
+
== [0.1.0] — 2026-07-22
|
|
16
|
+
|
|
17
|
+
=== Added
|
|
18
|
+
* Initial public release of the `dcc` gem.
|
|
19
|
+
* Fully typed object model for DCC v2.x and v3.x with per-major-version
|
|
20
|
+
type registries (mirrors the plurimath/mml pattern).
|
|
21
|
+
* D-SI v1.x and v2.x quantity models (real, complex, constant, lists,
|
|
22
|
+
hybrid, uncertainties).
|
|
23
|
+
* XSD validation against all 12 bundled DCC schemas.
|
|
24
|
+
* Pure-Ruby Schematron engine implementing 14 PTB patterns.
|
|
25
|
+
* Ruby-side business rule validators (signer coverage, unique IDs).
|
|
26
|
+
* Format converters: JSON, YAML, CSV, HTML.
|
|
27
|
+
* File extraction with ring-aware iteration.
|
|
28
|
+
* MathML content-MathML parser with BigDecimal evaluator (REXML-based).
|
|
29
|
+
* XMLDSig signature sign/verify (soft-dep on xmldsig).
|
|
30
|
+
* XSLT transform via xsltproc or Saxon-HE bridge.
|
|
31
|
+
* Builder DSL for programmatic DCC construction.
|
|
32
|
+
* Structural diff of two certificates.
|
|
33
|
+
* Version migration (same-major rewrite, cross-major reparse).
|
|
34
|
+
* BigDecimal-based quantity math with uncertainty propagation
|
|
35
|
+
(RSS / fractional / derivative).
|
|
36
|
+
* SmartCom-style quantity formatting (short / long / LaTeX).
|
|
37
|
+
* Thor-based CLI with 8 subcommands.
|
|
38
|
+
* Optional Sinatra REST API mirroring PTB dcclib endpoints.
|
|
39
|
+
* i18n navigation helpers for multilingual content.
|
|
40
|
+
* Streaming pull parser for large documents.
|
|
41
|
+
* Plugin registry for third-party extensions.
|
|
42
|
+
* 229 specs, 0 failures.
|
|
43
|
+
* 45 PTB reference fixtures covering DCC + D-SI examples by tier.
|
|
44
|
+
* AsciiDoc documentation + 5 runnable example scripts.
|
|
45
|
+
|
|
46
|
+
=== Quality gates met
|
|
47
|
+
* No `require_relative` in `lib/`.
|
|
48
|
+
* No `require "dcc/..."` with internal paths.
|
|
49
|
+
* No `send` / `instance_variable_set` / `instance_variable_get`.
|
|
50
|
+
* No `respond_to?` for type checking.
|
|
51
|
+
* No Nokogiri outside `lib/dcc/validate/xsd.rb`.
|
|
52
|
+
* No doubles in specs.
|
|
53
|
+
* `frozen_string_literal: true` everywhere.
|
|
54
|
+
* OCP/MECE/DRY throughout.
|
data/CONTRIBUTING.adoc
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
= Contributing to the dcc gem
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in improving the `dcc` gem! This document
|
|
4
|
+
covers setup, code style, and the contribution workflow.
|
|
5
|
+
|
|
6
|
+
== Setup
|
|
7
|
+
|
|
8
|
+
$ git clone https://github.com/lutaml/dcc.git
|
|
9
|
+
$ cd dcc
|
|
10
|
+
$ bundle install
|
|
11
|
+
|
|
12
|
+
Run the test suite:
|
|
13
|
+
|
|
14
|
+
$ bundle exec rake
|
|
15
|
+
|
|
16
|
+
(That runs `bundle exec rspec` then `bundle exec rubocop`.)
|
|
17
|
+
|
|
18
|
+
== Branch policy
|
|
19
|
+
|
|
20
|
+
* All changes go through PRs. Never commit to `main`.
|
|
21
|
+
* Branch naming: `feat/<short-description>`,
|
|
22
|
+
`fix/<short-description>`, `docs/<short-description>`.
|
|
23
|
+
* Squash-merge or rebase-merge into `main`.
|
|
24
|
+
|
|
25
|
+
== Code quality rules
|
|
26
|
+
|
|
27
|
+
The project enforces strict rules inherited from Ribose's
|
|
28
|
+
https://github.com/riboseinc/oss-guides[OSS guides] plus project-specific
|
|
29
|
+
constraints:
|
|
30
|
+
|
|
31
|
+
=== Forbidden
|
|
32
|
+
* `require_relative` inside `lib/` — use Ruby `autoload` instead.
|
|
33
|
+
* `require "dcc/..."` with internal paths — autoload only.
|
|
34
|
+
* `send` to call private methods — redesign the API boundary.
|
|
35
|
+
* `instance_variable_set` / `instance_variable_get` — use accessors.
|
|
36
|
+
* `respond_to?` for type checking — use `is_a?` or model the type hierarchy.
|
|
37
|
+
* Nokogiri anywhere outside `lib/dcc/validate/xsd.rb`.
|
|
38
|
+
* Doubles in specs — use real model instances.
|
|
39
|
+
* Hand-rolled `to_h`/`from_h` on model classes — use lutaml-model mappings.
|
|
40
|
+
|
|
41
|
+
=== Required
|
|
42
|
+
* `# frozen_string_literal: true` at the top of every Ruby file.
|
|
43
|
+
* `module_eval`/`class_eval` blocks should reference fully-qualified
|
|
44
|
+
constants (e.g. `::Dcc::Namespace::Dcc`).
|
|
45
|
+
* Output models (`Dcc::Validate::Result`, `Dcc::Convert::Result`,
|
|
46
|
+
`Dcc::Inspect::Report`, `Dcc::Diff::Result`) must respond to
|
|
47
|
+
`to_s`, `to_json`, and `to_yaml`.
|
|
48
|
+
* Public API surfaces should carry YARD `# @param` / `# @return`
|
|
49
|
+
annotations.
|
|
50
|
+
|
|
51
|
+
== Testing
|
|
52
|
+
|
|
53
|
+
* Every public method has specs.
|
|
54
|
+
* Round-trip specs run over every PTB reference fixture under
|
|
55
|
+
`spec/fixtures/`.
|
|
56
|
+
* Schematron rules each have at least one negative spec.
|
|
57
|
+
|
|
58
|
+
== Commit messages
|
|
59
|
+
|
|
60
|
+
* Imperative mood: "Add X", "Fix Y", "Document Z".
|
|
61
|
+
* First line ≤ 72 characters.
|
|
62
|
+
* Body wraps at 72 columns.
|
|
63
|
+
* No `Co-authored-by:` trailers for AI tools (per project policy).
|
|
64
|
+
* No "Generated with Claude" or similar AI-acknowledgment footers.
|
data/Gemfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gemspec
|
|
6
|
+
|
|
7
|
+
gem "canon"
|
|
8
|
+
gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
|
|
9
|
+
gem "mml", "~> 2.4.0"
|
|
10
|
+
gem "moxml"
|
|
11
|
+
gem "nokogiri"
|
|
12
|
+
gem "rake", "~> 13.0"
|
|
13
|
+
gem "rspec", "~> 3.0"
|
|
14
|
+
gem "rubocop", "~> 1.21"
|
|
15
|
+
gem "rubocop-performance"
|
|
16
|
+
gem "rubocop-rake"
|
|
17
|
+
gem "rubocop-rspec"
|
|
18
|
+
gem "tty-table"
|
|
19
|
+
|
|
20
|
+
# Optional dependencies — loaded lazily by the feature that needs them.
|
|
21
|
+
group :optional do
|
|
22
|
+
gem "sinatra" # Dcc::Server REST API
|
|
23
|
+
gem "tty-prompt" # dcc issue (interactive builder)
|
|
24
|
+
gem "xmldsig" # Dcc::Signature
|
|
25
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ribose Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.adoc
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
= DCC
|
|
2
|
+
|
|
3
|
+
A Ruby library for parsing, validating, converting, signing, and building
|
|
4
|
+
PTB https://ptb.de[Digital Calibration Certificates^] (DCC) and
|
|
5
|
+
https://ptb.de/d-si[D-SI^] quantity documents.
|
|
6
|
+
|
|
7
|
+
Built on top of the
|
|
8
|
+
https://github.com/lutaml/lutaml-model[`lutaml-model`^] framework, `dcc`
|
|
9
|
+
provides a fully typed Ruby object representation of both the DCC and D-SI
|
|
10
|
+
XML schemas, with per-major-version class hierarchies mirroring the approach
|
|
11
|
+
used by the https://github.com/plurimath/mml[`mml`^] gem for MathML.
|
|
12
|
+
|
|
13
|
+
== Highlights
|
|
14
|
+
|
|
15
|
+
* Fully typed object model for DCC v2.x and v3.x (no more XPath over `lxml`)
|
|
16
|
+
* Fully typed object model for D-SI v1.x and v2.x
|
|
17
|
+
* Lossless round-trip XML fidelity (parsing then serializing is byte-equivalent after canonicalization)
|
|
18
|
+
* Pure-Ruby Schematron engine implementing the 14 PTB Schematron patterns
|
|
19
|
+
(no Java/Saxon-HE dependency)
|
|
20
|
+
* XSD validation against all 12 bundled DCC schema versions
|
|
21
|
+
* JSON / YAML / CSV / HTML converters
|
|
22
|
+
* MathML formula extraction with BigDecimal-based evaluation
|
|
23
|
+
* XMLDSig signature signing and verification (soft dependency on `xmldsig`)
|
|
24
|
+
* XSLT 1.0 transformation via Nokogiri (optional Saxon-HE bridge for XSLT 2.0/3.0)
|
|
25
|
+
* Programmatic DCC builder DSL
|
|
26
|
+
* Structural diff of two certificates
|
|
27
|
+
* Version migration helpers
|
|
28
|
+
* Thor-based CLI with `validate`, `convert`, `extract`, `signature`,
|
|
29
|
+
`transform`, `inspect`, `diff`, and `issue` commands
|
|
30
|
+
|
|
31
|
+
== Quick start
|
|
32
|
+
|
|
33
|
+
Install the gem:
|
|
34
|
+
|
|
35
|
+
$ gem install dcc
|
|
36
|
+
|
|
37
|
+
Parse a certificate:
|
|
38
|
+
|
|
39
|
+
[source,ruby]
|
|
40
|
+
----
|
|
41
|
+
require "dcc"
|
|
42
|
+
|
|
43
|
+
dcc = Dcc.parse(File.read("certificate.xml"))
|
|
44
|
+
dcc.administrative_data.core_data.unique_identifier
|
|
45
|
+
dcc.measurement_results.first.results.first.data.quantities.first.value
|
|
46
|
+
----
|
|
47
|
+
|
|
48
|
+
Validate:
|
|
49
|
+
|
|
50
|
+
[source,ruby]
|
|
51
|
+
----
|
|
52
|
+
result = Dcc::Validate::Xsd.call(File.read("certificate.xml"), version: "3.3.0")
|
|
53
|
+
result.ok? # => true
|
|
54
|
+
----
|
|
55
|
+
|
|
56
|
+
Or via the CLI:
|
|
57
|
+
|
|
58
|
+
$ dcc inspect certificate.xml
|
|
59
|
+
$ dcc validate all certificate.xml
|
|
60
|
+
$ dcc convert json certificate.xml -o certificate.json
|
|
61
|
+
|
|
62
|
+
== Status
|
|
63
|
+
|
|
64
|
+
This gem is under active development. See `TODO.complete/` for the current
|
|
65
|
+
work breakdown.
|
|
66
|
+
|
|
67
|
+
== License
|
|
68
|
+
|
|
69
|
+
MIT -- see link:LICENSE[LICENSE].
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
RuboCop::RakeTask.new
|
|
10
|
+
|
|
11
|
+
Dir.glob("lib/tasks/**/*.rake").each { |r| load r }
|
|
12
|
+
|
|
13
|
+
task default: %i[spec rubocop]
|
data/dcc.gemspec
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/dcc/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "dcc"
|
|
7
|
+
spec.version = Dcc::VERSION
|
|
8
|
+
spec.authors = ["Ribose Inc."]
|
|
9
|
+
spec.email = ["open.source@ribose.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Digital Calibration Certificate (DCC) and D-SI library for Ruby"
|
|
12
|
+
spec.description = <<~DESCRIPTION
|
|
13
|
+
A Ruby library for parsing, validating, converting, signing, and building
|
|
14
|
+
PTB Digital Calibration Certificates (DCC) and D-SI quantity documents.
|
|
15
|
+
Uses lutaml-model for a fully typed object representation of both XML
|
|
16
|
+
schemas, with per-major-version (v2, v3) class hierarchies.
|
|
17
|
+
DESCRIPTION
|
|
18
|
+
|
|
19
|
+
spec.homepage = "https://github.com/lutaml/dcc"
|
|
20
|
+
spec.license = "MIT"
|
|
21
|
+
|
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/lutaml/dcc/releases"
|
|
25
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
26
|
+
|
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
28
|
+
`git ls-files -z`
|
|
29
|
+
.split("\x0")
|
|
30
|
+
.reject { |f| f.match(%r{^(test|spec|features|TODO\.complete)/}) }
|
|
31
|
+
end
|
|
32
|
+
spec.bindir = "exe"
|
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
34
|
+
spec.require_paths = ["lib"]
|
|
35
|
+
|
|
36
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
37
|
+
|
|
38
|
+
spec.add_dependency "lutaml-model", "~> 0.8"
|
|
39
|
+
spec.add_dependency "mml", "~> 2.4.0"
|
|
40
|
+
spec.add_dependency "thor"
|
|
41
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
= CLI Reference
|
|
2
|
+
|
|
3
|
+
The `dcc` executable ships with the gem and exposes the following
|
|
4
|
+
subcommands. All commands default to human-readable output; pass
|
|
5
|
+
`--format json` or `--format yaml` for machine-readable output.
|
|
6
|
+
|
|
7
|
+
== validate
|
|
8
|
+
|
|
9
|
+
$ dcc validate xsd FILE [--version 3.3.0|auto]
|
|
10
|
+
$ dcc validate schematron FILE
|
|
11
|
+
$ dcc validate all FILE
|
|
12
|
+
|
|
13
|
+
Validates a DCC XML file. `xsd` checks against the bundled XSD of the
|
|
14
|
+
chosen version. `schematron` runs the 14 PTB patterns in pure Ruby.
|
|
15
|
+
`all` chains both. Exits 0 on success, 1 on failure.
|
|
16
|
+
|
|
17
|
+
== convert
|
|
18
|
+
|
|
19
|
+
$ dcc convert json|yaml|csv|html FILE [-o OUTPUT]
|
|
20
|
+
|
|
21
|
+
Converts a DCC XML file to the requested format. Default writes to
|
|
22
|
+
stdout; use `-o PATH` to write to a file.
|
|
23
|
+
|
|
24
|
+
== extract
|
|
25
|
+
|
|
26
|
+
$ dcc extract files FILE [INDEX] [-o OUTPUT] [-r RING]
|
|
27
|
+
$ dcc extract formulae FILE [-v KEY=VAL[,VAL...]]...
|
|
28
|
+
|
|
29
|
+
Lists or extracts embedded files (`files`), or evaluates MathML
|
|
30
|
+
formulae (`formulae`). For `files`, `INDEX` returns the binary payload
|
|
31
|
+
of one file; `-r` filters by ring (`administrativeData`,
|
|
32
|
+
`measurementResults`, `comment`, `document`).
|
|
33
|
+
|
|
34
|
+
== inspect
|
|
35
|
+
|
|
36
|
+
$ dcc inspect FILE [--format text|json|yaml]
|
|
37
|
+
|
|
38
|
+
Prints a summary of a DCC: schema version, unique identifier, country,
|
|
39
|
+
languages, counts of items / measurement results / quantities / lists /
|
|
40
|
+
embedded files / signers, and signature presence.
|
|
41
|
+
|
|
42
|
+
== diff
|
|
43
|
+
|
|
44
|
+
$ dcc diff A.xml B.xml [--format text|json]
|
|
45
|
+
|
|
46
|
+
Compares two DCC files structurally and reports additions, removals,
|
|
47
|
+
and modifications.
|
|
48
|
+
|
|
49
|
+
== signature (soft-dep on xmldsig)
|
|
50
|
+
|
|
51
|
+
$ dcc signature sign CERT KEY FILE [-o OUTPUT]
|
|
52
|
+
$ dcc signature verify CA_CERT FILE [-o OUTPUT]
|
|
53
|
+
|
|
54
|
+
Signs or verifies a DCC using XMLDSig enveloped signatures.
|
|
55
|
+
|
|
56
|
+
== transform
|
|
57
|
+
|
|
58
|
+
$ dcc transform xslt FILE XSLT [-o OUTPUT] [--engine xsltproc|saxon]
|
|
59
|
+
|
|
60
|
+
Applies an XSLT stylesheet. Uses the system `xsltproc` for XSLT 1.0,
|
|
61
|
+
or `java -jar $SAXON_JAR` for XSLT 2.0/3.0 when `SAXON_JAR` is set.
|
|
62
|
+
|
|
63
|
+
== version
|
|
64
|
+
|
|
65
|
+
$ dcc version
|
|
66
|
+
|
|
67
|
+
Prints the installed gem version.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
= Getting Started with the dcc gem
|
|
2
|
+
|
|
3
|
+
This guide walks through the basics of parsing, validating, and converting
|
|
4
|
+
PTB Digital Calibration Certificates (DCC) in Ruby.
|
|
5
|
+
|
|
6
|
+
== Prerequisites
|
|
7
|
+
|
|
8
|
+
* Ruby 3.2 or newer
|
|
9
|
+
* The `dcc` gem installed (`gem install dcc`)
|
|
10
|
+
|
|
11
|
+
== Parsing your first DCC
|
|
12
|
+
|
|
13
|
+
[source,ruby]
|
|
14
|
+
----
|
|
15
|
+
require "dcc"
|
|
16
|
+
|
|
17
|
+
xml = File.read("certificate.xml")
|
|
18
|
+
dcc = Dcc.parse(xml)
|
|
19
|
+
|
|
20
|
+
puts dcc.class.name
|
|
21
|
+
# => Dcc::V3::DigitalCalibrationCertificate
|
|
22
|
+
|
|
23
|
+
puts dcc.schema_version
|
|
24
|
+
# => 3.3.0
|
|
25
|
+
|
|
26
|
+
puts dcc.administrative_data.core_data.unique_identifier
|
|
27
|
+
----
|
|
28
|
+
|
|
29
|
+
`Dcc.parse` auto-detects the schema version from the `schemaVersion`
|
|
30
|
+
attribute and routes to the correct major-version context
|
|
31
|
+
(`Dcc::V2::*` or `Dcc::V3::*`). Each major version has its own type
|
|
32
|
+
registry, so the two can coexist in one process.
|
|
33
|
+
|
|
34
|
+
== Validating
|
|
35
|
+
|
|
36
|
+
Three validators ship with the gem:
|
|
37
|
+
|
|
38
|
+
[source,ruby]
|
|
39
|
+
----
|
|
40
|
+
# XSD validation against the bundled v3.3.0 schema
|
|
41
|
+
result = Dcc::Validate::Xsd.call(xml, version: "3.3.0")
|
|
42
|
+
puts result.ok? # => true
|
|
43
|
+
puts result.errors.size
|
|
44
|
+
|
|
45
|
+
# Pure-Ruby Schematron (14 PTB patterns)
|
|
46
|
+
result = Dcc::Validate::Schematron.call(dcc)
|
|
47
|
+
|
|
48
|
+
# Ruby-side business rules (signer coverage, etc.)
|
|
49
|
+
result = Dcc::Validate::BusinessRules.call(dcc)
|
|
50
|
+
----
|
|
51
|
+
|
|
52
|
+
Every validator returns a `Dcc::Validate::Result` model with `to_s`,
|
|
53
|
+
`to_json`, and `to_yaml` for rendering.
|
|
54
|
+
|
|
55
|
+
== Converting
|
|
56
|
+
|
|
57
|
+
Four formats out of the box:
|
|
58
|
+
|
|
59
|
+
[source,ruby]
|
|
60
|
+
----
|
|
61
|
+
Dcc::Convert::Json.call(dcc).to_s # PTB-compatible JSON
|
|
62
|
+
Dcc::Convert::Yaml.call(dcc).to_s # YAML
|
|
63
|
+
Dcc::Convert::Csv.call(dcc).to_s # tabular CSV of quantities
|
|
64
|
+
Dcc::Convert::Html.call(dcc).to_s # human-readable HTML report
|
|
65
|
+
----
|
|
66
|
+
|
|
67
|
+
== Extracting
|
|
68
|
+
|
|
69
|
+
[source,ruby]
|
|
70
|
+
----
|
|
71
|
+
# Iterate embedded files (Ring-aware)
|
|
72
|
+
Dcc::Extract::File.each(dcc) do |f|
|
|
73
|
+
puts "#{f.file_name} (#{f.ring}): #{f.data.bytesize} bytes"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Parse MathML formulae to a Ruby AST
|
|
77
|
+
asts = Dcc::Extract::Formula.call(dcc)
|
|
78
|
+
asts.first.evaluate(T: BigDecimal("42.0"))
|
|
79
|
+
----
|
|
80
|
+
|
|
81
|
+
== Building
|
|
82
|
+
|
|
83
|
+
Construct a DCC programmatically with the Builder DSL:
|
|
84
|
+
|
|
85
|
+
[source,ruby]
|
|
86
|
+
----
|
|
87
|
+
dcc = Dcc.build(version: 3) do
|
|
88
|
+
administrative_data do
|
|
89
|
+
core_data do
|
|
90
|
+
unique_identifier "urn:uuid:abc-123"
|
|
91
|
+
country_code "DE"
|
|
92
|
+
used_lang "en"
|
|
93
|
+
mandatory_lang "en"
|
|
94
|
+
end
|
|
95
|
+
items { item(model: "Pt100") }
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
puts dcc.to_xml
|
|
100
|
+
----
|
|
101
|
+
|
|
102
|
+
== CLI
|
|
103
|
+
|
|
104
|
+
$ dcc validate xsd cert.xml
|
|
105
|
+
$ dcc convert json cert.xml -o cert.json
|
|
106
|
+
$ dcc inspect cert.xml
|
|
107
|
+
$ dcc extract files cert.xml
|
|
108
|
+
$ dcc diff a.xml b.xml
|
|
109
|
+
$ dcc version
|
|
110
|
+
|
|
111
|
+
== What's next
|
|
112
|
+
|
|
113
|
+
* `Dcc::QuantityMath` — BigDecimal arithmetic with uncertainty propagation
|
|
114
|
+
* `Dcc::QuantityFormat` — SmartCom-style pretty-printing
|
|
115
|
+
* `Dcc::Streaming::Reader` — pull-parser for large documents
|
|
116
|
+
* `Dcc::Server::App` — optional Sinatra REST API
|
|
117
|
+
* `Dcc::Plugin` — registry for custom validators / converters
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
= Schema Versions
|
|
2
|
+
|
|
3
|
+
The dcc gem ships bundled XSD and Schematron resources for every PTB
|
|
4
|
+
DCC release. Use `Dcc::Schema::Version` to query the registry.
|
|
5
|
+
|
|
6
|
+
== Bundled DCC XSDs
|
|
7
|
+
|
|
8
|
+
* v2.1.0, v2.1.1, v2.2.0, v2.3.0, v2.4.0
|
|
9
|
+
* v3.0.0, v3.1.0, v3.1.1, v3.1.2, v3.2.0, v3.2.1, v3.3.0
|
|
10
|
+
|
|
11
|
+
== Bundled D-SI XSDs
|
|
12
|
+
|
|
13
|
+
* v1.0.1, v1.3.0, v1.3.1
|
|
14
|
+
* v2.0.0, v2.1.0, v2.2.1
|
|
15
|
+
|
|
16
|
+
== Per-major-version class hierarchy
|
|
17
|
+
|
|
18
|
+
The gem follows the registry-aware pattern proven in `plurimath/mml`:
|
|
19
|
+
each major DCC version gets its own module namespace and type registry.
|
|
20
|
+
|
|
21
|
+
* `Dcc::V2::*` registers in `:dcc_v2` — legacy, no `refId`/`refType`,
|
|
22
|
+
imports D-SI v1.x
|
|
23
|
+
* `Dcc::V3::*` registers in `:dcc_v3` — modern, with `refId`/`refType`
|
|
24
|
+
and D-SI v2.x. Includes v3.4.0-rc.2 features as optional attributes.
|
|
25
|
+
|
|
26
|
+
The two registries are isolated, so a single Ruby process can parse
|
|
27
|
+
both v2 and v3 documents without symbol clashes.
|
|
28
|
+
|
|
29
|
+
== D-SI namespaces
|
|
30
|
+
|
|
31
|
+
* `Dcc::Si::V1::*` registers in `:dsi_v1`
|
|
32
|
+
* `Dcc::Si::V2::*` registers in `:dsi_v2`
|
|
33
|
+
|
|
34
|
+
When parsing a v3 DCC, the v3 context re-exports D-SI v2 types so that
|
|
35
|
+
`dcc:quantity` children (`si:real`, `si:hybrid`, `si:realListXMLList`,
|
|
36
|
+
etc.) resolve to their typed classes without a context switch.
|
|
37
|
+
|
|
38
|
+
== Resolving versions programmatically
|
|
39
|
+
|
|
40
|
+
[source,ruby]
|
|
41
|
+
----
|
|
42
|
+
Dcc::Schema::Version::DCC_LATEST # => "3.3.0"
|
|
43
|
+
Dcc::Schema::Version::DSI_LATEST # => "2.2.1"
|
|
44
|
+
Dcc::Schema::Version.dcc?("3.3.0") # => true
|
|
45
|
+
Dcc::Schema::Version.major("2.3.0") # => 2
|
|
46
|
+
|
|
47
|
+
# Auto-detect from XML
|
|
48
|
+
xml = File.read("cert.xml")
|
|
49
|
+
Dcc::Schema::Version.resolve_dcc(:auto, xml: xml) # => "3.3.0"
|
|
50
|
+
----
|
|
51
|
+
|
|
52
|
+
== Migration
|
|
53
|
+
|
|
54
|
+
Use `Dcc.migrate` to upgrade or downgrade between schema versions:
|
|
55
|
+
|
|
56
|
+
[source,ruby]
|
|
57
|
+
----
|
|
58
|
+
dcc = Dcc.parse(File.read("v3.xml"))
|
|
59
|
+
migrated = Dcc.migrate(dcc, from: "3.3.0", to: "3.2.1")
|
|
60
|
+
puts migrated.schema_version # => 3.2.1
|
|
61
|
+
----
|
|
62
|
+
|
|
63
|
+
Cross-major migration (e.g. v2 → v3) serializes the source DCC and
|
|
64
|
+
re-parses it under the target version's context. Same-major just
|
|
65
|
+
rewrites the `schemaVersion` attribute in place.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Build a minimal DCC programmatically using the Builder DSL.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# bundle exec examples/build_minimal_dcc.rb
|
|
8
|
+
|
|
9
|
+
require "dcc"
|
|
10
|
+
|
|
11
|
+
dcc = Dcc.build(version: 3) do
|
|
12
|
+
administrative_data do
|
|
13
|
+
core_data do
|
|
14
|
+
unique_identifier "urn:uuid:00000000-0000-0000-0000-000000000001"
|
|
15
|
+
country_code "DE"
|
|
16
|
+
used_lang "en"
|
|
17
|
+
mandatory_lang "en"
|
|
18
|
+
end
|
|
19
|
+
items { item(model: "Demo Pt100") }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
puts dcc.to_xml
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Convert a DCC XML file to JSON, YAML, CSV, and HTML in one go.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# bundle exec examples/convert_all_formats.rb path/to/dcc.xml
|
|
8
|
+
|
|
9
|
+
require "dcc"
|
|
10
|
+
|
|
11
|
+
path = ARGV[0] || File.expand_path("../spec/fixtures/dcclib/valid.xml", __dir__)
|
|
12
|
+
dcc = Dcc.parse(File.read(path))
|
|
13
|
+
|
|
14
|
+
[Dcc::Convert::Json, Dcc::Convert::Yaml, Dcc::Convert::Csv, Dcc::Convert::Html].each do |service|
|
|
15
|
+
result = service.call(dcc)
|
|
16
|
+
puts "== #{service.name.split('::').last} =="
|
|
17
|
+
puts result.to_s[0, 200] + "..."
|
|
18
|
+
puts
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Parse a DCC XML file and print the uniqueIdentifier + country.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# bundle exec examples/parse_and_inspect.rb path/to/dcc.xml
|
|
8
|
+
|
|
9
|
+
require "dcc"
|
|
10
|
+
|
|
11
|
+
path = ARGV[0] || File.expand_path("../spec/fixtures/dcclib/valid.xml", __dir__)
|
|
12
|
+
dcc = Dcc.parse(File.read(path))
|
|
13
|
+
|
|
14
|
+
puts "Class: #{dcc.class.name}"
|
|
15
|
+
puts "Schema version: #{dcc.schema_version}"
|
|
16
|
+
puts "Unique identifier: #{dcc.administrative_data.core_data.unique_identifier}"
|
|
17
|
+
puts "Country: #{dcc.administrative_data.core_data.country_code_iso_3166_1}"
|
|
18
|
+
puts "Items: #{dcc.administrative_data.items.item.size}"
|
|
19
|
+
puts "Measurement results: #{dcc.measurement_results.measurement_result.size}"
|