oddb2xml 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.standard.yml +2 -0
- data/Gemfile +3 -3
- data/History.txt +8 -0
- data/README.md +1 -1
- data/Rakefile +24 -23
- data/bin/check_artikelstamm +11 -11
- data/bin/compare_v5 +23 -23
- data/bin/oddb2xml +14 -13
- data/lib/oddb2xml.rb +1 -1
- data/lib/oddb2xml/builder.rb +1070 -1038
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -236
- data/lib/oddb2xml/compare.rb +70 -59
- data/lib/oddb2xml/compositions_syntax.rb +448 -430
- data/lib/oddb2xml/compressor.rb +20 -20
- data/lib/oddb2xml/downloader.rb +153 -127
- data/lib/oddb2xml/extractor.rb +302 -289
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +263 -269
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +163 -163
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/oddb2xml.gemspec +31 -32
- data/spec/artikelstamm_spec.rb +111 -110
- data/spec/builder_spec.rb +489 -505
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +173 -174
- data/spec/compare_spec.rb +9 -11
- data/spec/composition_syntax_spec.rb +390 -409
- data/spec/compressor_spec.rb +48 -48
- data/spec/data/transfer.dat +1 -0
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +247 -260
- data/spec/extractor_spec.rb +171 -159
- data/spec/galenic_spec.rb +233 -256
- data/spec/options_spec.rb +116 -119
- data/spec/parslet_spec.rb +833 -861
- data/spec/spec_helper.rb +154 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +19 -3
data/spec/spec_helper.rb
CHANGED
@@ -5,125 +5,125 @@
|
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
#
|
8
|
-
$:.unshift File.join(File.dirname(__FILE__),
|
8
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
9
9
|
$:.unshift File.dirname(__FILE__)
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
11
|
+
require "rspec"
|
12
|
+
require "webmock/rspec"
|
13
|
+
require "flexmock/rspec"
|
14
|
+
require "pp"
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# load pry if is available
|
17
|
+
begin
|
18
|
+
require "pry"
|
19
|
+
Pry.config.output = $stdout
|
19
20
|
rescue LoadError
|
20
21
|
end
|
21
22
|
|
22
|
-
require
|
23
|
-
require
|
23
|
+
require "vcr"
|
24
|
+
require "timecop"
|
24
25
|
|
25
26
|
module Oddb2xml
|
26
27
|
# we override here a few directories to make input/output when running specs to
|
27
28
|
# be in different places compared when running
|
28
|
-
SpecData
|
29
|
-
|
30
|
-
|
31
|
-
SpecCompressor = File.join(Oddb2xml::SpecData,
|
32
|
-
DATE_REGEXP
|
29
|
+
SpecData = File.join(File.dirname(__FILE__), "data")
|
30
|
+
WORK_DIR = File.join(File.dirname(__FILE__), "run")
|
31
|
+
DOWNLOADS = File.join(WORK_DIR, "downloads")
|
32
|
+
SpecCompressor = File.join(Oddb2xml::SpecData, "compressor")
|
33
|
+
DATE_REGEXP = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[-+]\d{4}/
|
33
34
|
|
34
35
|
GTINS_CALC = [
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
FRIDGE_GTIN =
|
50
|
-
ORPHAN_GTIN =
|
51
|
-
GTINS_DRUGS = [
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
36
|
+
"7680458820202", # for calc_spec.rb
|
37
|
+
"7680555940018", # for calc_spec.rb
|
38
|
+
"7680434541015", # for calc_spec.rb
|
39
|
+
"7680300150105", # for calc_spec.rb
|
40
|
+
"7680446250592", # for calc_spec.rb
|
41
|
+
"7680611860045", # for calc_spec.rb
|
42
|
+
"7680165980114", # for calc_spec.rb
|
43
|
+
"7680589430011", # for calc_spec.rb
|
44
|
+
"7680556740075", # for calc_spec.rb
|
45
|
+
"7680540151009", # for calc_spec.rb
|
46
|
+
"7680560890018", # for calc_spec.rb
|
47
|
+
"7680532900196", # Insulin, gentechnik
|
48
|
+
"7680555610041" # Diaphin 10 g i.v. drug
|
49
|
+
]
|
50
|
+
FRIDGE_GTIN = "7680002770014" # fridge drug 7680002770014 Coeur-Vaisseaux Sérocytol, suppositoire
|
51
|
+
ORPHAN_GTIN = "7680587340015" # orphan drug IKSNR 62132: Adcetris, Pulver zur Herstellung einer Infusionslösung
|
52
|
+
GTINS_DRUGS = ["733905577161", # 1-DAY ACUVUE Moist Tag -2.00dpt BC 8.5
|
53
|
+
FRIDGE_GTIN,
|
54
|
+
ORPHAN_GTIN,
|
55
|
+
"4042809018288",
|
56
|
+
"4042809018400",
|
57
|
+
"4042809018493",
|
58
|
+
"5000223074777",
|
59
|
+
"5000223439507",
|
60
|
+
"7611600441013",
|
61
|
+
"7611600441020",
|
62
|
+
"7611600441037",
|
63
|
+
"7680161050583", # Hirudoid Creme 3 mg/g
|
64
|
+
"7680172330414", # SELSUN
|
65
|
+
"7680284860144",
|
66
|
+
"7680316440115", # FERRO-GRADUMET Depottabl 30 Stk
|
67
|
+
"7680316950157", # SOFRADEX Gtt Auric 8 ml
|
68
|
+
"7680324750190", # LANSOYL Gel
|
69
|
+
"7680353660163",
|
70
|
+
"7680403330459",
|
71
|
+
"7680536620137", # 3TC Filmtabl 150 mg
|
72
|
+
"7680555580054", # ZYVOXID
|
73
|
+
# 7680620690084 is LEVETIRACETAM DESITIN Mini Filmtab 250 mg needed for extractor_spec.rb
|
74
|
+
"7680620690084"] +
|
75
|
+
GTINS_CALC
|
76
|
+
FERRO_GRADUMET_GTIN = "7680316440115"
|
77
|
+
HIRUDOID_GTIN = "7680161050583"
|
78
|
+
LANSOYL_GTIN = "7680324750190"
|
79
|
+
LANSOYL_PRICE_RESELLER_PUB = 18.95
|
80
|
+
LANSOYL_PRICE_ZURROSE = 10.54
|
81
|
+
LANSOYL_PRICE_ZURROSEPUB = 16.25
|
82
|
+
LEVETIRACETAM_GTIN = "7680620690084"
|
83
|
+
LEVETIRACETAM_PRICE_PPUB = 27.8
|
84
|
+
LEVETIRACETAM_PRICE_ZURROSE = 13.49
|
85
|
+
LEVETIRACETAM_PRICE_RESELLER_PUB = 24.3
|
86
|
+
SOFRADEX_GTIN = "7680316950157"
|
87
|
+
SOFRADEX_PRICE_RESELLER_PUB = 12.9
|
88
|
+
SOFRADEX_PRICE_ZURROSE = 7.18
|
89
|
+
SOFRADEX_PRICE_ZURROSEPUB = 15.45
|
90
|
+
THREE_TC_GTIN = "7680536620137"
|
91
|
+
ZYVOXID_GTIN = "7680555580054"
|
90
92
|
|
91
93
|
GTINS_MEDREG = [
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
94
|
+
"7601001380028", # Glarus
|
95
|
+
"7601002017145", # Kantonsspital Glarus AG
|
96
|
+
"7601001395145", # Kantonstierärztlicher Dienst
|
97
|
+
"7601001396043", # St. Fridolin Pharma AG
|
98
|
+
"7601000159199", # Davatz Ursula
|
99
|
+
"7601000159199", # Davatz Ursula
|
100
|
+
"7601000254344", # Pfister Daniel 8753 Mollis
|
101
|
+
"7601000254207", # Züst Peter 8753 Mollis
|
102
|
+
"7601000752314" # Züst Yvonne 8753 Mollis
|
103
|
+
]
|
103
104
|
end
|
104
105
|
|
105
106
|
RSpec.configure do |config|
|
106
|
-
|
107
|
-
|
107
|
+
config.mock_with :flexmock
|
108
|
+
end
|
108
109
|
|
109
110
|
VCR.configure do |config|
|
110
111
|
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
|
111
112
|
config.hook_into :webmock
|
112
|
-
config.debug_logger = File.open(File.join(File.dirname(File.dirname(__FILE__)),
|
113
|
+
config.debug_logger = File.open(File.join(File.dirname(File.dirname(__FILE__)), "vcr.log"), "w+")
|
113
114
|
config.debug_logger.sync = true
|
114
|
-
config.default_cassette_options = { :
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#
|
122
|
-
#
|
123
|
-
# List of request matchers to use to determine what recorded HTTP interaction to replay. Defaults to [:method, :uri]. The built-in matchers are :method, :uri, :host, :path, :headers and :body. You can also pass the name of a registered custom request matcher or any object that responds to #call.
|
115
|
+
config.default_cassette_options = {record: :once, # ARGV.join(' ').index('downloader_spec') ? :new_episodes : :once ,
|
116
|
+
preserve_exact_body_bytes: true,
|
117
|
+
allow_playback_repeats: true,
|
118
|
+
serialize_with: :json,
|
119
|
+
decode_compressed_response: true,
|
120
|
+
match_requests_on: [:method, :uri, :body]}
|
121
|
+
# :match_requests_on (Array<Symbol, #call>) —
|
122
|
+
#
|
123
|
+
# List of request matchers to use to determine what recorded HTTP interaction to replay. Defaults to [:method, :uri]. The built-in matchers are :method, :uri, :host, :path, :headers and :body. You can also pass the name of a registered custom request matcher or any object that responds to #call.
|
124
124
|
|
125
125
|
config.before_http_request(:real?) do |request|
|
126
|
-
|
126
|
+
warn("before real request: #{request.method} #{request.uri} #{caller[0..5].join("\n")}")
|
127
127
|
$stderr.flush
|
128
128
|
end
|
129
129
|
end
|
@@ -131,17 +131,20 @@ end
|
|
131
131
|
AllCompositionLines = File.expand_path("#{__FILE__}/../data/compositions.txt")
|
132
132
|
AllColumn_C_Lines = File.expand_path("#{__FILE__}/../data/column_c.txt")
|
133
133
|
|
134
|
-
require
|
134
|
+
require "oddb2xml"
|
135
135
|
|
136
136
|
module Kernel
|
137
137
|
def buildr_capture(stream)
|
138
138
|
begin
|
139
|
+
# We know that standardrb complains here. But there is no time to fix it
|
139
140
|
stream = stream.to_s
|
140
141
|
eval "$#{stream} = StringIO.new"
|
141
142
|
yield
|
142
143
|
result = eval("$#{stream}").string
|
143
144
|
ensure
|
144
|
-
eval
|
145
|
+
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
|
146
|
+
"$#{stream} = #{stream.upcase}"
|
147
|
+
RUBY
|
145
148
|
end
|
146
149
|
result
|
147
150
|
end
|
@@ -149,19 +152,19 @@ end
|
|
149
152
|
|
150
153
|
module ServerMockHelper
|
151
154
|
def cleanup_compressor
|
152
|
-
[
|
153
|
-
File.join(Oddb2xml::SpecCompressor,
|
154
|
-
File.join(Oddb2xml::SpecCompressor,
|
155
|
-
File.join(Oddb2xml::SpecCompressor,
|
156
|
-
File.join(Oddb2xml::SpecCompressor,
|
157
|
-
File.join(Oddb2xml::SpecCompressor,
|
158
|
-
File.join(Oddb2xml::SpecCompressor,
|
159
|
-
].each { |file| FileUtils.rm_f(Dir.glob(file), :verbose => false) if Dir.glob(file).size > 0 }
|
155
|
+
[File.join(Oddb2xml::SpecCompressor, "*.zip"),
|
156
|
+
File.join(Oddb2xml::SpecCompressor, "*.tar.gz"),
|
157
|
+
File.join(Oddb2xml::SpecCompressor, "epha_interactions.txt*"),
|
158
|
+
File.join(Oddb2xml::SpecCompressor, "medregbm_company.txt*"),
|
159
|
+
File.join(Oddb2xml::SpecCompressor, "medregbm_person.txt*"),
|
160
|
+
File.join(Oddb2xml::SpecCompressor, "transfer.dat.*"),
|
161
|
+
File.join(Oddb2xml::SpecCompressor, "oddb2xml_files_nonpharma.xls.*")].each { |file| FileUtils.rm_f(Dir.glob(file), verbose: false) if Dir.glob(file).size > 0 }
|
160
162
|
end
|
163
|
+
|
161
164
|
def cleanup_directories_before_run
|
162
|
-
dirs = [
|
163
|
-
dirs.each{ |dir| FileUtils.rm_rf(Dir.glob(File.join(dir,
|
164
|
-
dirs.each{ |dir| FileUtils.makedirs(dir, :
|
165
|
+
dirs = [Oddb2xml::DOWNLOADS, Oddb2xml::WORK_DIR]
|
166
|
+
dirs.each { |dir| FileUtils.rm_rf(Dir.glob(File.join(dir, "*")), verbose: false) }
|
167
|
+
dirs.each { |dir| FileUtils.makedirs(dir, verbose: false) }
|
165
168
|
cleanup_compressor
|
166
169
|
mock_downloads
|
167
170
|
end
|
@@ -177,9 +180,9 @@ def check_elements(xml_name, tests)
|
|
177
180
|
value = test[1]
|
178
181
|
it "should have correct entries #{value} for path #{path}" do
|
179
182
|
found = false
|
180
|
-
|
183
|
+
Nokogiri::XML(File.read(xml_name)).search(path, nil, nil).each do |x|
|
181
184
|
if value.match(x.text)
|
182
|
-
found= true
|
185
|
+
found = true
|
183
186
|
break
|
184
187
|
end
|
185
188
|
end
|
@@ -196,8 +199,8 @@ def check_attributes(xml_name, tests)
|
|
196
199
|
it "should have correct value #{value} for attribute #{attribute} in #{path}" do
|
197
200
|
found = false
|
198
201
|
Nokogiri::XML(File.read(xml_name)).search(path, nil, nil).each do |x|
|
199
|
-
if value.match(x[
|
200
|
-
found= true
|
202
|
+
if value.match(x[attribute.to_s])
|
203
|
+
found = true
|
201
204
|
break
|
202
205
|
end
|
203
206
|
end
|
@@ -210,62 +213,60 @@ RSpec.configure do |config|
|
|
210
213
|
config.run_all_when_everything_filtered = true
|
211
214
|
config.filter_run :focus
|
212
215
|
config.filter_run_excluding :slow
|
213
|
-
#config.exclusion_filter = {:slow => true}
|
216
|
+
# config.exclusion_filter = {:slow => true}
|
214
217
|
|
215
218
|
# Run specs in random order to surface order dependencies. If you find an
|
216
219
|
# order dependency and want to debug it, you can fix the order by providing
|
217
220
|
# the seed, which is printed after each run.
|
218
221
|
# --seed 1234
|
219
|
-
config.order =
|
222
|
+
config.order = "random"
|
220
223
|
|
221
224
|
# Helper
|
222
225
|
config.include(ServerMockHelper)
|
223
226
|
end
|
224
227
|
|
225
228
|
def validate_via_xsd(xsd_file, xml_file)
|
226
|
-
xsd =open(xsd_file).read
|
229
|
+
xsd = File.open(xsd_file).read
|
227
230
|
xsd_rtikelstamm_xml = Nokogiri::XML::Schema(xsd)
|
228
231
|
doc = Nokogiri::XML(File.read(xml_file))
|
229
|
-
xsd_rtikelstamm_xml.validate(doc).each do
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
expect(error.message).to be_nil, msg
|
232
|
+
xsd_rtikelstamm_xml.validate(doc).each do |error|
|
233
|
+
if error.message
|
234
|
+
puts "Failed validating #{xml_file} with #{File.size(xml_file)} bytes using XSD from #{xsd_file}"
|
235
|
+
puts "CMD: xmllint --noout --schema #{xsd_file} #{xml_file}"
|
236
|
+
end
|
237
|
+
msg = "expected #{error.message} to be nil\nfor #{xml_file}"
|
238
|
+
puts msg
|
239
|
+
expect(error.message).to be_nil, msg
|
238
240
|
end
|
239
241
|
end
|
240
242
|
|
241
243
|
def mock_downloads
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
'http://
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
|
244
|
+
WebMock.enable!
|
245
|
+
{"transfer.zip" => ["transfer.dat"],
|
246
|
+
"XMLPublications.zip" => ["Preparations.xml", "ItCodes.xml", "GL_Diff_SB.xml"]}.each do |zip, entries|
|
247
|
+
zip_file = File.join(Oddb2xml::SpecData, zip)
|
248
|
+
files = entries.collect { |entry| File.join(Oddb2xml::SpecData, entry) }
|
249
|
+
FileUtils.rm(zip_file, verbose: false) if File.exist?(zip_file)
|
250
|
+
cmd = "zip --quiet --junk-paths #{zip_file} #{files.join(" ")}"
|
251
|
+
system(cmd)
|
252
|
+
end
|
253
|
+
{"https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/interactions_de_utf8.csv" => "epha_interactions.csv",
|
254
|
+
"https://www.swissmedic.ch/swissmedic/de/home/services/listen_neu.html" => "listen_neu.html",
|
255
|
+
"https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/status_ophan%20Drug.xlsx.download.xlsx/Liste_OrphanDrug_Internet_2019_01_31.xlsx" => "swissmedic_orphan.xlsx",
|
256
|
+
"https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/zugelassene_packungen_ham.xlsx.download.xlsx/Zugelassene_Packungen%20HAM_31012019.xlsx" => "swissmedic_package.xlsx",
|
257
|
+
"http://pillbox.oddb.org/TRANSFER.ZIP" => "transfer.zip",
|
258
|
+
"https://github.com/zdavatz/cpp2sqlite/blob/master/input/atc_codes_multi_lingual.txt" => "atc.csv",
|
259
|
+
"https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/LPPV.txt" => "oddb2xml_files_lppv.txt",
|
260
|
+
"http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip" => "XMLPublications.zip",
|
261
|
+
# 'http://refdatabase.refdata.ch/Service/Article.asmx?WSDL' => 'refdata_Pharma.xml
|
262
|
+
"http://www.spezialitaetenliste.ch/varia_De.htm" => "varia_De.htm"}.each do |url, file|
|
263
|
+
inhalt = File.read(File.join(Oddb2xml::SpecData, file))
|
264
|
+
m = flexmock("open-uri")
|
265
|
+
m.should_receive(:open).with(url).and_return(inhalt)
|
266
|
+
stub_request(:any, url).to_return(body: inhalt)
|
267
|
+
stub_request(:get, url).to_return(body: inhalt)
|
268
|
+
stub_request(:open, url).to_return(body: inhalt)
|
269
|
+
end
|
270
|
+
VCR.eject_cassette
|
271
|
+
VCR.insert_cassette("oddb2xml")
|
271
272
|
end
|
data/test_options.rb
CHANGED
@@ -5,66 +5,63 @@
|
|
5
5
|
# - runs all commands (and add ---skip-download)
|
6
6
|
# - saveds output and downloads to ausgabe/time_stamp
|
7
7
|
|
8
|
-
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require 'oddb2xml/version'
|
8
|
+
require "fileutils"
|
9
|
+
require "socket"
|
10
|
+
require "oddb2xml/version"
|
12
11
|
|
13
12
|
def test_one_call(cmd)
|
14
|
-
dest = File.join(Ausgabe, cmd.gsub(/[ -]/,
|
15
|
-
all_downloads = File.join(dest,
|
16
|
-
FileUtils.makedirs(all_downloads) unless File.
|
17
|
-
cmd.sub!(
|
18
|
-
files = (Dir.glob(
|
19
|
-
FileUtils.rm(files, :
|
13
|
+
dest = File.join(Ausgabe, cmd.gsub(/[ -]/, "_"))
|
14
|
+
all_downloads = File.join(dest, "downloads")
|
15
|
+
FileUtils.makedirs(all_downloads) unless File.exist?(all_downloads)
|
16
|
+
cmd.sub!("oddb2xml", "oddb2xml --skip-download --log")
|
17
|
+
files = (Dir.glob("%.xls*") + Dir.glob("*.dat*") + Dir.glob("*.xml"))
|
18
|
+
FileUtils.rm(files, verbose: true)
|
20
19
|
puts "#{Time.now}: Running cmd #{cmd}"
|
21
|
-
|
20
|
+
start_time = Time.now
|
22
21
|
res = system(cmd)
|
23
|
-
|
24
|
-
|
25
|
-
duration = "#{Time.now}: Took #{sprintf(
|
22
|
+
end_time = Time.now
|
23
|
+
diff_seconds = (end_time - start_time).to_i
|
24
|
+
duration = "#{Time.now}: Took #{sprintf("%3d", diff_seconds)} seconds for"
|
26
25
|
puts "#{duration} success #{res} for #{cmd}"
|
27
26
|
exit 2 unless res
|
28
27
|
FileUtils.makedirs(dest)
|
29
|
-
return unless File.directory?(
|
30
|
-
FileUtils.cp_r(
|
31
|
-
FileUtils.cp(Dir.glob(
|
32
|
-
FileUtils.cp(Dir.glob(
|
33
|
-
FileUtils.cp(Dir.glob(
|
28
|
+
return unless File.directory?("downloads")
|
29
|
+
FileUtils.cp_r("downloads", dest, preserve: true, verbose: true) if Dir.glob(Ausgabe).size > 0
|
30
|
+
FileUtils.cp(Dir.glob("*.dat"), dest, preserve: true, verbose: true) if Dir.glob("*.dat").size > 0
|
31
|
+
FileUtils.cp(Dir.glob("*.xml"), dest, preserve: true, verbose: true) if Dir.glob("*.xml").size > 0
|
32
|
+
FileUtils.cp(Dir.glob("*.gz"), dest, preserve: true, verbose: true) if Dir.glob("*.gz").size > 0
|
34
33
|
downloaded_files = Dir.glob("#{dest}/*/downloads/*")
|
35
|
-
FileUtils.mv(downloaded_files,
|
36
|
-
FileUtils.rm(Dir.glob("#{dest}/*#{Time.now.year}*.xml"), :
|
34
|
+
FileUtils.mv(downloaded_files, all_downloads, verbose: true) if downloaded_files.size > 0
|
35
|
+
FileUtils.rm(Dir.glob("#{dest}/*#{Time.now.year}*.xml"), verbose: true)
|
37
36
|
end
|
38
37
|
|
39
38
|
def prepare_for_gem_test
|
40
|
-
[
|
41
|
-
# "gem uninstall --all --ignore-dependencies --executables",
|
42
|
-
"gem install --no-ri --no-rdoc pkg/*.gem"
|
43
|
-
|
44
|
-
|
45
|
-
puts "Running #{cmd}"
|
46
|
-
exit 1 unless system(cmd)
|
39
|
+
["rake clean gem install", # build and install our gem first
|
40
|
+
# "gem uninstall --all --ignore-dependencies --executables",
|
41
|
+
"gem install --no-ri --no-rdoc pkg/*.gem"].each { |cmd|
|
42
|
+
puts "Running #{cmd}"
|
43
|
+
exit 1 unless system(cmd)
|
47
44
|
}
|
48
45
|
end
|
49
46
|
|
50
|
-
Ausgabe = File.join(Dir.pwd,
|
47
|
+
Ausgabe = File.join(Dir.pwd, "ausgabe", "#{Oddb2xml::VERSION}-#{Time.now.strftime("%Y.%m.%d")}")
|
51
48
|
puts "FQDN hostname #{Socket.gethostbyname(Socket.gethostname).inspect}"
|
52
49
|
FileUtils.makedirs(Ausgabe)
|
53
50
|
prepare_for_gem_test
|
54
51
|
# we will skip some long running tests as travis jobs must finish in less than 50 minutes
|
55
52
|
# unfortunately it returns a very common name
|
56
|
-
unless
|
57
|
-
test_one_call(
|
58
|
-
test_one_call(
|
59
|
-
test_one_call(
|
60
|
-
test_one_call(
|
61
|
-
test_one_call(
|
62
|
-
test_one_call(
|
53
|
+
unless "localhost.localdomain".eql?(Socket.gethostbyname(Socket.gethostname).first)
|
54
|
+
test_one_call("oddb2xml -e")
|
55
|
+
test_one_call("oddb2xml --artikelstamm")
|
56
|
+
test_one_call("oddb2xml -e -I80")
|
57
|
+
test_one_call("oddb2xml -f dat --append -I 80")
|
58
|
+
test_one_call("oddb2xml -f dat --append")
|
59
|
+
test_one_call("oddb2xml --append")
|
63
60
|
end
|
64
|
-
test_one_call(
|
65
|
-
test_one_call(
|
66
|
-
test_one_call(
|
67
|
-
test_one_call(
|
68
|
-
test_one_call(
|
69
|
-
test_one_call(
|
61
|
+
test_one_call("oddb2xml --calc")
|
62
|
+
test_one_call("oddb2xml -t md -c tar.gz")
|
63
|
+
test_one_call("oddb2xml -o")
|
64
|
+
test_one_call("oddb2xml -f xml")
|
65
|
+
test_one_call("oddb2xml -f dat")
|
66
|
+
test_one_call("oddb2xml -t md")
|
70
67
|
# test_one_call('oddb2xml -x address')
|