Skip to content

Commit

Permalink
#13 judges
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 28, 2024
1 parent 053c62a commit 183a25d
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 14 deletions.
60 changes: 60 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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.
---
AllCops:
Exclude:
- 'vendor/**/*'
DisplayCopNames: true
TargetRubyVersion: 3.2
SuggestExtensions: false
NewCops: enable

Naming/FileName:
Regex: !ruby/regexp '/^[a-z-._]*$/'
Style/GlobalVars:
Enabled: false
Metrics/MethodLength:
Enabled: false
Lint/NestedMethodDefinition:
Enabled: false
Gemspec/RequiredRubyVersion:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Layout/MultilineMethodCallIndentation:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Layout/EmptyLineAfterGuardClause:
Enabled: false
Layout/CaseIndentation:
Enabled: false
Naming/MethodParameterName:
MinNameLength: 2
30 changes: 30 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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.

source 'https://rubygems.org'

gem 'fbe', '~>0.0'
gem 'judges', '~>0.8'
gem 'rake', '13.2.1'
gem 'rubocop', '1.64.1'
157 changes: 157 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
backtrace (0.4.0)
concurrent-ruby (1.3.3)
decoor (0.0.1)
ethon (0.16.0)
ffi (>= 1.15.0)
factbase (0.0.56)
backtrace (~> 0.3)
decoor (~> 0.0)
json (~> 2.7)
loog (~> 0.2)
nokogiri (~> 1.10)
others (~> 0.0)
tago (~> 0.0)
yaml (~> 0.3)
faraday (2.9.2)
faraday-net_http (>= 2.0, < 3.2)
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.1.0)
net-http
faraday-retry (2.2.1)
faraday (~> 2.0)
fbe (0.0.3)
backtrace (~> 0.3)
decoor (~> 0.0)
factbase (~> 0.0)
faraday (~> 2.9)
faraday-http-cache (~> 2.5)
faraday-multipart (~> 1.0)
faraday-retry (~> 2.2)
judges (~> 0.0)
loog (~> 0.2)
obk (~> 0.0)
octokit (~> 9.1.0)
others (~> 0.0)
verbose (~> 0.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-aarch64-linux-musl)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm-linux-musl)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86-linux-musl)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
gli (2.21.1)
iri (0.8.0)
json (2.7.2)
judges (0.13.3)
backtrace (~> 0.3)
concurrent-ruby (~> 1.2)
factbase (~> 0.0)
gli (~> 2.21)
iri (~> 0.8)
loog (~> 0.2)
moments (~> 0.3)
nokogiri (~> 1.10)
others (~> 0.0)
retries (~> 0.0)
tago (~> 0.0)
typhoeus (~> 1.3)
language_server-protocol (3.17.0.3)
loog (0.5.2)
moments (0.3.0)
multipart-post (2.4.1)
net-http (0.4.1)
uri
nokogiri (1.16.6-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86-linux)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
obk (0.3.1)
octokit (9.1.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
others (0.0.3)
parallel (1.25.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
public_suffix (6.0.0)
racc (1.8.0)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
retries (0.0.5)
rexml (3.3.1)
strscan
rubocop (1.64.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
strscan (3.1.0)
tago (0.0.2)
typhoeus (1.4.1)
ethon (>= 0.9.0)
unicode-display_width (2.5.0)
uri (0.13.0)
verbose (0.0.2)
loog (~> 0.2)
tago (~> 0.0)
yaml (0.3.0)

PLATFORMS
aarch64-linux
aarch64-linux-gnu
aarch64-linux-musl
arm-linux
arm-linux-gnu
arm-linux-musl
arm64-darwin
x86-linux
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
fbe (~> 0.0)
judges (~> 0.8)
rake (= 13.2.1)
rubocop (= 1.64.1)

BUNDLED WITH
2.5.6
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
.SHELLFLAGS := -e -o pipefail -c
SHELL := bash

JUDGES_VERSION=0.13.1
FACTBASE_VERSION=0.0.55

YAMLS = $(wildcard tests/*.yml)
FBS = $(subst tests/,target/fb/,${YAMLS:.yml=.fb})
HTMLS = $(subst fb/,html/,${FBS:.fb=.html})
Expand Down Expand Up @@ -68,8 +65,7 @@ $(SAXON): | target
wget --no-verbose -O $(SAXON) https://repo.maven.apache.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-5/Saxon-HE-9.8.0-5.jar

install: $(SAXON) | target
gem install factbase:$(FACTBASE_VERSION)
gem install judges:$(JUDGES_VERSION)
bundle update
npm --no-color install -g [email protected]

$(DIRS):
Expand Down
50 changes: 50 additions & 0 deletions Rakefile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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 'rubygems'
require 'rake'
require 'rake/clean'

task default: %i[clean test judges rubocop]

require 'rake/testtask'
desc 'Run all unit tests'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.warning = true
test.verbose = false
end

desc 'Test all judges'
task :judges do
live = ARGV.include?('--live') ? '' : '--disable live'
sh "judges --verbose test #{live} --no-log judges"
end

require 'rubocop/rake_task'
desc 'Run RuboCop on all directories'
RuboCop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = true
end
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ inputs:
verbose:
description: 'Log as much debug information as possible'
required: false
default: false
output:
description: 'Directory path with YAML, XML, JSON and other files generated'
required: false
default: 'pages'
factbase:
description: 'Path of the factbase file'
required: true
default: 'recent.fb'
default: 'default.fb'
2 changes: 2 additions & 0 deletions entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ for f in yaml xml json; do
"${JUDGES}" "${gopts[@]}" print --format "${f}" "${INPUT_FACTBASE}" "${INPUT_OUTPUT}/${name}.${f}"
done

"${JUDGES}" "${gopts[@]}" update "${INPUT_FACTBASE}" "${SELF}/judges/"

# Build a summary HTML.
css=$(cat "${SELF}/target/css/main.css")
java -jar "${SELF}/target/saxon.jar" \
Expand Down
33 changes: 33 additions & 0 deletions judges/add-user-names/add-user-name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 'fbe/octo'
require 'fbe/conclude'

Fbe.conclude do
on '(and (exists who) (not (exists who_name)))'
consider do |f|
f.who_name = Fbe.octo.user_name_by_id(f.who)
end
end
Loading

0 comments on commit 183a25d

Please sign in to comment.