-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathRakefile
More file actions
54 lines (44 loc) · 1.66 KB
/
Copy pathRakefile
File metadata and controls
54 lines (44 loc) · 1.66 KB
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
require "pathname"
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "httparty"
require "zip"
Zip.on_exists_proc = true
RSpec::Core::RakeTask.new(:spec)
task default: :spec
VALIDATOR_SOURCES = {
tool: {
filename: "validator/validator-1.6.0-standalone.jar",
release_url: "https://github.com/itplr-kosit/validator/releases/download/v1.6.0/validator-1.6.0.zip",
},
scenarios: {
filename: "validator/scenarios.xml",
release_url: "https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/release-2025-07-10/validator-configuration-xrechnung_3.0.2_2025-07-10.zip",
},
}.freeze
namespace :validator do
VALIDATOR_SOURCES.each_value do |v|
base = Pathname.new(__dir__).join("validator")
zipfile = base.join(File.basename(v[:release_url]))
file zipfile do
base.mkpath unless base.exist?
res = HTTParty.get(v[:release_url], follow_redirects: true)
File.binwrite(zipfile, res.body)
end
file v[:filename] => zipfile do
Zip::File.foreach(zipfile) do |entry|
entry.extract destination_directory: base
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