at_coder_friends 0.6.5 → 0.6.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbf2c089d89bcf9e3a8acf248715fdcaf59cb24f
4
- data.tar.gz: baa90cc2da792563e25da6f7f33e55d479e3c58e
3
+ metadata.gz: 529abf515e1ac88d91324d75878b5230a06f0950
4
+ data.tar.gz: e8cac75318fac06d78e33a2541250fc2f3d511d9
5
5
  SHA512:
6
- metadata.gz: 0dc062e9b96728474290d66d65b1434abb4dda89c83004e30dcab3e59045427d260e779ba6117460c0357b13aa002a179c0175d6083e6d77308d2e0f19830624
7
- data.tar.gz: 7115e84fda7ec09bb036ad13912c871780149ec91e5ccabfb30be2326e9781006270805767aa55e700d632e9766c00b884a7d5b9f13e9e88287dc9df59cc7453
6
+ metadata.gz: 0c0c9ccf130759df1c6fb7eca64abf5dcfd0a404bbbda4d4b307d95a9e00a5c6695b048f87fb3b08f9d347be404ae058927c81ed56440961cabeb988216cf9e1
7
+ data.tar.gz: a2804299f1870c9a5a4e7975bec387cc0c52cba798b6fffb546162f47aaf996adb866c71dd6aee146276ec59b15815a2e6eae652600206073f24d5abcefc82f4
@@ -1,11 +1,11 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
+ TargetRubyVersion: 2.3
4
5
  Exclude:
5
6
  - 'templates/**/*'
6
7
  - 'spec/fixtures/**/*'
7
8
  - 'regression/**/*'
8
- TargetRubyVersion: 2.3
9
9
 
10
10
  Lint/AmbiguousBlockAssociation:
11
11
  Exclude:
@@ -26,5 +26,5 @@ Metrics/ModuleLength:
26
26
  Exclude:
27
27
  - 'spec/**/*.rb'
28
28
 
29
- Naming/UncommunicativeMethodParamName:
29
+ Naming/MethodParameterName:
30
30
  MinNameLength: 1
@@ -6,3 +6,19 @@ Metrics/ClassLength:
6
6
 
7
7
  Metrics/MethodLength:
8
8
  Max: 15
9
+
10
+ # enable new cops to avoid warnings
11
+ Lint/RaiseException:
12
+ Enabled: true
13
+
14
+ Lint/StructNewOverride:
15
+ Enabled: true
16
+
17
+ Style/HashEachMethods:
18
+ Enabled: true
19
+
20
+ Style/HashTransformKeys:
21
+ Enabled: true
22
+
23
+ Style/HashTransformValues:
24
+ Enabled: true
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.6.6 (2020-05-29)
6
+ ### Added
7
+ - open submission list after submit.
8
+ - enable -%> in ERBs.
9
+ - error handling in fetch_problem.
10
+ - remove \mathrm{...} from expressions.
11
+
12
+ ### Changed
13
+ - change task id match pattern on submission.
14
+ - treat input more than 19 digits as string.
15
+
5
16
  ## 0.6.5 (2020-04-15)
6
17
  ### Added
7
18
  - multiple language version support.
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- at_coder_friends (0.6.5)
4
+ at_coder_friends (0.6.6)
5
5
  colorize (~> 0.8.1)
6
- launchy (~> 2.4.3)
6
+ launchy (>= 2.4.3, < 2.6.0)
7
7
  mechanize (~> 2.0)
8
8
 
9
9
  GEM
@@ -36,29 +36,29 @@ GEM
36
36
  webrobots (>= 0.0.9, < 0.2)
37
37
  mime-types (3.3.1)
38
38
  mime-types-data (~> 3.2015)
39
- mime-types-data (3.2019.1009)
39
+ mime-types-data (3.2020.0512)
40
40
  mini_portile2 (2.4.0)
41
41
  net-http-digest_auth (1.4.1)
42
- net-http-persistent (3.1.0)
42
+ net-http-persistent (4.0.0)
43
43
  connection_pool (~> 2.2)
44
44
  nokogiri (1.10.9)
45
45
  mini_portile2 (~> 2.4.0)
46
46
  ntlm-http (0.1.1)
47
- public_suffix (4.0.3)
47
+ public_suffix (4.0.5)
48
48
  rake (13.0.1)
49
49
  rspec (3.9.0)
50
50
  rspec-core (~> 3.9.0)
51
51
  rspec-expectations (~> 3.9.0)
52
52
  rspec-mocks (~> 3.9.0)
53
- rspec-core (3.9.1)
54
- rspec-support (~> 3.9.1)
55
- rspec-expectations (3.9.0)
53
+ rspec-core (3.9.2)
54
+ rspec-support (~> 3.9.3)
55
+ rspec-expectations (3.9.2)
56
56
  diff-lcs (>= 1.2.0, < 2.0)
57
57
  rspec-support (~> 3.9.0)
58
58
  rspec-mocks (3.9.1)
59
59
  diff-lcs (>= 1.2.0, < 2.0)
60
60
  rspec-support (~> 3.9.0)
61
- rspec-support (3.9.2)
61
+ rspec-support (3.9.3)
62
62
  safe_yaml (1.0.5)
63
63
  simplecov (0.17.1)
64
64
  docile (~> 1.1)
@@ -67,7 +67,7 @@ GEM
67
67
  simplecov-html (0.10.2)
68
68
  unf (0.1.4)
69
69
  unf_ext
70
- unf_ext (0.0.7.6)
70
+ unf_ext (0.0.7.7)
71
71
  webmock (3.8.3)
72
72
  addressable (>= 2.3.6)
73
73
  crack (>= 0.3.2)
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'at_coder_friends/version'
3
+ require_relative 'lib/at_coder_friends/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'at_coder_friends'
@@ -35,11 +33,11 @@ Gem::Specification.new do |spec|
35
33
  spec.metadata = {
36
34
  'homepage_uri' => spec.homepage,
37
35
  'source_code_uri' => spec.homepage,
38
- 'changelog_uri' => 'https://github.com/nejiko96/at_coder_friends/blob/master/CHANGELOG.md'
36
+ 'changelog_uri' => spec.homepage + '/blob/master/CHANGELOG.md'
39
37
  }
40
38
 
41
39
  spec.add_dependency 'colorize', '~> 0.8.1'
42
- spec.add_dependency 'launchy', '~> 2.4.3'
40
+ spec.add_dependency 'launchy', '>= 2.4.3', '< 2.6.0'
43
41
  spec.add_dependency 'mechanize', '~> 2.0'
44
42
 
45
43
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'optparse'
4
+ require 'launchy'
4
5
 
5
6
  module AtCoderFriends
6
7
  # command line interface
@@ -116,6 +117,7 @@ module AtCoderFriends
116
117
 
117
118
  ctx.scraping_agent.submit
118
119
  vf.unverify
120
+ open_submission_list
119
121
  end
120
122
 
121
123
  def check_and_go
@@ -124,6 +126,7 @@ module AtCoderFriends
124
126
  # submit automatically
125
127
  ctx.scraping_agent.submit
126
128
  vf.unverify
129
+ open_submission_list
127
130
  else
128
131
  # enable manual submit
129
132
  vf.verify
@@ -139,8 +142,13 @@ module AtCoderFriends
139
142
  end
140
143
 
141
144
  def open_contest
142
- require 'launchy'
143
145
  Launchy.open(ctx.scraping_agent.contest_url)
144
146
  end
147
+
148
+ def open_submission_list
149
+ url = ctx.scraping_agent.contest_url('submissions/me')
150
+ puts "submission status : #{url}"
151
+ Launchy.open(url)
152
+ end
145
153
  end
146
154
  end
@@ -21,7 +21,7 @@ module AtCoderFriends
21
21
  def generate(pbm)
22
22
  @pbm = pbm
23
23
  src = File.read(select_template)
24
- src = ERB.new(src).result(binding)
24
+ src = ERB.new(src, safe_level = nil, trim_mode = '-').result(binding)
25
25
  src = render(src) if respond_to?(:render)
26
26
  src
27
27
  end
@@ -19,7 +19,8 @@ module AtCoderFriends
19
19
  gen_obj.process(pbm)
20
20
  rescue StandardError => e
21
21
  puts "an error occurred in generator:#{gen_name}."
22
- p e
22
+ puts e.to_s
23
+ puts e.backtrace
23
24
  end
24
25
  end
25
26
  end
@@ -64,6 +64,7 @@ module AtCoderFriends
64
64
  .gsub('\\lvert', '|')
65
65
  .gsub('\\rvert', '|')
66
66
  .gsub('\\mathit', '')
67
+ .gsub('\\mathrm', '')
67
68
  .gsub('\\times', '*')
68
69
  .gsub(/\\begin(\{[^{}]*\})*/, '')
69
70
  .gsub(/\\end(\{[^{}]*\})*/, '')
@@ -61,6 +61,7 @@ module AtCoderFriends
61
61
  .gsub('\\lvert', '|')
62
62
  .gsub('\\rvert', '|')
63
63
  .gsub('\\mathit', '')
64
+ .gsub('\\mathrm', '')
64
65
  .gsub('\\times', '*')
65
66
  .gsub(/\\begin(\{[^{}]*\})*/, '')
66
67
  .gsub(/\\end(\{[^{}]*\})*/, '')
@@ -6,10 +6,11 @@ module AtCoderFriends
6
6
  module InputType
7
7
  module_function
8
8
 
9
- NUMBER_PAT = /\A[+-]?[0-9]+\z/.freeze
9
+ NUMBER_PAT = /\A[+-]?[0-9]{1,19}\z/.freeze
10
+ DECIMAL_PAT = /\A[+-]?[0-9]{1,19}(\.[0-9]+)?\z/.freeze
10
11
  TYPE_TBL = [
11
12
  [:number, NUMBER_PAT],
12
- [:decimal, /\A[+-]?[0-9]+(\.[0-9]+)?\z/]
13
+ [:decimal, DECIMAL_PAT]
13
14
  ].freeze
14
15
 
15
16
  def process(pbm)
@@ -18,7 +18,7 @@ module AtCoderFriends
18
18
  lang = find_lang(page, langs)
19
19
  form = page.forms[1]
20
20
  form.field_with(name: 'data.TaskScreenName') do |sel|
21
- option = sel.options.find { |op| op.text.start_with?(q) }
21
+ option = sel.options.find { |op| op.text =~ /\A#{q}\W/ }
22
22
  option&.select || (raise AppError, "unknown problem:#{q}.")
23
23
  end
24
24
  form.add_field!('data.LanguageId', lang)
@@ -7,9 +7,14 @@ module AtCoderFriends
7
7
  def fetch_all
8
8
  puts "***** fetch_all #{contest} *****"
9
9
  fetch_assignments.map do |q, url|
10
- pbm = fetch_problem(q, url)
11
- yield pbm if block_given?
12
- pbm
10
+ begin
11
+ pbm = fetch_problem(q, url)
12
+ yield pbm if block_given?
13
+ pbm
14
+ rescue StandardError => e
15
+ puts e.to_s
16
+ puts e.backtrace
17
+ end
13
18
  end
14
19
  end
15
20
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AtCoderFriends
4
- VERSION = '0.6.5'
4
+ VERSION = '0.6.6'
5
5
  end
@@ -1,17 +1,20 @@
1
1
  // <%= pbm.url %>
2
- <%
3
- if pbm.options.interactive
4
- %>
2
+
5
3
  #include <cstdio>
4
+ <% if pbm.options.interactive -%>
6
5
  #include <vector>
7
6
  #include <string>
7
+ <% end -%>
8
8
 
9
9
  using namespace std;
10
10
 
11
+ <% if pbm.options.interactive -%>
11
12
  #define DEBUG
13
+ <% end -%>
12
14
  #define REP(i,n) for(int i=0; i<(int)(n); i++)
13
15
  #define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
14
16
 
17
+ <% if pbm.options.interactive -%>
15
18
  //------------------------------------------------------------------------------
16
19
  const int BUFSIZE = 1024;
17
20
  char req[BUFSIZE];
@@ -33,11 +36,17 @@ void query() {
33
36
  }
34
37
 
35
38
  //------------------------------------------------------------------------------
36
- <% gen_consts.each do |const| %><%= const %>
37
- <% end %>
38
- <% gen_decls.each do |dcl| %><%= dcl %>
39
- <% end %>
39
+ <% end -%>
40
+ <% gen_consts.each do |line| -%>
41
+ <%= line %>
42
+ <% end -%>
43
+
44
+ <% gen_decls.each do |line| -%>
45
+ <%= line %>
46
+ <% end -%>
47
+
40
48
  void solve() {
49
+ <% if pbm.options.interactive -%>
41
50
  printf("! %s\n", ans);
42
51
  fflush(stdout);
43
52
  #ifdef DEBUG
@@ -47,48 +56,26 @@ void solve() {
47
56
  puts(responses[i].c_str());
48
57
  }
49
58
  #endif
59
+ <% elsif (vs = pbm.options.binary_values) -%>
60
+ bool cond = false;
61
+ puts(cond ? "<%= vs[0] %>" : "<%= vs[1] %>");
62
+ <% else -%>
63
+ int ans = 0;
64
+ printf("%d\n", ans);
65
+ <% end -%>
50
66
  }
51
67
 
52
68
  void input() {
53
- <% gen_inputs.each do |input| %> <%= input %>
54
- <% end
55
- %>#ifdef DEBUG
69
+ <% gen_inputs.each do |line| -%>
70
+ <%= line %>
71
+ <% end -%>
72
+ <% if pbm.options.interactive -%>
73
+ #ifdef DEBUG
56
74
  scanf("%s", source);
57
75
  #endif
58
- }
59
- <%
60
- else
61
- %>
62
- #include <cstdio>
63
-
64
- using namespace std;
65
-
66
- #define REP(i,n) for(int i=0; i<(int)(n); i++)
67
- #define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
68
-
69
- <% gen_consts.each do |const| %><%= const %>
70
- <% end %>
71
- <% gen_decls.each do |dcl| %><%= dcl %>
72
- <% end %>
73
- void solve() {
74
- <%
75
- if (vs = pbm.options.binary_values)
76
- %> bool cond = false;
77
- puts(cond ? "<%= vs[0] %>" : "<%= vs[1] %>");<%
78
- else
79
- %> int ans = 0;
80
- printf("%d\n", ans);<%
81
- end
82
- %>
76
+ <% end -%>
83
77
  }
84
78
 
85
- void input() {
86
- <% gen_inputs.each do |input| %> <%= input %>
87
- <% end
88
- %>}
89
- <%
90
- end
91
- %>
92
79
  int main() {
93
80
  input();
94
81
  solve();
@@ -1,7 +1,6 @@
1
1
  # <%= pbm.url %>
2
- <%
3
- if pbm.options.interactive
4
- %>
2
+
3
+ <% if pbm.options.interactive -%>
5
4
  def query(*args)
6
5
  puts "? #{args.join(' ')}"
7
6
  STDOUT.flush
@@ -15,15 +14,23 @@ end
15
14
 
16
15
  $DEBUG = true
17
16
 
18
- <% gen_consts.each do |const| %><%= const %>
19
- <% end %>
20
- <% gen_decls.each do |dcl| %><%= dcl %>
21
- <% end %>
17
+ <% end -%>
18
+ <% gen_consts.each do |line| -%>
19
+ <%= line %>
20
+ <% end -%>
21
+
22
+ <% gen_decls.each do |line| -%>
23
+ <%= line %>
24
+ <% end -%>
25
+ <% if pbm.options.interactive -%>
26
+
22
27
  if $DEBUG
23
28
  @responses = []
24
29
  @source = gets.chomp
25
30
  end
31
+ <% end -%>
26
32
 
33
+ <% if pbm.options.interactive -%>
27
34
  puts "! #{ans}"
28
35
  STDOUT.flush
29
36
 
@@ -33,18 +40,9 @@ if $DEBUG
33
40
  puts "query results:"
34
41
  @responses.each { |res| puts res }
35
42
  puts "----------------------------------------"
36
- end<%
37
- else
38
- %>
39
- <% gen_consts.each do |const| %><%= const %>
40
- <% end %>
41
- <% gen_decls.each do |dcl| %><%= dcl %>
42
- <% end %>
43
- <%
44
- if (vs = pbm.options.binary_values)
45
- %>puts cond ? '<%= vs[0] %>' : '<%= vs[1] %>'<%
46
- else
47
- %>puts ans<%
48
- end
49
43
  end
50
- %>
44
+ <% elsif (vs = pbm.options.binary_values) -%>
45
+ puts cond ? '<%= vs[0] %>' : '<%= vs[1] %>'
46
+ <% else -%>
47
+ puts ans
48
+ <% end -%>
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.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - nejiko96
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: launchy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.4.3
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 2.6.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 2.4.3
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 2.6.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: mechanize
43
49
  requirement: !ruby/object:Gem::Requirement