pkm_level2_converter 0.1.2 → 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 +4 -4
- data/.gitignore +0 -2
- data/Gemfile.lock +39 -38
- data/lib/pkm_level2_converter/version.rb +1 -1
- data/lib/pkm_level2_converter.rb +80 -12
- metadata +3 -5
- data/lib/conv_PV_KM.rb +0 -75
- data/lib/conv_RN_TM.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97c43176a6dc371c0603050b13f197d0ba563aa1cc0259a9fc9749db2b7f9a56
|
4
|
+
data.tar.gz: 7e01836579a624c1066cac0e0e49710fff71f8910f5da1155965e4be18ba70a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 826a1cf5808b3ce435128532809e26555a4dee14e62fc54921dddce269eef0bc2c06759a606d64ac1c737d1c0660135ffeeaf40138b56e11bd471b98bd8143d6
|
7
|
+
data.tar.gz: f5b359813d967af6db08445b308cd59227edfb022fc5270e36121e00a5b683001adabb8b715225d5a3d0aca1d91eaa5c6f005ffcfaa85d168154baf0d8453fa9
|
data/Gemfile.lock
CHANGED
@@ -1,38 +1,39 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pkm_level2_converter (0.
|
5
|
-
nokogiri (~> 1.10.4)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
diff-lcs (1.
|
11
|
-
mini_portile2 (2.4.0)
|
12
|
-
nokogiri (1.10.10
|
13
|
-
mini_portile2 (~> 2.4.0)
|
14
|
-
rake (13.0.
|
15
|
-
rspec (3.
|
16
|
-
rspec-core (~> 3.
|
17
|
-
rspec-expectations (~> 3.
|
18
|
-
rspec-mocks (~> 3.
|
19
|
-
rspec-core (3.
|
20
|
-
rspec-support (~> 3.
|
21
|
-
rspec-expectations (3.
|
22
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-mocks (3.
|
25
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-support (3.
|
28
|
-
|
29
|
-
PLATFORMS
|
30
|
-
x64-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pkm_level2_converter (0.2.0)
|
5
|
+
nokogiri (~> 1.10.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
mini_portile2 (2.4.0)
|
12
|
+
nokogiri (1.10.10)
|
13
|
+
mini_portile2 (~> 2.4.0)
|
14
|
+
rake (13.0.6)
|
15
|
+
rspec (3.12.0)
|
16
|
+
rspec-core (~> 3.12.0)
|
17
|
+
rspec-expectations (~> 3.12.0)
|
18
|
+
rspec-mocks (~> 3.12.0)
|
19
|
+
rspec-core (3.12.0)
|
20
|
+
rspec-support (~> 3.12.0)
|
21
|
+
rspec-expectations (3.12.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.12.0)
|
24
|
+
rspec-mocks (3.12.3)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.12.0)
|
27
|
+
rspec-support (3.12.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
x64-mingw-ucrt
|
31
|
+
x64-mingw32
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
pkm_level2_converter!
|
35
|
+
rake (~> 13.0)
|
36
|
+
rspec (~> 3.2)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
2.2.20
|
data/lib/pkm_level2_converter.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'nokogiri'
|
3
|
+
require 'pathname'
|
3
4
|
require_relative "pkm_level2_converter/version"
|
4
5
|
|
5
6
|
module PkmLevel2Converter
|
@@ -14,17 +15,13 @@ module PkmLevel2Converter
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def convertFileName()
|
17
|
-
|
18
|
-
|
19
|
-
f =
|
20
|
-
#puts f
|
18
|
+
pn = Pathname.new(@filename)
|
19
|
+
dir, base = File.split(pn)
|
20
|
+
f = base.split('_')
|
21
21
|
org_id_l3 = f[1].to_i
|
22
|
-
#puts org_id_l3
|
23
22
|
org_id_l2 = org_id_l3 + 0x8000
|
24
|
-
#puts org_id_l2
|
25
23
|
f[1] = org_id_l2.to_s
|
26
|
-
|
27
|
-
return f.join("_")
|
24
|
+
return Pathname.new(dir).join(f.join("_"))
|
28
25
|
end
|
29
26
|
|
30
27
|
def save_file(file)
|
@@ -56,7 +53,17 @@ module PkmLevel2Converter
|
|
56
53
|
orig_file_name = @filename
|
57
54
|
if File.file?(orig_file_name)
|
58
55
|
@xml_doc = File.open(orig_file_name) { |f| Nokogiri::XML(f) }
|
59
|
-
|
56
|
+
case @xml_doc.root.name
|
57
|
+
when "pv-km"
|
58
|
+
convert_ids_pvkm
|
59
|
+
when "dl-km"
|
60
|
+
convert_ids_dlkm
|
61
|
+
when "rntm"
|
62
|
+
convert_ids_rntm
|
63
|
+
else
|
64
|
+
puts(@xml_doc.root.name + " wird nicht unterstützt.")
|
65
|
+
end
|
66
|
+
|
60
67
|
if xml_is_valid_pkm(@xml_doc)
|
61
68
|
save_file(@xml_doc)
|
62
69
|
end
|
@@ -67,7 +74,18 @@ module PkmLevel2Converter
|
|
67
74
|
|
68
75
|
def xml_is_valid_pkm(xml)
|
69
76
|
#xsd = File.read("./ka/pkm/1/XML-Schema_PKM.xsd")
|
70
|
-
|
77
|
+
path=''
|
78
|
+
case @xml_doc.root.name
|
79
|
+
when "pv-km"
|
80
|
+
path = './pkm_level2_converter/ka/pkm/1/XML-Schema_PKM.xsd'
|
81
|
+
when "dl-km"
|
82
|
+
path = './pkm_level2_converter/ka/pkm/1/XML-Schema_PKM.xsd'
|
83
|
+
when "rntm"
|
84
|
+
path = './pkm_level2_converter/ka/pkm/2/XML-Schema_PKM.xsd'
|
85
|
+
end
|
86
|
+
|
87
|
+
file_path = File.join(File.dirname(__FILE__), path)
|
88
|
+
|
71
89
|
xsd = File.read(file_path)
|
72
90
|
return self.check_xsd(xsd,xml)
|
73
91
|
end
|
@@ -78,7 +96,7 @@ module PkmLevel2Converter
|
|
78
96
|
map.content = (id + 0x8000).to_s
|
79
97
|
end
|
80
98
|
|
81
|
-
def
|
99
|
+
def convert_ids_dlkm
|
82
100
|
#Organisations-ID des DL:
|
83
101
|
#dl-km/organisation/id
|
84
102
|
convert_xpath_l3_id(@xml_doc, 'xmlns:dl-km/xmlns:organisation/xmlns:id')
|
@@ -101,7 +119,57 @@ module PkmLevel2Converter
|
|
101
119
|
#Für Anzeige von KVP als Klartext:
|
102
120
|
#dl-km/kontrollmodul-pool/item/moduldaten/nummerninterpretation-pool/item[nr=2]/nummerntext-pool/item/nr
|
103
121
|
end
|
104
|
-
|
122
|
+
|
123
|
+
def convert_ids_pvkm
|
124
|
+
#Organisations-ID des DL:
|
125
|
+
#dl-km/organisation/id
|
126
|
+
# convert_xpath_l3_id(@xml_doc, 'xmlns:dl-km/xmlns:organisation/xmlns:id')
|
127
|
+
# puts "Converted following IDs:"
|
128
|
+
# puts "/dl-km/organisation/id = " + @xml_doc.xpath('/xmlns:dl-km/xmlns:organisation/xmlns:id').text
|
129
|
+
|
130
|
+
# @xml_doc.xpath('/xmlns:dl-km/xmlns:kontrollmodul-pool/xmlns:item').each do |node|
|
131
|
+
node = @xml_doc.xpath('/xmlns:pv-km')
|
132
|
+
#Organisations-ID des PV:
|
133
|
+
#dl-km/kontrollmodul-pool/item/moduldaten/organisation/id
|
134
|
+
# convert_xpath_l3_id(node, '/xmlns:pv-km/xmlns:organisation/xmlns:id')
|
135
|
+
convert_xpath_l3_id(node, 'xmlns:organisation/xmlns:id')
|
136
|
+
puts "# pv-km/organisation/id = " + node.xpath('xmlns:organisation/xmlns:id').text
|
137
|
+
#Für PVKM zulässige Organisations-IDs der DL:
|
138
|
+
#dl-km/kontrollmodul-pool/item/moduldaten/organisation-pool/item/id
|
139
|
+
node.xpath('xmlns:organisation-pool/xmlns:item').each do |child|
|
140
|
+
convert_xpath_l3_id(child, 'xmlns:id')
|
141
|
+
puts "## pv-km/organisation-pool/item/id = " + child.xpath('xmlns:id').text
|
142
|
+
end
|
143
|
+
# end
|
144
|
+
#Für Anzeige von KVP als Klartext:
|
145
|
+
#dl-km/kontrollmodul-pool/item/moduldaten/nummerninterpretation-pool/item[nr=2]/nummerntext-pool/item/nr
|
146
|
+
end
|
147
|
+
|
148
|
+
def convert_ids_rntm
|
149
|
+
#Organisations-ID des RN:
|
150
|
+
#rntm/herausgeber/nr
|
151
|
+
convert_xpath_l3_id(@xml_doc, 'xmlns:rntm/xmlns:herausgeber/xmlns:nr')
|
152
|
+
puts "Converted following IDs:"
|
153
|
+
puts "rntm/herausgeber/nr = " + @xml_doc.xpath('xmlns:rntm/xmlns:herausgeber/xmlns:nr').text
|
154
|
+
|
155
|
+
@xml_doc.xpath('/xmlns:rntm/xmlns:tarifmodul-pool/xmlns:item').each do |node|
|
156
|
+
|
157
|
+
#Organisations-ID des PV:
|
158
|
+
#dl-km/kontrollmodul-pool/item/moduldaten/organisation/id
|
159
|
+
|
160
|
+
convert_xpath_l3_id(node, 'xmlns:tarifmodul/xmlns:herausgeber/xmlns:nr')
|
161
|
+
puts "# /rntm/tarifmodul-pool/item/tarifmodul/herausgeber/nr/ = " + node.xpath('xmlns:tarifmodul/xmlns:herausgeber/xmlns:nr').text
|
162
|
+
#Für PVKM zulässige Organisations-IDs der DL:
|
163
|
+
#dl-km/kontrollmodul-pool/item/moduldaten/organisation-pool/item/id
|
164
|
+
node.xpath('xmlns:tarifmodul/xmlns:organisation-pool/xmlns:item').each do |child|
|
165
|
+
convert_xpath_l3_id(child, 'xmlns:nr')
|
166
|
+
puts "## /rntm/tarifmodul-pool/item/tarifmodul/organisation-pool/item/nr = " + child.xpath('xmlns:nr').text
|
167
|
+
end
|
168
|
+
end
|
169
|
+
#Für Anzeige von KVP als Klartext:
|
170
|
+
#dl-km/kontrollmodul-pool/item/moduldaten/nummerninterpretation-pool/item[nr=2]/nummerntext-pool/item/nr
|
171
|
+
end
|
172
|
+
|
105
173
|
end
|
106
174
|
|
107
175
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pkm_level2_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Doege
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -57,8 +57,6 @@ files:
|
|
57
57
|
- bin/console
|
58
58
|
- bin/setup
|
59
59
|
- exe/pkmlevel2
|
60
|
-
- lib/conv_PV_KM.rb
|
61
|
-
- lib/conv_RN_TM.rb
|
62
60
|
- lib/pkm_level2_converter.rb
|
63
61
|
- lib/pkm_level2_converter/ka/pkm/1/XML-Schema_PKM.xsd
|
64
62
|
- lib/pkm_level2_converter/ka/pkm/1/XML-Schema_PKM_TX.xsd
|
@@ -89,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
87
|
- !ruby/object:Gem::Version
|
90
88
|
version: '0'
|
91
89
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
90
|
+
rubygems_version: 3.3.7
|
93
91
|
signing_key:
|
94
92
|
specification_version: 4
|
95
93
|
summary: Converts PKM modules for testing
|
data/lib/conv_PV_KM.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
#require 'pry'
|
3
|
-
require_relative 'check_xsd'
|
4
|
-
|
5
|
-
def convertFileName(file_name)
|
6
|
-
f = file_name.split('_')
|
7
|
-
org_id_l3 = f[1].to_i
|
8
|
-
org_id_l2 = org_id_l3 + 0x8000
|
9
|
-
f[1] = org_id_l2.to_s
|
10
|
-
return f.join("_")
|
11
|
-
end
|
12
|
-
|
13
|
-
def safe_file(file, new_file_name)
|
14
|
-
#SAVE FILE with NEW name
|
15
|
-
output = File.open( new_file_name, "w" )
|
16
|
-
output << file.to_xml(:indent_text => "", :indent => 0).gsub(/>\n/,">")
|
17
|
-
output.close
|
18
|
-
puts "File saved as: #{new_file_name}"
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def convert_pkm(orig_file_name)
|
23
|
-
if File.file?(orig_file_name)
|
24
|
-
new_file_name = convertFileName(orig_file_name)
|
25
|
-
@xml_doc = File.open(orig_file_name) { |f| Nokogiri::XML(f) }
|
26
|
-
convert_ids
|
27
|
-
if xml_is_valid_pkm(@xml_doc)
|
28
|
-
safe_file(@xml_doc, new_file_name)
|
29
|
-
end
|
30
|
-
else
|
31
|
-
puts "File ('#{orig_file_name}') not found."
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def xml_is_valid_pkm(xml)
|
36
|
-
#xsd = File.read("./ka/pkm/1/XML-Schema_PKM.xsd")
|
37
|
-
file_path = File.join(File.dirname(__FILE__), './ka/pkm/1/XML-Schema_PKM.xsd')
|
38
|
-
xsd = File.read(file_path)
|
39
|
-
return check_xsd(xsd,xml)
|
40
|
-
end
|
41
|
-
|
42
|
-
def convert_xpath_l3_id(node, x_path)
|
43
|
-
map = node.at_xpath x_path
|
44
|
-
id = map.content.to_i
|
45
|
-
map.content = (id + 0x8000).to_s
|
46
|
-
end
|
47
|
-
|
48
|
-
def convert_ids
|
49
|
-
#Organisations-ID des DL:
|
50
|
-
#dl-km/organisation/id
|
51
|
-
# convert_xpath_l3_id(@xml_doc, 'xmlns:dl-km/xmlns:organisation/xmlns:id')
|
52
|
-
# puts "Converted following IDs:"
|
53
|
-
# puts "/dl-km/organisation/id = " + @xml_doc.xpath('/xmlns:dl-km/xmlns:organisation/xmlns:id').text
|
54
|
-
|
55
|
-
# @xml_doc.xpath('/xmlns:dl-km/xmlns:kontrollmodul-pool/xmlns:item').each do |node|
|
56
|
-
node = @xml_doc.xpath('/xmlns:pv-km')
|
57
|
-
#Organisations-ID des PV:
|
58
|
-
#dl-km/kontrollmodul-pool/item/moduldaten/organisation/id
|
59
|
-
# convert_xpath_l3_id(node, '/xmlns:pv-km/xmlns:organisation/xmlns:id')
|
60
|
-
convert_xpath_l3_id(node, 'xmlns:organisation/xmlns:id')
|
61
|
-
puts "# pv-km/organisation/id = " + node.xpath('xmlns:organisation/xmlns:id').text
|
62
|
-
#Für PVKM zulässige Organisations-IDs der DL:
|
63
|
-
#dl-km/kontrollmodul-pool/item/moduldaten/organisation-pool/item/id
|
64
|
-
node.xpath('xmlns:organisation-pool/xmlns:item').each do |child|
|
65
|
-
convert_xpath_l3_id(child, 'xmlns:id')
|
66
|
-
puts "## pv-km/organisation-pool/item/id = " + child.xpath('xmlns:id').text
|
67
|
-
end
|
68
|
-
# end
|
69
|
-
#Für Anzeige von KVP als Klartext:
|
70
|
-
#dl-km/kontrollmodul-pool/item/moduldaten/nummerninterpretation-pool/item[nr=2]/nummerntext-pool/item/nr
|
71
|
-
end
|
72
|
-
|
73
|
-
orig_file_name = ARGV.first
|
74
|
-
convert_pkm(orig_file_name)
|
75
|
-
|
data/lib/conv_RN_TM.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
#require 'pry'
|
3
|
-
require_relative 'check_xsd'
|
4
|
-
|
5
|
-
def convertFileName(file_name)
|
6
|
-
f = file_name.split('_')
|
7
|
-
org_id_l3 = f[1].to_i
|
8
|
-
org_id_l2 = org_id_l3 + 0x8000
|
9
|
-
f[1] = org_id_l2.to_s
|
10
|
-
return f.join("_")
|
11
|
-
end
|
12
|
-
|
13
|
-
def safe_file(file, new_file_name)
|
14
|
-
#SAVE FILE with NEW name
|
15
|
-
output = File.open( new_file_name, "w" )
|
16
|
-
output << file.to_xml(:indent_text => "", :indent => 0).gsub(/>\n/,">")
|
17
|
-
output.close
|
18
|
-
puts "File saved as: #{new_file_name}"
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def convert_pkm(orig_file_name)
|
23
|
-
if File.file?(orig_file_name)
|
24
|
-
new_file_name = convertFileName(orig_file_name)
|
25
|
-
@xml_doc = File.open(orig_file_name) { |f| Nokogiri::XML(f) }
|
26
|
-
convert_ids
|
27
|
-
if xml_is_valid_pkm(@xml_doc)
|
28
|
-
safe_file(@xml_doc, new_file_name)
|
29
|
-
end
|
30
|
-
else
|
31
|
-
puts "File ('#{orig_file_name}') not found."
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def xml_is_valid_pkm(xml)
|
36
|
-
xsd = File.read("ka/pkm/2/XML-Schema_PKM.xsd")
|
37
|
-
return check_xsd(xsd,xml)
|
38
|
-
end
|
39
|
-
|
40
|
-
def convert_xpath_l3_id(node, x_path)
|
41
|
-
map = node.at_xpath x_path
|
42
|
-
id = map.content.to_i
|
43
|
-
map.content = (id + 0x8000).to_s
|
44
|
-
end
|
45
|
-
|
46
|
-
def convert_ids
|
47
|
-
#Organisations-ID des RN:
|
48
|
-
#rntm/herausgeber/nr
|
49
|
-
convert_xpath_l3_id(@xml_doc, 'xmlns:rntm/xmlns:herausgeber/xmlns:nr')
|
50
|
-
puts "Converted following IDs:"
|
51
|
-
puts "rntm/herausgeber/nr = " + @xml_doc.xpath('xmlns:rntm/xmlns:herausgeber/xmlns:nr').text
|
52
|
-
|
53
|
-
@xml_doc.xpath('/xmlns:rntm/xmlns:tarifmodul-pool/xmlns:item').each do |node|
|
54
|
-
|
55
|
-
#Organisations-ID des PV:
|
56
|
-
#dl-km/kontrollmodul-pool/item/moduldaten/organisation/id
|
57
|
-
|
58
|
-
convert_xpath_l3_id(node, 'xmlns:tarifmodul/xmlns:herausgeber/xmlns:nr')
|
59
|
-
puts "# /rntm/tarifmodul-pool/item/tarifmodul/herausgeber/nr/ = " + node.xpath('xmlns:tarifmodul/xmlns:herausgeber/xmlns:nr').text
|
60
|
-
#Für PVKM zulässige Organisations-IDs der DL:
|
61
|
-
#dl-km/kontrollmodul-pool/item/moduldaten/organisation-pool/item/id
|
62
|
-
node.xpath('xmlns:tarifmodul/xmlns:organisation-pool/xmlns:item').each do |child|
|
63
|
-
convert_xpath_l3_id(child, 'xmlns:nr')
|
64
|
-
puts "## /rntm/tarifmodul-pool/item/tarifmodul/organisation-pool/item/nr = " + child.xpath('xmlns:nr').text
|
65
|
-
end
|
66
|
-
end
|
67
|
-
#Für Anzeige von KVP als Klartext:
|
68
|
-
#dl-km/kontrollmodul-pool/item/moduldaten/nummerninterpretation-pool/item[nr=2]/nummerntext-pool/item/nr
|
69
|
-
end
|
70
|
-
|
71
|
-
orig_file_name = ARGV.first
|
72
|
-
convert_pkm(orig_file_name)
|
73
|
-
|