at_coder_friends 0.6.8 → 0.6.9
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/.gitattributes +1 -0
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/ruby.yml +32 -0
- data/.rubocop.yml +8 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +21 -18
- data/README.md +6 -2
- data/at_coder_friends.gemspec +2 -1
- data/lib/at_coder_friends/config_loader.rb +2 -3
- data/lib/at_coder_friends/generator/cxx_builtin.rb +1 -2
- data/lib/at_coder_friends/generator/main.rb +7 -9
- data/lib/at_coder_friends/generator/ruby_builtin.rb +2 -3
- data/lib/at_coder_friends/parser/binary.rb +3 -2
- data/lib/at_coder_friends/parser/input_format.rb +14 -10
- data/lib/at_coder_friends/parser/modulo.rb +5 -7
- data/lib/at_coder_friends/parser/section_wrapper.rb +3 -5
- data/lib/at_coder_friends/parser/sections.rb +2 -2
- data/lib/at_coder_friends/problem.rb +1 -1
- data/lib/at_coder_friends/scraping/agent.rb +1 -1
- data/lib/at_coder_friends/scraping/authentication.rb +3 -3
- data/lib/at_coder_friends/scraping/tasks.rb +6 -8
- data/lib/at_coder_friends/test_runner/base.rb +1 -2
- data/lib/at_coder_friends/test_runner/judge.rb +3 -3
- data/lib/at_coder_friends/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc8c9e5d2e8f2f243d7e520c88186cc62b46296a3e1b5d7a60673d8a208dd7ec
|
4
|
+
data.tar.gz: 732ab4cbadae2e8e8a1a51e3928fc0bb7f58da4738c770c93d82f5b6262f76b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df86a0c84321098080ba9ad9ef32b6b8f413621ecd90c297fc27d65f36d8d159e7cbfe03c54cce0aa9560ce2b33841c9afa46eb5fbff33bb977d3c0dcfb186bb
|
7
|
+
data.tar.gz: fbc249260ea37187c833ff102002feee9781dc6eecdfd175d4fd06ccf3f33d7a706431353c39a4126d9761825f50b3050b695b02353558594ef93ab07a4dede0
|
data/.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
spec/mocks/* linguist-vendored
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ master ]
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: [ master ]
|
20
|
+
schedule:
|
21
|
+
- cron: '34 8 * * 0'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
actions: read
|
29
|
+
contents: read
|
30
|
+
security-events: write
|
31
|
+
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
language: [ 'ruby' ]
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout repository
|
41
|
+
uses: actions/checkout@v2
|
42
|
+
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
44
|
+
- name: Initialize CodeQL
|
45
|
+
uses: github/codeql-action/init@v1
|
46
|
+
with:
|
47
|
+
languages: ${{ matrix.language }}
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
+
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
+
- name: Autobuild
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
57
|
+
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
+
# 📚 https://git.io/JvXDl
|
60
|
+
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
+
# and modify them (or add more) to build your code if your project
|
63
|
+
# uses a compiled language
|
64
|
+
|
65
|
+
#- run: |
|
66
|
+
# make bootstrap
|
67
|
+
# make release
|
68
|
+
|
69
|
+
- name: Perform CodeQL Analysis
|
70
|
+
uses: github/codeql-action/analyze@v1
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.5', '2.7']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby-version }}
|
30
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
31
|
+
- name: Run tests
|
32
|
+
run: script -e -c "bundle exec rspec"
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.5
|
5
5
|
Exclude:
|
6
6
|
- 'templates/**/*'
|
7
7
|
- 'spec/fixtures/**/*'
|
@@ -12,6 +12,13 @@ Lint/AmbiguousBlockAssociation:
|
|
12
12
|
Exclude:
|
13
13
|
- 'spec/**/*.rb'
|
14
14
|
|
15
|
+
Lint/ConstantDefinitionInBlock:
|
16
|
+
Exclude:
|
17
|
+
- 'spec/**/*.rb'
|
18
|
+
|
19
|
+
Lint/DuplicateBranch:
|
20
|
+
Enabled: false
|
21
|
+
|
15
22
|
Metrics/BlockLength:
|
16
23
|
Exclude:
|
17
24
|
- 'Rakefile'
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.6.9 (2021-12-25)
|
6
|
+
### Added
|
7
|
+
- input_format.rb : \hspace{...}, \text{...} support
|
8
|
+
- input_format.rb : \rm, \textrm{...} support
|
9
|
+
- modulo.rb : \text{mod}, {\bmod}, (10^9+7) support
|
10
|
+
|
5
11
|
## 0.6.8 (2021-05-27)
|
6
12
|
### Deleted
|
7
13
|
- drop Ruby2.4 from target version.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
at_coder_friends (0.6.
|
4
|
+
at_coder_friends (0.6.9)
|
5
5
|
colorize (~> 0.8.1)
|
6
6
|
launchy (>= 2.4.3)
|
7
7
|
mechanize (~> 2.0)
|
@@ -9,23 +9,23 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.
|
12
|
+
addressable (2.8.0)
|
13
13
|
public_suffix (>= 2.0.2, < 5.0)
|
14
14
|
colorize (0.8.1)
|
15
15
|
connection_pool (2.2.5)
|
16
16
|
crack (0.4.5)
|
17
17
|
rexml
|
18
|
-
diff-lcs (1.
|
18
|
+
diff-lcs (1.5.0)
|
19
19
|
docile (1.4.0)
|
20
20
|
domain_name (0.5.20190701)
|
21
21
|
unf (>= 0.0.5, < 1.0.0)
|
22
22
|
hashdiff (1.0.1)
|
23
|
-
http-cookie (1.0.
|
23
|
+
http-cookie (1.0.4)
|
24
24
|
domain_name (~> 0.5)
|
25
25
|
launchy (2.5.0)
|
26
26
|
addressable (~> 2.7)
|
27
|
-
mechanize (2.8.
|
28
|
-
addressable (~> 2.
|
27
|
+
mechanize (2.8.3)
|
28
|
+
addressable (~> 2.8)
|
29
29
|
domain_name (~> 0.5, >= 0.5.20190701)
|
30
30
|
http-cookie (~> 1.0, >= 1.0.3)
|
31
31
|
mime-types (~> 3.0)
|
@@ -35,19 +35,21 @@ GEM
|
|
35
35
|
rubyntlm (~> 0.6, >= 0.6.3)
|
36
36
|
webrick (~> 1.7)
|
37
37
|
webrobots (~> 0.1.2)
|
38
|
-
mime-types (3.
|
38
|
+
mime-types (3.4.1)
|
39
39
|
mime-types-data (~> 3.2015)
|
40
|
-
mime-types-data (3.2021.
|
41
|
-
mini_portile2 (2.
|
40
|
+
mime-types-data (3.2021.1115)
|
41
|
+
mini_portile2 (2.6.1)
|
42
42
|
net-http-digest_auth (1.4.1)
|
43
43
|
net-http-persistent (4.0.1)
|
44
44
|
connection_pool (~> 2.2)
|
45
|
-
nokogiri (1.
|
46
|
-
mini_portile2 (~> 2.
|
45
|
+
nokogiri (1.12.5)
|
46
|
+
mini_portile2 (~> 2.6.1)
|
47
|
+
racc (~> 1.4)
|
48
|
+
nokogiri (1.12.5-x64-mingw32)
|
47
49
|
racc (~> 1.4)
|
48
50
|
public_suffix (4.0.6)
|
49
|
-
racc (1.
|
50
|
-
rake (13.0.
|
51
|
+
racc (1.6.0)
|
52
|
+
rake (13.0.6)
|
51
53
|
rexml (3.2.5)
|
52
54
|
rspec (3.10.0)
|
53
55
|
rspec-core (~> 3.10.0)
|
@@ -61,7 +63,7 @@ GEM
|
|
61
63
|
rspec-mocks (3.10.2)
|
62
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
65
|
rspec-support (~> 3.10.0)
|
64
|
-
rspec-support (3.10.
|
66
|
+
rspec-support (3.10.3)
|
65
67
|
rubyntlm (0.6.3)
|
66
68
|
simplecov (0.21.2)
|
67
69
|
docile (~> 1.1)
|
@@ -71,9 +73,10 @@ GEM
|
|
71
73
|
simplecov_json_formatter (0.1.3)
|
72
74
|
unf (0.1.4)
|
73
75
|
unf_ext
|
74
|
-
unf_ext (0.0.
|
75
|
-
|
76
|
-
|
76
|
+
unf_ext (0.0.8)
|
77
|
+
unf_ext (0.0.8-x64-mingw32)
|
78
|
+
webmock (3.14.0)
|
79
|
+
addressable (>= 2.8.0)
|
77
80
|
crack (>= 0.3.2)
|
78
81
|
hashdiff (>= 0.4.0, < 2.0.0)
|
79
82
|
webrick (1.7.0)
|
@@ -92,4 +95,4 @@ DEPENDENCIES
|
|
92
95
|
webmock (~> 3.0)
|
93
96
|
|
94
97
|
BUNDLED WITH
|
95
|
-
2.2.
|
98
|
+
2.2.32
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
[](https://badge.fury.io/rb/at_coder_friends)
|
2
|
-
|
2
|
+

|
3
|
+
[](https://github.com/nejiko96/at_coder_friends/actions/workflows/ruby.yml)
|
4
|
+
[](https://github.com/nejiko96/at_coder_friends/actions/workflows/codeql-analysis.yml)
|
3
5
|
[](https://codeclimate.com/github/nejiko96/at_coder_friends/maintainability)
|
4
6
|
[](https://codeclimate.com/github/nejiko96/at_coder_friends/test_coverage)
|
7
|
+

|
8
|
+
<!-- [](https://travis-ci.org/nejiko96/at_coder_friends) -->
|
5
9
|
|
6
10
|
# AtCoderFriends
|
7
11
|
|
@@ -16,7 +20,7 @@ AtCoderFriends automates tasks about [AtCoder](https://atcoder.jp/) programming
|
|
16
20
|
|
17
21
|
## Dependencies
|
18
22
|
|
19
|
-
- Ruby 2.
|
23
|
+
- Ruby 2.5 or newer
|
20
24
|
- [Mechanize](https://github.com/sparklemotion/mechanize)
|
21
25
|
|
22
26
|
## Installation
|
data/at_coder_friends.gemspec
CHANGED
@@ -33,7 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.metadata = {
|
34
34
|
'homepage_uri' => spec.homepage,
|
35
35
|
'source_code_uri' => spec.homepage,
|
36
|
-
'changelog_uri' => spec.homepage
|
36
|
+
'changelog_uri' => "#{spec.homepage}/blob/master/CHANGELOG.md",
|
37
|
+
'rubygems_mfa_required' => 'true'
|
37
38
|
}
|
38
39
|
|
39
40
|
spec.add_dependency 'colorize', '~> 0.8.1'
|
@@ -51,18 +51,17 @@ module AtCoderFriends
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def merge(base_hash, derived_hash)
|
54
|
-
|
54
|
+
base_hash.merge(derived_hash) do |_, base_val, derived_val|
|
55
55
|
if base_val.is_a?(Hash) && derived_val.is_a?(Hash)
|
56
56
|
merge(base_val, derived_val)
|
57
57
|
else
|
58
58
|
derived_val
|
59
59
|
end
|
60
60
|
end
|
61
|
-
res
|
62
61
|
end
|
63
62
|
|
64
63
|
def load_yaml(path)
|
65
|
-
yaml =
|
64
|
+
yaml = File.read(path, encoding: Encoding::UTF_8)
|
66
65
|
YAML.safe_load(yaml, [], [], false, path) || {}
|
67
66
|
rescue Errno::ENOENT
|
68
67
|
raise ConfigNotFoundError,
|
@@ -238,8 +238,7 @@ module AtCoderFriends
|
|
238
238
|
def render(src)
|
239
239
|
src = embed_lines(src, '/*** CONSTS ***/', gen_consts)
|
240
240
|
src = embed_lines(src, '/*** DCLS ***/', gen_decls)
|
241
|
-
|
242
|
-
src
|
241
|
+
embed_lines(src, '/*** INPUTS ***/', gen_inputs)
|
243
242
|
end
|
244
243
|
|
245
244
|
def gen_consts(constants = pbm.constants)
|
@@ -12,16 +12,14 @@ module AtCoderFriends
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def process(pbm)
|
15
|
-
generators = ctx.config
|
15
|
+
generators = ctx.config['generators'] || []
|
16
16
|
generators.each do |gen_name|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
puts e.backtrace
|
24
|
-
end
|
17
|
+
gen_obj = load_obj(gen_name)
|
18
|
+
gen_obj.process(pbm)
|
19
|
+
rescue StandardError => e
|
20
|
+
puts "an error occurred in generator:#{gen_name}."
|
21
|
+
puts e.to_s
|
22
|
+
puts e.backtrace
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
@@ -15,8 +15,7 @@ module AtCoderFriends
|
|
15
15
|
|
16
16
|
def render(src)
|
17
17
|
src = embed_lines(src, '### CONSTS ###', gen_consts)
|
18
|
-
|
19
|
-
src
|
18
|
+
embed_lines(src, '### DCLS ###', gen_decls)
|
20
19
|
end
|
21
20
|
|
22
21
|
def gen_consts(constants = pbm.constants)
|
@@ -110,7 +109,7 @@ module AtCoderFriends
|
|
110
109
|
vs[mx] += 's'
|
111
110
|
sz = inpdef.size[0]
|
112
111
|
dcls = vs.map { |v| "#{v}[i]" }
|
113
|
-
dcls[mx] =
|
112
|
+
dcls[mx] = "*#{dcls[mx]}" unless inpdef.item == :char
|
114
113
|
dcl = dcls.join(', ')
|
115
114
|
expr = gen_cmb_expr(inpdef)
|
116
115
|
ret = []
|
@@ -16,9 +16,10 @@ module AtCoderFriends
|
|
16
16
|
re1, re2 = vs.map { |v| Regexp.escape(v) }
|
17
17
|
|
18
18
|
pbm.options.binary_values =
|
19
|
-
|
19
|
+
case out_fmt
|
20
|
+
when /#{re1}.+#{re2}/m
|
20
21
|
vs
|
21
|
-
|
22
|
+
when /#{re2}.+#{re1}/m
|
22
23
|
vs.reverse
|
23
24
|
end
|
24
25
|
end
|
@@ -56,16 +56,20 @@ module AtCoderFriends
|
|
56
56
|
.gsub('>', '>')
|
57
57
|
.gsub('<', '<')
|
58
58
|
.gsub('\\ ', ' ')
|
59
|
-
.gsub(/\\hspace\{\d+pt\}/, ' ')
|
60
59
|
.gsub('\\(', '')
|
61
60
|
.gsub('\\)', '')
|
62
61
|
.gsub('\\lvert', '|')
|
63
62
|
.gsub('\\rvert', '|')
|
64
|
-
.gsub('\\mathit', '')
|
65
|
-
.gsub('\\mathrm', '')
|
66
63
|
.gsub('\\times', '*')
|
67
64
|
.gsub(/\\begin(\{[^{}]*\})*/, '')
|
68
65
|
.gsub(/\\end(\{[^{}]*\})*/, '')
|
66
|
+
.gsub(/\\hspace(\{[^{}]*\})*/, ' ')
|
67
|
+
.gsub(/\\mathrm\{([^{}]*)\}/, '\1')
|
68
|
+
.gsub(/\\mathit\{([^{}]*)\}/, '\1')
|
69
|
+
.gsub(/\\textrm\{([^{}]*)\}/, '\1')
|
70
|
+
.gsub(/\\text\{([^{}]*)\}/, '\1')
|
71
|
+
.gsub(/\\rm\{([^{}]*)\}/, '\1')
|
72
|
+
.gsub('\\rm ', ' ')
|
69
73
|
.gsub(/\\[cdlv]?dots/, '..')
|
70
74
|
.gsub(/\{\}/, ' ')
|
71
75
|
.gsub('−', '-') # full width hyphen
|
@@ -148,8 +152,8 @@ module AtCoderFriends
|
|
148
152
|
class InputFormatMatcher
|
149
153
|
include InputFormatUtils
|
150
154
|
|
151
|
-
attr_reader :container, :item, :pat, :gen_names, :gen_pat2
|
152
|
-
|
155
|
+
attr_reader :container, :item, :pat, :gen_names, :gen_pat2,
|
156
|
+
:names, :pat2, :size, :delim, :ix0
|
153
157
|
|
154
158
|
def initialize(
|
155
159
|
container: nil, item: nil,
|
@@ -168,8 +172,8 @@ module AtCoderFriends
|
|
168
172
|
|
169
173
|
@names = gen_names.call(m1)
|
170
174
|
@pat2 = gen_pat2&.call(names)
|
171
|
-
@size = m1.names.include?('sz') && m1['sz'] || ''
|
172
|
-
@ix0 = m1.names.include?('ix0') && m1['ix0'] || size
|
175
|
+
@size = (m1.names.include?('sz') && m1['sz']) || ''
|
176
|
+
@ix0 = (m1.names.include?('ix0') && m1['ix0']) || size
|
173
177
|
@delim = dlm
|
174
178
|
true
|
175
179
|
end
|
@@ -416,7 +420,7 @@ module AtCoderFriends
|
|
416
420
|
SINGLE_MATCHER = InputFormatMatcher.new(
|
417
421
|
container: :single,
|
418
422
|
pat: /\A(.*\s)?#{RE_SINGLE}(\s.*)?\z/,
|
419
|
-
gen_names: ->(m) { m[0].split.
|
423
|
+
gen_names: ->(m) { m[0].split.grep(/\A#{RE_SINGLE}\z/) }
|
420
424
|
)
|
421
425
|
MATCHERS = [
|
422
426
|
MATRIX_MATCHER,
|
@@ -469,8 +473,8 @@ module AtCoderFriends
|
|
469
473
|
|
470
474
|
ret << matcher.to_inpdef
|
471
475
|
end
|
472
|
-
|
473
|
-
|
476
|
+
matcher = MATCHERS.find { |m| m.match(line) }
|
477
|
+
if !line.empty? && matcher.nil?
|
474
478
|
puts "unknown format: #{line}"
|
475
479
|
ret << unknown_fmt(line)
|
476
480
|
end
|
@@ -6,7 +6,6 @@ module AtCoderFriends
|
|
6
6
|
module Modulo
|
7
7
|
module_function
|
8
8
|
|
9
|
-
# rubocop:disable Style/AsciiComments
|
10
9
|
SECTIONS = [
|
11
10
|
Problem::SECTION_OUT_FMT,
|
12
11
|
Problem::SECTION_STATEMENT,
|
@@ -18,6 +17,7 @@ module AtCoderFriends
|
|
18
17
|
VALUE_PATTERN = %r{
|
19
18
|
(?:
|
20
19
|
<var>([^<>]+)</var>
|
20
|
+
|\(([^()]+)\)
|
21
21
|
|\\\(([^()]+)\\\)
|
22
22
|
|\$([^$]+)\$
|
23
23
|
|\{([^{}]+)\}
|
@@ -29,10 +29,9 @@ module AtCoderFriends
|
|
29
29
|
MOD_PATTERN = /
|
30
30
|
(?:
|
31
31
|
#{VALUE_PATTERN}\s*(?:\([^()]+\)\s*)?で割った(?:剰余|余り|あまり)
|
32
|
-
|(?:modulo|mod|
|
32
|
+
|(?:modulo|mod|divid(?:ed|ing)\s*by)\s*#{VALUE_PATTERN}
|
33
33
|
)
|
34
34
|
/xi.freeze
|
35
|
-
# rubocop:enable Style/AsciiComments
|
36
35
|
|
37
36
|
def process(pbm)
|
38
37
|
mods = []
|
@@ -59,10 +58,9 @@ module AtCoderFriends
|
|
59
58
|
s
|
60
59
|
.tr('0-9A-Za-z', '0-9A-Za-z')
|
61
60
|
.gsub(/[[:space:]]/, ' ')
|
62
|
-
.gsub(%r{[^一-龠_
|
63
|
-
.gsub(/{\\
|
64
|
-
.gsub(/\\
|
65
|
-
.gsub(/\\mbox\s*{\s*mod\s*}/i, 'mod') # \mbox{mod} -> mod
|
61
|
+
.gsub(%r{[^一-龠_ぁ-んァ-ヶーa-zA-Z0-9 -/:-@\[-`\{-~]}, '')
|
62
|
+
.gsub(/{\\[a-z]+\s*mod\s*}\\?/i, 'mod') # {\rm mod}, {\bmod} -> mod
|
63
|
+
.gsub(/\\[a-z]+\s*{\s*mod\s*}\\?/i, 'mod') # \text{mod} -> mod
|
66
64
|
.gsub(%r{<var>\s*mod\s*</var>}i, 'mod') # <var>mod</var> -> mod
|
67
65
|
end
|
68
66
|
|
@@ -23,15 +23,13 @@ module AtCoderFriends
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def content
|
26
|
-
@content ||=
|
26
|
+
@content ||=
|
27
27
|
siblings.reduce('') { |m, node| m + node.content }.gsub("\r\n", "\n")
|
28
|
-
end
|
29
28
|
end
|
30
29
|
|
31
30
|
def html
|
32
|
-
@html ||=
|
31
|
+
@html ||=
|
33
32
|
siblings.reduce('') { |m, node| m + node.to_html }.gsub("\r\n", "\n")
|
34
|
-
end
|
35
33
|
end
|
36
34
|
|
37
35
|
def find_element(tags)
|
@@ -54,7 +52,7 @@ module AtCoderFriends
|
|
54
52
|
|
55
53
|
def code_block(mtd)
|
56
54
|
elem = find_element(%w[pre blockquote])
|
57
|
-
elem && elem.send(mtd).lstrip.gsub("\r\n", "\n") || ''
|
55
|
+
(elem && elem.send(mtd).lstrip.gsub("\r\n", "\n")) || ''
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
@@ -129,7 +129,7 @@ module AtCoderFriends
|
|
129
129
|
key = nil
|
130
130
|
SECTION_DEFS.any? do |grp|
|
131
131
|
if (m = title.match(grp[:pattern]))
|
132
|
-
no = m.names.include?('no') && m['no'] || '1'
|
132
|
+
no = (m.names.include?('no') && m['no']) || '1'
|
133
133
|
key = format(grp[:key], no: no)
|
134
134
|
end
|
135
135
|
end
|
@@ -140,7 +140,7 @@ module AtCoderFriends
|
|
140
140
|
s
|
141
141
|
.tr('0-9A-Za-z', '0-9A-Za-z')
|
142
142
|
.gsub(/[[:space:]]/, ' ') # &npsp; full-width space
|
143
|
-
.gsub(/[^一-龠_
|
143
|
+
.gsub(/[^一-龠_ぁ-んァ-ヶーa-zA-Z0-9 ]/, '')
|
144
144
|
.strip
|
145
145
|
end
|
146
146
|
end
|
@@ -23,7 +23,7 @@ module AtCoderFriends
|
|
23
23
|
@agent = Mechanize.new
|
24
24
|
agent.user_agent = "AtCoderFriends/#{VERSION} (#{CONTACT})"
|
25
25
|
agent.pre_connect_hooks << proc { sleep 0.1 }
|
26
|
-
agent.log = Logger.new(
|
26
|
+
agent.log = Logger.new($stderr) if ctx.options[:debug]
|
27
27
|
load_session
|
28
28
|
end
|
29
29
|
|
@@ -25,7 +25,7 @@ module AtCoderFriends
|
|
25
25
|
raise e if username_link(e.page)
|
26
26
|
end
|
27
27
|
|
28
|
-
agent.get(common_url('login')
|
28
|
+
agent.get("#{common_url('login')}?continue=#{CGI.escape(url)}")
|
29
29
|
end
|
30
30
|
|
31
31
|
def post_login(page)
|
@@ -40,13 +40,13 @@ module AtCoderFriends
|
|
40
40
|
user = ctx.config['user'].to_s
|
41
41
|
if user.empty?
|
42
42
|
print('enter username:')
|
43
|
-
user =
|
43
|
+
user = $stdin.gets.chomp
|
44
44
|
end
|
45
45
|
|
46
46
|
pass = ctx.config['password'].to_s
|
47
47
|
if pass.empty?
|
48
48
|
print("enter password for #{user}:")
|
49
|
-
pass =
|
49
|
+
pass = $stdin.noecho(&:gets).chomp
|
50
50
|
puts
|
51
51
|
end
|
52
52
|
[user, pass]
|
@@ -7,14 +7,12 @@ module AtCoderFriends
|
|
7
7
|
def fetch_all
|
8
8
|
puts "***** fetch_all #{contest} *****"
|
9
9
|
fetch_assignments.map do |q, url|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
puts e.backtrace
|
17
|
-
end
|
10
|
+
pbm = fetch_problem(q, url)
|
11
|
+
yield pbm if block_given?
|
12
|
+
pbm
|
13
|
+
rescue StandardError => e
|
14
|
+
puts e.to_s
|
15
|
+
puts e.backtrace
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
@@ -121,7 +121,7 @@ module AtCoderFriends
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def which_os
|
124
|
-
@which_os ||=
|
124
|
+
@which_os ||=
|
125
125
|
case RbConfig::CONFIG['host_os']
|
126
126
|
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
127
127
|
:windows
|
@@ -134,7 +134,6 @@ module AtCoderFriends
|
|
134
134
|
else
|
135
135
|
:unknown
|
136
136
|
end
|
137
|
-
end
|
138
137
|
end
|
139
138
|
end
|
140
139
|
end
|
@@ -16,17 +16,17 @@ module AtCoderFriends
|
|
16
16
|
puts "***** judge_all #{prg} (#{test_loc}) *****"
|
17
17
|
results = Dir["#{data_dir}/#{q}/in/*"].sort.map do |infile|
|
18
18
|
id = File.basename(infile)
|
19
|
-
judge(id, false)
|
19
|
+
judge(id, detail: false)
|
20
20
|
end
|
21
21
|
!results.empty? && results.all?
|
22
22
|
end
|
23
23
|
|
24
24
|
def judge_one(id)
|
25
25
|
puts "***** judge_one #{prg} (#{test_loc}) *****"
|
26
|
-
judge(id, true)
|
26
|
+
judge(id, detail: true)
|
27
27
|
end
|
28
28
|
|
29
|
-
def judge(id, detail
|
29
|
+
def judge(id, detail: true)
|
30
30
|
@detail = detail
|
31
31
|
infile = "#{data_dir}/#{q}/in/#{id}"
|
32
32
|
outfile = "#{result_dir}/#{q}/result/#{id}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: at_coder_friends
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nejiko96
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -135,6 +135,9 @@ executables:
|
|
135
135
|
extensions: []
|
136
136
|
extra_rdoc_files: []
|
137
137
|
files:
|
138
|
+
- ".gitattributes"
|
139
|
+
- ".github/workflows/codeql-analysis.yml"
|
140
|
+
- ".github/workflows/ruby.yml"
|
138
141
|
- ".gitignore"
|
139
142
|
- ".rspec"
|
140
143
|
- ".rubocop.yml"
|
@@ -197,6 +200,7 @@ metadata:
|
|
197
200
|
homepage_uri: https://github.com/nejiko96/at_coder_friends
|
198
201
|
source_code_uri: https://github.com/nejiko96/at_coder_friends
|
199
202
|
changelog_uri: https://github.com/nejiko96/at_coder_friends/blob/master/CHANGELOG.md
|
203
|
+
rubygems_mfa_required: 'true'
|
200
204
|
post_install_message:
|
201
205
|
rdoc_options: []
|
202
206
|
require_paths:
|
@@ -212,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
216
|
- !ruby/object:Gem::Version
|
213
217
|
version: '0'
|
214
218
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
219
|
+
rubygems_version: 3.1.6
|
216
220
|
signing_key:
|
217
221
|
specification_version: 4
|
218
222
|
summary: AtCoder support tool
|