diff --git a/Gemfile b/Gemfile index 3b33336..2fe5174 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ gem 'fbe', '>0' gem 'judges', '>0' gem 'minitest', '5.25.1', require: false gem 'minitest-reporters', '1.7.1', require: false +gem 'qbash', '0.0.3', require: false gem 'rake', '13.2.1', require: false gem 'redcarpet', '~>3.5' gem 'rubocop', '1.66.1', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 066f779..000ba59 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,14 +54,15 @@ GEM others (> 0) tago (> 0) yaml (~> 0.3) - faraday (2.10.1) - faraday-net_http (>= 2.0, < 3.2) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json logger faraday-http-cache (2.5.1) faraday (>= 0.8) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (3.1.1) + faraday-net_http (3.3.0) net-http faraday-retry (2.2.1) faraday (~> 2.0) @@ -151,18 +152,21 @@ GEM sawyer (~> 0.9) others (0.0.3) parallel (1.26.3) - parser (3.3.4.2) + parser (3.3.5.0) ast (~> 2.4.1) racc public_suffix (6.0.1) + qbash (0.0.3) + backtrace (> 0) + elapsed (> 0) + loog (> 0) racc (1.8.1) rainbow (3.1.1) rake (13.2.1) redcarpet (3.6.0) regexp_parser (2.9.2) retries (0.0.5) - rexml (3.3.6) - strscan + rexml (3.3.7) rubocop (1.66.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -173,7 +177,7 @@ GEM rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.2) + rubocop-ast (1.32.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) sawyer (0.9.2) @@ -187,15 +191,14 @@ GEM simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) - strscan (3.1.0) tago (0.0.2) typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (2.6.0) uri (0.13.1) verbose (0.0.2) loog (~> 0.2) @@ -231,6 +234,7 @@ DEPENDENCIES judges (> 0) minitest (= 5.25.1) minitest-reporters (= 1.7.1) + qbash (= 0.0.3) rake (= 13.2.1) redcarpet (~> 3.5) rubocop (= 1.66.1) diff --git a/test/pages/test_awards.rb b/test/pages/test_awards.rb new file mode 100644 index 0000000..12bd3f0 --- /dev/null +++ b/test/pages/test_awards.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +require 'minitest/autorun' +require 'nokogiri' +require 'qbash' +require 'loog' + +# Test. +# Author:: Yegor Bugayenko (yegor256@gmail.com) +# Copyright:: Copyright (c) 2024 Yegor Bugayenko +# License:: MIT +class TestAwards < Minitest::Test + def test_payables + Dir.mktmpdir do |dir| + xsl = File.join(dir, 'foo.xsl') + File.write( + xsl, + " + + + + + + + " + ) + xml = File.join(dir, 'input.xml') + File.write( + xml, + " + + + reconciliation + #{(Time.now - (60 * 60)).utc.iso8601} + #{(Time.now - (50 * 60 * 60)).utc.iso8601} + dude + 100 + 70 + 30 + + + 1 + #{(Time.now - (10 * 60 * 60)).utc.iso8601} + dude + 40 + + + 1 + #{(Time.now - (10 * 60 * 60)).utc.iso8601} + dude + 60 + + + 1 + #{Time.now.utc.iso8601} + dude + 25 + + + " + ) + output = File.join(dir, 'output.xml') + qbash( + [ + "java -jar #{Shellwords.escape(File.join(__dir__, '../../target/saxon.jar'))}", + "-s:#{Shellwords.escape(xml)}", + "-xsl:#{Shellwords.escape(xsl)}", + "-o:#{Shellwords.escape(output)}", + "today=#{Shellwords.escape((Time.now + 10).utc.iso8601)}" + ], + log: Loog::NULL + ) + out = Nokogiri::XML.parse(File.read(output)) + assert_equal('55', out.xpath('/td/text()').to_s, out) + end + end +end diff --git a/xsl/awards.xsl b/xsl/awards.xsl index c79faf2..139c861 100644 --- a/xsl/awards.xsl +++ b/xsl/awards.xsl @@ -46,6 +46,16 @@ SOFTWARE. + + + + + There is no ' + + ' property in the fact + + + @@ -57,9 +67,15 @@ SOFTWARE. , making the amount payable equal to - ; since then you've accumulated + ; since + + you've accumulated - points, that's why the amount payable now is + points ( + + - + + ), that's why the amount payable now is @@ -67,7 +83,10 @@ SOFTWARE. - + + There was no reconciliation (payouts) as of yet. + The entire rolling balance may be paid. +