-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRakefile
55 lines (43 loc) · 1.69 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "pathname"
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task default: :spec
namespace :validator do
VALIDATOR_SOURCES = {
tool: {
filename: "validator/validationtool-1.5.0-standalone.jar",
release_url: "https://github.com/itplr-kosit/validator/releases/download/v1.5.0/validator-1.5.0-distribution.zip",
},
scenarios: {
filename: "validator/scenarios.xml",
release_url: "https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/release-2024-10-31/validator-configuration-xrechnung_3.0.2_2024-10-31.zip",
},
}.freeze
VALIDATOR_SOURCES.each do |_, v|
base = Pathname.new(__dir__).join("validator")
zipfile = base.join(File.basename(v[:release_url]))
file zipfile do
require "httparty"
base.mkpath unless base.exist?
res = HTTParty.get(v[:release_url], follow_redirects: true)
File.open(zipfile, "wb") { |f| f.write res.body }
end
file v[:filename] => zipfile do
require "zip"
Zip::File.foreach(zipfile) do |entry|
entry.extract base.join(entry.name)
end
end
end
desc "Download official validator and scenarios"
task download: VALIDATOR_SOURCES.map { |_, v| v[:filename] }
desc "Run validator on test fixtures"
task run: :download do
fixtures = Pathname.new(__dir__).join("spec/fixtures/*.xml")
output = Pathname.new(__dir__).join("validator/results").tap(&:mkpath)
tool = VALIDATOR_SOURCES[:tool][:filename]
scenarios = VALIDATOR_SOURCES[:scenarios][:filename]
sh "java -jar #{tool} -r validator -s #{scenarios} --output-directory #{output} --html #{fixtures}"
end
end