zugpferd 0.3.3 → 0.3.4

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/setup-schemas +28 -20
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5f92588b928e3ddebb536ee082e58b47f25b078defb969d0407c9ad5f86ec2e
4
- data.tar.gz: 8375975a159bc34c31a9dc7231dd64567faf31bec021c51311b4453e7dc7cbbb
3
+ metadata.gz: 62856c1301920bbea44b64a360effeee49572cc5d0563a3585a57821f97a855d
4
+ data.tar.gz: e1a60440693e9a66f089a5469643d5b9089f1e9e97d2387a415a1fea82420e02
5
5
  SHA512:
6
- metadata.gz: a8a4faadffd2c53608959f6610f7aae35513eb262a885da430ac22cc248069c0ac9ed41828cd84e27b0f56f662c557a1310a4100cb08d1e3ff1732f7dc6049af
7
- data.tar.gz: dfe0208222f0ef32c181ba27718b82a0d30474894c4c3fe1d16043fb059cfe7d3827f20ffc2f8d4cbec3dc4028c90369a50337e032906b8df7ccfeab21753576
6
+ metadata.gz: f0f5da629eeeda2b93ec71a4398ea9cdec486742bf43a8871d663afe06498eea56ad4356e98638fbeb613aaca77e8301f48e62ffc1056c277be3f14651b570bf
7
+ data.tar.gz: 8b26ca18cd6dd8c1ecffc18d465e71796e152ec3ca29e25600627804b119dab8cf962e211937c1eb9ae8e6dcf11e75a5e423a129b6e843f622e84c3381841a79
data/bin/setup-schemas CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- VENDOR_DIR="$(cd "$(dirname "$0")/../vendor" && pwd)"
4
+ VENDOR_DIR="$(pwd)/vendor"
5
5
  SCHEMAS_DIR="$VENDOR_DIR/schemas"
6
6
  TMP_DIR=$(mktemp -d)
7
7
  trap 'rm -rf "$TMP_DIR"' EXIT
8
8
 
9
9
  CURL_UA="Mozilla/5.0"
10
+ ZUGPFERD_REPO="https://github.com/alexzeitler/zugpferd"
10
11
 
11
12
  # --- Saxon HE (for Schematron validation) ---
12
13
 
@@ -45,9 +46,8 @@ if [ ! -d "$UBL_DIR/xsd/maindoc" ]; then
45
46
  echo " Downloading UBL-2.1.zip..."
46
47
  curl -fsSL -A "$CURL_UA" "http://docs.oasis-open.org/ubl/os-UBL-2.1/UBL-2.1.zip" \
47
48
  -o "$TMP_DIR/UBL-2.1.zip"
48
- mkdir -p "$UBL_DIR/xsd"
49
- unzip -qo "$TMP_DIR/UBL-2.1.zip" "os-UBL-2.1/xsd/*" -d "$TMP_DIR"
50
- cp -r "$TMP_DIR/os-UBL-2.1/xsd/"* "$UBL_DIR/xsd/"
49
+ mkdir -p "$UBL_DIR"
50
+ unzip -qo "$TMP_DIR/UBL-2.1.zip" "xsd/*" -d "$UBL_DIR"
51
51
  else
52
52
  echo " UBL XSD already present"
53
53
  fi
@@ -61,23 +61,31 @@ CII_DIR="$SCHEMAS_DIR/cii"
61
61
 
62
62
  if [ ! -f "$CII_DIR/CrossIndustryInvoice_100pD16B.xsd" ]; then
63
63
  echo " Downloading D16B SCRDM (Subset) CII..."
64
- CII_URL="https://unece.org/fileadmin/DAM/cefact/xml_schemas/D16B_SCRDM__Subset__CII.zip"
65
- curl -fsSL -A "$CURL_UA" "$CII_URL" -o "$TMP_DIR/cii-outer.zip" || {
66
- echo " WARN: Could not download CII XSD from UN/CEFACT."
67
- echo " Download manually from: $CII_URL"
68
- echo " Extract the 'uncoupled' XSD files into $CII_DIR/"
69
- }
70
-
71
- if [ -f "$TMP_DIR/cii-outer.zip" ]; then
72
- mkdir -p "$CII_DIR"
73
- unzip -qo "$TMP_DIR/cii-outer.zip" -d "$TMP_DIR/cii-outer"
74
- # The outer ZIP contains nested ZIPs extract the uncoupled one
75
- UNCOUPLED_ZIP=$(find "$TMP_DIR/cii-outer" -name "*uncoupled.zip" -type f | head -1)
76
- if [ -n "$UNCOUPLED_ZIP" ]; then
77
- unzip -qo "$UNCOUPLED_ZIP" -d "$CII_DIR"
64
+ CII_URL="$ZUGPFERD_REPO/releases/download/v0.3.3/D16B_SCRDM__Subset__CII.zip"
65
+ curl -fsSL -A "$CURL_UA" "$CII_URL" -o "$TMP_DIR/cii-outer.zip"
66
+
67
+ mkdir -p "$CII_DIR"
68
+ unzip -qo "$TMP_DIR/cii-outer.zip" -d "$TMP_DIR/cii-outer"
69
+ # The outer ZIP contains nested ZIPs — extract the uncoupled one
70
+ UNCOUPLED_ZIP=$(find "$TMP_DIR/cii-outer" -name "*uncoupled.zip" -type f | head -1)
71
+ if [ -n "$UNCOUPLED_ZIP" ]; then
72
+ unzip -qo "$UNCOUPLED_ZIP" -d "$TMP_DIR/cii-uncoupled"
73
+ # XSDs are nested deep — move them flat into CII_DIR
74
+ XSD_DIR=$(find "$TMP_DIR/cii-uncoupled" -name "CrossIndustryInvoice_100pD16B.xsd" -type f -exec dirname {} \; | head -1)
75
+ if [ -n "$XSD_DIR" ]; then
76
+ cp -r "$XSD_DIR"/* "$CII_DIR/"
77
+ # Copy codelist XSDs (relative imports from main XSD)
78
+ CODELIST_DIR=$(find "$TMP_DIR/cii-uncoupled" -type d -name "codelist" | head -1)
79
+ if [ -n "$CODELIST_DIR" ]; then
80
+ cp -r "$CODELIST_DIR" "$CII_DIR/"
81
+ fi
78
82
  else
79
- echo " WARN: Could not find uncoupled ZIP inside CII archive"
83
+ echo " ERROR: Could not find CrossIndustryInvoice_100pD16B.xsd in extracted archive"
84
+ exit 1
80
85
  fi
86
+ else
87
+ echo " ERROR: Could not find uncoupled ZIP inside CII archive"
88
+ exit 1
81
89
  fi
82
90
  else
83
91
  echo " CII XSD already present"
@@ -122,7 +130,7 @@ XR_DIR="$SCHEMAS_DIR/schematron/xrechnung"
122
130
 
123
131
  if [ ! -f "$XR_DIR/schematron/ubl/XRechnung-UBL-validation.xsl" ]; then
124
132
  echo " Downloading xrechnung-$XRECHNUNG_SPEC_VERSION-schematron-$XRECHNUNG_SCHEMATRON_VERSION.zip..."
125
- curl -fsSL -A "$CURL_UA" "https://github.com/itplr-kosit/xrechnung-schematron/releases/download/release-$XRECHNUNG_SCHEMATRON_VERSION/xrechnung-$XRECHNUNG_SPEC_VERSION-schematron-$XRECHNUNG_SCHEMATRON_VERSION.zip" \
133
+ curl -fsSL -A "$CURL_UA" "https://github.com/itplr-kosit/xrechnung-schematron/releases/download/v$XRECHNUNG_SCHEMATRON_VERSION/xrechnung-$XRECHNUNG_SPEC_VERSION-schematron-$XRECHNUNG_SCHEMATRON_VERSION.zip" \
126
134
  -o "$TMP_DIR/xrechnung-schematron.zip"
127
135
  mkdir -p "$XR_DIR"
128
136
  unzip -qo "$TMP_DIR/xrechnung-schematron.zip" -d "$XR_DIR"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zugpferd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Zeitler