at_coder_friends-generator-python_ref 0.1.0 → 0.3.2

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
- SHA1:
3
- metadata.gz: 2e84ac238506799a393d6a5728476aacad96218b
4
- data.tar.gz: d08501d453284d7a299ab0caad8333edcc5bb585
2
+ SHA256:
3
+ metadata.gz: 45f6fd099c746e4e5e4912c4cac72e839cd49985aff42f560d833f13aa8daf96
4
+ data.tar.gz: 5b3fb579bfc0ac86800cc20b99b75e2505015ce4d98cc0c8908ff6fe2dbcd1f3
5
5
  SHA512:
6
- metadata.gz: b8a1108c6d301523371c5185cc582cf6bc30b3a98fb2218b413ce777f05d56c94b5ad8d6fcc61c3429e3993d0b894d02d34c6833c874cd1b5694ba5903346e3f
7
- data.tar.gz: e59912f8024f5925f1442d78fd16ccb02bdbc8591fb0af1ae792c7b2968f684382c4e383182b3b427ea9a714c4523b6e56ca57b4895ba173ab18639a311ab39f
6
+ metadata.gz: 0f142ec1d52f7ceacf31096cd4535f85b1b780f9ef4d4752f742e907344743219277e1f8082488f9a806ab731f34a82d7c2e2c8655a9c1df5fb40b1dd7ddbc82
7
+ data.tar.gz: d38828116e05577842dffbd5e28648106f1af62649b91e447d977966fda2ea09db6bb5db3114fb7383b7a3374a3629e1409e9fe13be72ba059a58b9ec6674a5e
@@ -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: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,12 +1,13 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
4
+ TargetRubyVersion: 2.5
5
+ NewCops: enable
5
6
 
6
7
  Metrics/BlockLength:
7
8
  Exclude:
8
9
  - 'spec/**/*.rb'
9
10
  - '**/*.gemspec'
10
11
 
11
- Naming/UncommunicativeMethodParamName:
12
+ Naming/MethodParameterName:
12
13
  MinNameLength: 1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,40 @@
1
1
  # Change log
2
2
 
3
- ## master(unreleased)
3
+ ## master (unreleased)
4
+
5
+ ## 0.3.2 (2021/12/25)
6
+ ### Deleted
7
+ - drop Ruby2.4 from target version.
8
+
9
+ ## 0.3.1 (2020/12/20)
10
+ ### Added
11
+ - python 3.8.2 support - use underscore separator in number literal
12
+
13
+ ### Deleted
14
+ - drop Ruby2.3 from target version.
15
+
16
+ ## 0.3.0 (2020-05-29)
17
+ ### Changed
18
+ - use -%> in ERB. (available in next release of AtCoderFriends.)
19
+
20
+ ## 0.2.0 (2020-01-05)
21
+ ### Added
22
+ - at_coder_friends 0.6.3 support
23
+ - 'vertical array + matrix' input format support.
24
+ - 'matrix + vertical array' input format support.
25
+ - 'vertically expanded matrices' input format support.
26
+ - 'horizontally expanded matrices' input format support.
27
+ - decimal type support.
28
+ - input data with delimiter(- : /) support.
29
+
30
+ ### Changed
31
+ - Change template file format to ERB.
32
+ - Template file integration
33
+
34
+ ### Deleted
35
+ - Template file for interactive problems.
36
+ - '### OUTPUT ###' embedding pattern.
37
+ - '### URL ###' embedding pattern.
4
38
 
5
39
  ## 0.1.0 (2019-10-31)
6
40
  - Initial implementation
data/Gemfile.lock CHANGED
@@ -1,74 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- at_coder_friends-generator-python_ref (0.1.0)
4
+ at_coder_friends-generator-python_ref (0.3.2)
5
+ at_coder_friends (~> 0.6.8)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- addressable (2.7.0)
10
+ addressable (2.8.0)
10
11
  public_suffix (>= 2.0.2, < 5.0)
11
- at_coder_friends (0.6.1)
12
+ at_coder_friends (0.6.8)
12
13
  colorize (~> 0.8.1)
13
- launchy (~> 2.4.3)
14
+ launchy (>= 2.4.3)
14
15
  mechanize (~> 2.0)
15
16
  colorize (0.8.1)
16
- connection_pool (2.2.2)
17
- diff-lcs (1.3)
17
+ connection_pool (2.2.5)
18
+ diff-lcs (1.5.0)
19
+ docile (1.4.0)
18
20
  domain_name (0.5.20190701)
19
21
  unf (>= 0.0.5, < 1.0.0)
20
- http-cookie (1.0.3)
22
+ http-cookie (1.0.4)
21
23
  domain_name (~> 0.5)
22
- launchy (2.4.3)
23
- addressable (~> 2.3)
24
- mechanize (2.7.6)
25
- domain_name (~> 0.5, >= 0.5.1)
26
- http-cookie (~> 1.0)
27
- mime-types (>= 1.17.2)
28
- net-http-digest_auth (~> 1.1, >= 1.1.1)
29
- net-http-persistent (>= 2.5.2)
30
- nokogiri (~> 1.6)
31
- ntlm-http (~> 0.1, >= 0.1.1)
32
- webrobots (>= 0.0.9, < 0.2)
33
- mime-types (3.3)
24
+ launchy (2.5.0)
25
+ addressable (~> 2.7)
26
+ mechanize (2.8.3)
27
+ addressable (~> 2.8)
28
+ domain_name (~> 0.5, >= 0.5.20190701)
29
+ http-cookie (~> 1.0, >= 1.0.3)
30
+ mime-types (~> 3.0)
31
+ net-http-digest_auth (~> 1.4, >= 1.4.1)
32
+ net-http-persistent (>= 2.5.2, < 5.0.dev)
33
+ nokogiri (~> 1.11, >= 1.11.2)
34
+ rubyntlm (~> 0.6, >= 0.6.3)
35
+ webrick (~> 1.7)
36
+ webrobots (~> 0.1.2)
37
+ mime-types (3.4.1)
34
38
  mime-types-data (~> 3.2015)
35
- mime-types-data (3.2019.1009)
36
- mini_portile2 (2.4.0)
39
+ mime-types-data (3.2021.1115)
40
+ mini_portile2 (2.6.1)
37
41
  net-http-digest_auth (1.4.1)
38
- net-http-persistent (3.1.0)
42
+ net-http-persistent (4.0.1)
39
43
  connection_pool (~> 2.2)
40
- nokogiri (1.10.4)
41
- mini_portile2 (~> 2.4.0)
42
- ntlm-http (0.1.1)
43
- public_suffix (4.0.1)
44
- rake (10.5.0)
45
- rspec (3.9.0)
46
- rspec-core (~> 3.9.0)
47
- rspec-expectations (~> 3.9.0)
48
- rspec-mocks (~> 3.9.0)
49
- rspec-core (3.9.0)
50
- rspec-support (~> 3.9.0)
51
- rspec-expectations (3.9.0)
44
+ nokogiri (1.12.5)
45
+ mini_portile2 (~> 2.6.1)
46
+ racc (~> 1.4)
47
+ nokogiri (1.12.5-x64-mingw32)
48
+ racc (~> 1.4)
49
+ public_suffix (4.0.6)
50
+ racc (1.6.0)
51
+ rake (13.0.6)
52
+ rspec (3.10.0)
53
+ rspec-core (~> 3.10.0)
54
+ rspec-expectations (~> 3.10.0)
55
+ rspec-mocks (~> 3.10.0)
56
+ rspec-core (3.10.1)
57
+ rspec-support (~> 3.10.0)
58
+ rspec-expectations (3.10.1)
52
59
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.9.0)
54
- rspec-mocks (3.9.0)
60
+ rspec-support (~> 3.10.0)
61
+ rspec-mocks (3.10.2)
55
62
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.9.0)
57
- rspec-support (3.9.0)
63
+ rspec-support (~> 3.10.0)
64
+ rspec-support (3.10.3)
65
+ rubyntlm (0.6.3)
66
+ simplecov (0.21.2)
67
+ docile (~> 1.1)
68
+ simplecov-html (~> 0.11)
69
+ simplecov_json_formatter (~> 0.1)
70
+ simplecov-html (0.12.3)
71
+ simplecov_json_formatter (0.1.3)
58
72
  unf (0.1.4)
59
73
  unf_ext
60
- unf_ext (0.0.7.6)
74
+ unf_ext (0.0.8)
75
+ unf_ext (0.0.8-x64-mingw32)
76
+ webrick (1.7.0)
61
77
  webrobots (0.1.2)
62
78
 
63
79
  PLATFORMS
64
80
  ruby
81
+ x64-mingw32
65
82
 
66
83
  DEPENDENCIES
67
- at_coder_friends (~> 0.6)
68
84
  at_coder_friends-generator-python_ref!
69
85
  bundler (~> 2.0)
70
- rake (~> 10.0)
86
+ rake (~> 13.0)
71
87
  rspec (~> 3.0)
88
+ simplecov (~> 0.10)
72
89
 
73
90
  BUNDLED WITH
74
- 2.0.2
91
+ 2.1.4
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ [![Gem Version](https://badge.fury.io/rb/at_coder_friends-generator-python_ref.svg)](https://badge.fury.io/rb/at_coder_friends-generator-python_ref)
2
+ ![Gem](https://img.shields.io/gem/dt/at_coder_friends-generator-python_ref)
3
+ [![Ruby](https://github.com/nejiko96/at_coder_friends-generator-python_ref/actions/workflows/ruby.yml/badge.svg)](https://github.com/nejiko96/at_coder_friends-generator-python_ref/actions/workflows/ruby.yml)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/0775ef9da0798b73beb4/maintainability)](https://codeclimate.com/github/nejiko96/at_coder_friends-generator-python_ref/maintainability)
5
+ ![GitHub](https://img.shields.io/github/license/nejiko96/at_coder_friends-generator-python_ref)
6
+
1
7
  # AtCoderFriends::Generator::PythonRef
2
8
 
3
9
  Python source generator for [AtCoderFriends](https://github.com/nejiko96/at_coder_friends).
@@ -21,27 +27,28 @@ Or install it yourself as:
21
27
 
22
28
  ## Configuration
23
29
 
24
- Add ```PythonRef``` to ```generators``` setting in ```.at_coder_friends.yml```:
25
- ```YAML
26
- generators:
27
- - PythonRef
28
- ```
30
+ Add ```PythonRef``` to ```generators``` setting in ```.at_coder_friends.yml```
29
31
 
30
32
  ## Generator Options
31
33
 
32
- You can set following options to ```generator_settings/PythonRef``` setting
33
- in ```.at_coder_friends.yml```:
34
+ Following options are available
35
+ in ```generator_settings/PythonRef``` section of ```.at_coder_friends.yml```:
34
36
 
35
- | Setting | Description | Default |
37
+ | Option | Description | Default |
36
38
  |---------|-------------|---------|
37
- |default_template|Source template file path|[/templates/python_ref_default.py](/templates/python_ref_default.py)|
38
- |interactive_template|Source template file path for interactive problems|[/templates/python_ref_interactive.py](/templates/python_ref_interactive.py)|
39
+ |default_template|Source template file path|[/templates/python_ref.py.erb](/templates/python_ref.py.erb)|
39
40
 
40
- ### Example
41
+ ## ```.at_coder_friends.yml``` example for Python
41
42
  ```YAML
43
+ generators:
44
+ - PythonRef
42
45
  generator_settings:
43
46
  PythonRef:
44
47
  default_template: /path/to/template
48
+ ext_settings:
49
+ 'py':
50
+ test_cmd:
51
+ default: 'python "{dir}/{base}.py"'
45
52
  ```
46
53
 
47
54
  ## Development
@@ -1,19 +1,16 @@
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/generator/python_ref/version'
3
+ require_relative 'lib/at_coder_friends/generator/python_ref/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'at_coder_friends-generator-python_ref'
9
- spec.version = AtCoderFriends::Generator::PythonRef::VERSION
7
+ spec.version = AtCoderFriends::Generator::PythonRefConstants::VERSION
10
8
  spec.authors = ['nejiko96']
11
9
  spec.email = ['nejiko2006@gmail.com']
12
10
 
13
11
  spec.summary = 'Python generator for AtCoderFriends'
14
12
  spec.description = <<-DESCRIPTION
15
- AtCoderFriends plugin
16
- which Generates Python source from problem description
13
+ Python source generator plugin for AtCoderFriends
17
14
  (reference implementation)
18
15
  DESCRIPTION
19
16
  spec.homepage = 'https://github.com/nejiko96/at_coder_friends-generator-python_ref'
@@ -31,14 +28,19 @@ Gem::Specification.new do |spec|
31
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
29
  spec.require_paths = ['lib']
33
30
 
34
- spec.required_ruby_version = '>= 2.3.0'
31
+ spec.required_ruby_version = '>= 2.5.0'
35
32
 
36
- spec.metadata['homepage_uri'] = spec.homepage
37
- spec.metadata['source_code_uri'] = spec.homepage
38
- spec.metadata['changelog_uri'] = spec.homepage + '/CHANGELOG.md'
33
+ spec.metadata = {
34
+ 'homepage_uri' => spec.homepage,
35
+ 'source_code_uri' => spec.homepage,
36
+ 'changelog_uri' => "#{spec.homepage}/blob/master/CHANGELOG.md",
37
+ 'rubygems_mfa_required' => 'true'
38
+ }
39
+
40
+ spec.add_dependency 'at_coder_friends', '~> 0.6.8'
39
41
 
40
- spec.add_development_dependency 'at_coder_friends', '~> 0.6'
41
42
  spec.add_development_dependency 'bundler', '~> 2.0'
42
- spec.add_development_dependency 'rake', '~> 10.0'
43
+ spec.add_development_dependency 'rake', '~> 13.0'
43
44
  spec.add_development_dependency 'rspec', '~> 3.0'
45
+ spec.add_development_dependency 'simplecov', '~> 0.10'
44
46
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module AtCoderFriends
4
4
  module Generator
5
- class PythonRef
6
- VERSION = '0.1.0'
5
+ module PythonRefConstants
6
+ VERSION = '0.3.2'
7
7
  end
8
8
  end
9
9
  end
@@ -1,47 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'at_coder_friends'
3
4
  require 'at_coder_friends/generator/python_ref/version'
4
5
 
5
6
  module AtCoderFriends
6
7
  module Generator
7
8
  # generates Python source from problem description
8
- class PythonRef
9
+ class PythonRef < Base
10
+ include PythonRefConstants
11
+
9
12
  ACF_HOME = File.realpath(File.join(__dir__, '..', '..', '..'))
10
13
  TMPL_DIR = File.join(ACF_HOME, 'templates')
11
- DEFAULT_TMPL = File.join(TMPL_DIR, 'python_ref_default.py')
12
- INTERACTIVE_TMPL = File.join(TMPL_DIR, 'python_ref_interactive.py')
13
-
14
- attr_reader :cfg, :pbm
15
-
16
- def initialize(cfg = nil)
17
- @cfg = cfg || {}
18
- end
19
-
20
- def process(pbm)
21
- src = generate(pbm)
22
- pbm.add_src(:py, src)
23
- end
24
-
25
- def generate(pbm)
26
- @pbm = pbm
27
- File
28
- .read(select_template)
29
- .gsub('### URL ###', pbm.url)
30
- .gsub('### CONSTS ###', gen_consts.join("\n"))
31
- .gsub('### DCLS ###', gen_decls.join("\n"))
32
- .gsub('### OUTPUT ###', gen_output)
33
- end
34
-
35
- def select_template(interactive = pbm.options.interactive)
36
- interactive ? interactive_template : default_template
37
- end
14
+ DEFAULT_TMPL = File.join(TMPL_DIR, 'python_ref.py.erb')
15
+ ATTRS = Attributes.new(:py, DEFAULT_TMPL)
38
16
 
39
- def default_template
40
- cfg['default_template'] || DEFAULT_TMPL
17
+ def attrs
18
+ ATTRS
41
19
  end
42
20
 
43
- def interactive_template
44
- cfg['interactive_template'] || INTERACTIVE_TMPL
21
+ def render(src)
22
+ src = embed_lines(src, '### CONSTS ###', gen_consts)
23
+ embed_lines(src, '### DCLS ###', gen_decls)
45
24
  end
46
25
 
47
26
  def gen_consts(constants = pbm.constants)
@@ -51,8 +30,7 @@ module AtCoderFriends
51
30
  end
52
31
 
53
32
  def gen_mod(c)
54
- # underscores in numeric literals is available from Python3.6
55
- v = c.value.gsub('^', '**').gsub(',', '')
33
+ v = c.value.gsub('^', '**').gsub(',', '_')
56
34
  "MOD = #{v}"
57
35
  end
58
36
 
@@ -67,35 +45,45 @@ module AtCoderFriends
67
45
  when :harray
68
46
  gen_harray_decl(inpdef)
69
47
  when :varray
70
- if inpdef.names.size == 1
71
- gen_varray_1_decl(inpdef)
72
- else
73
- gen_varray_n_decl(inpdef)
74
- end
48
+ gen_varray_decl(inpdef)
75
49
  when :matrix
76
50
  gen_matrix_decl(inpdef)
51
+ when :varray_matrix, :matrix_varray
52
+ gen_cmb_decl(inpdef)
53
+ when :vmatrix
54
+ gen_vmatrix_decl(inpdef)
55
+ when :hmatrix
56
+ gen_hmatrix_decl(inpdef)
77
57
  end
78
58
  end
79
59
 
80
60
  def gen_single_decl(inpdef)
81
61
  names = inpdef.names
82
62
  dcl = names.join(', ')
83
- expr = gen_expr(inpdef.item, names.size > 1)
63
+ expr = gen_expr(inpdef, names.size > 1)
84
64
  "#{dcl} = #{expr}"
85
65
  end
86
66
 
87
67
  def gen_harray_decl(inpdef)
88
68
  v = inpdef.names[0]
89
69
  dcl = "#{v}s"
90
- expr = gen_expr(inpdef.item, true)
70
+ expr = gen_expr(inpdef, true)
91
71
  "#{dcl} = #{expr}"
92
72
  end
93
73
 
74
+ def gen_varray_decl(inpdef)
75
+ if inpdef.names.size == 1
76
+ gen_varray_1_decl(inpdef)
77
+ else
78
+ gen_varray_n_decl(inpdef)
79
+ end
80
+ end
81
+
94
82
  def gen_varray_1_decl(inpdef)
95
83
  v = inpdef.names[0]
96
84
  sz = inpdef.size[0]
97
85
  dcl = "#{v}s"
98
- expr = gen_expr(inpdef.item, false)
86
+ expr = gen_expr(inpdef, false)
99
87
  "#{dcl} = [#{expr} for _ in range(#{sz})]"
100
88
  end
101
89
 
@@ -103,7 +91,7 @@ module AtCoderFriends
103
91
  names = inpdef.names
104
92
  sz = inpdef.size[0]
105
93
  dcl = names.map { |v| "#{v}s[i]" }.join(', ')
106
- expr = gen_expr(inpdef.item, true)
94
+ expr = gen_expr(inpdef, true)
107
95
  ret = []
108
96
  ret += names.map { |v| "#{v}s = [None for _ in range(#{sz})]" }
109
97
  ret << "for i in range(#{sz}):"
@@ -115,28 +103,86 @@ module AtCoderFriends
115
103
  v = inpdef.names[0]
116
104
  sz = inpdef.size[0]
117
105
  decl = "#{v}ss"
118
- expr = gen_expr(inpdef.item, true)
106
+ expr = gen_expr(inpdef, true)
119
107
  "#{decl} = [#{expr} for _ in range(#{sz})]"
120
108
  end
121
109
 
122
- def gen_expr(item, split)
123
- case item
110
+ def gen_cmb_decl(inpdef)
111
+ mx = inpdef.container == :varray_matrix ? -1 : 0
112
+ vs = inpdef.names.map { |v| "#{v}s" }
113
+ vs[mx] += 's'
114
+ sz = inpdef.size[0]
115
+ dcls = vs.map { |v| "#{v}[i]" }
116
+ dcls[mx] = "*#{dcls[mx]}" unless inpdef.item == :char
117
+ dcl = dcls.join(', ')
118
+ expr = gen_cmb_expr(inpdef)
119
+ ret = []
120
+ ret += vs.map { |v| "#{v} = [None for _ in range(#{sz})]" }
121
+ ret << "for i in range(#{sz}):"
122
+ ret << " #{dcl} = #{expr}"
123
+ ret
124
+ end
125
+
126
+ def gen_vmatrix_decl(inpdef)
127
+ names = inpdef.names
128
+ sz1, sz2 = inpdef.size
129
+ dcl = names.map { |v| "#{v}ss[i][j]" }.join(', ')
130
+ expr = gen_expr(inpdef, true)
131
+ ret = []
132
+ ret += names.map do |v|
133
+ "#{v}ss = [[None for _ in range(#{sz2})] for _ in range(#{sz1})]"
134
+ end
135
+ ret << "for i in range(#{sz1}):"
136
+ ret << " for j in range(#{sz2}):"
137
+ ret << " #{dcl} = #{expr}"
138
+ ret
139
+ end
140
+
141
+ def gen_hmatrix_decl(inpdef)
142
+ names = inpdef.names
143
+ sz = inpdef.size[0]
144
+ dcls = names.map { |v| "#{v}ss[i]" }
145
+ expr = gen_expr(inpdef, true)
146
+ ret = []
147
+ ret += names.map { |v| "#{v}ss = [None for _ in range(#{sz})]" }
148
+ ret << "for i in range(#{sz}):"
149
+ ret << " line = #{expr}"
150
+ ret += dcls.map.with_index do |dcl, i|
151
+ " #{dcl} = line[#{i}::#{dcls.size}]"
152
+ end
153
+ ret
154
+ end
155
+
156
+ def gen_expr(inpdef, split)
157
+ read = gen_read(inpdef.delim)
158
+ case inpdef.item
124
159
  when :number
125
- split ? 'list(map(int, input().split()))' : 'int(input())'
160
+ split ? "list(map(int, #{read}.split()))" : "int(#{read})"
161
+ when :decimal
162
+ split ? "list(map(float, #{read}.split()))" : "float(#{read})"
126
163
  when :string
127
- split ? 'input().split()' : 'input()'
164
+ split ? "#{read}.split()" : read
128
165
  when :char
129
- 'input()'
166
+ read
130
167
  end
131
168
  end
132
169
 
133
- def gen_output(vs = pbm.options.binary_values)
134
- if vs
135
- "print('#{vs[0]}' if cond else '#{vs[1]}')"
136
- else
137
- 'print(ans)'
170
+ def gen_cmb_expr(inpdef)
171
+ read = gen_read(inpdef.delim)
172
+ case inpdef.item
173
+ when :number
174
+ "list(map(int, #{read}.split()))"
175
+ when :decimal
176
+ "list(map(float, #{read}.split()))"
177
+ when :string, :char
178
+ "#{read}.split()"
138
179
  end
139
180
  end
181
+
182
+ def gen_read(delim)
183
+ sub = delim.chars.map { |d| ".replace('#{d}', ' ')" }.join
184
+ "input()#{sub}"
185
+ end
140
186
  end
141
187
  end
142
188
  end
@@ -0,0 +1,15 @@
1
+ # <%= pbm.url %>
2
+
3
+ <% gen_consts.each do |line| -%>
4
+ <%= line %>
5
+ <% end -%>
6
+
7
+ <% gen_decls.each do |line| -%>
8
+ <%= line %>
9
+ <% end -%>
10
+
11
+ <% if (vs = pbm.options.binary_values) -%>
12
+ print('<%= vs[0] %>' if cond else '<%= vs[1] %>')
13
+ <% else -%>
14
+ print(ans)
15
+ <% end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: at_coder_friends-generator-python_ref
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nejiko96
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: at_coder_friends
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
20
- type: :development
19
+ version: 0.6.8
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.6'
26
+ version: 0.6.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,9 +66,22 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
69
83
  description: |2
70
- AtCoderFriends plugin
71
- which Generates Python source from problem description
84
+ Python source generator plugin for AtCoderFriends
72
85
  (reference implementation)
73
86
  email:
74
87
  - nejiko2006@gmail.com
@@ -76,6 +89,7 @@ executables: []
76
89
  extensions: []
77
90
  extra_rdoc_files: []
78
91
  files:
92
+ - ".github/workflows/ruby.yml"
79
93
  - ".gitignore"
80
94
  - ".rspec"
81
95
  - ".rubocop.yml"
@@ -93,15 +107,15 @@ files:
93
107
  - bin/setup
94
108
  - lib/at_coder_friends/generator/python_ref.rb
95
109
  - lib/at_coder_friends/generator/python_ref/version.rb
96
- - templates/python_ref_default.py
97
- - templates/python_ref_interactive.py
110
+ - templates/python_ref.py.erb
98
111
  homepage: https://github.com/nejiko96/at_coder_friends-generator-python_ref
99
112
  licenses:
100
113
  - MIT
101
114
  metadata:
102
115
  homepage_uri: https://github.com/nejiko96/at_coder_friends-generator-python_ref
103
116
  source_code_uri: https://github.com/nejiko96/at_coder_friends-generator-python_ref
104
- changelog_uri: https://github.com/nejiko96/at_coder_friends-generator-python_ref/CHANGELOG.md
117
+ changelog_uri: https://github.com/nejiko96/at_coder_friends-generator-python_ref/blob/master/CHANGELOG.md
118
+ rubygems_mfa_required: 'true'
105
119
  post_install_message:
106
120
  rdoc_options: []
107
121
  require_paths:
@@ -110,15 +124,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
124
  requirements:
111
125
  - - ">="
112
126
  - !ruby/object:Gem::Version
113
- version: 2.3.0
127
+ version: 2.5.0
114
128
  required_rubygems_version: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - ">="
117
131
  - !ruby/object:Gem::Version
118
132
  version: '0'
119
133
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.5.2.3
134
+ rubygems_version: 3.1.6
122
135
  signing_key:
123
136
  specification_version: 4
124
137
  summary: Python generator for AtCoderFriends
@@ -1,7 +0,0 @@
1
- # ### URL ###
2
-
3
- ### CONSTS ###
4
-
5
- ### DCLS ###
6
-
7
- ### OUTPUT ###
@@ -1,7 +0,0 @@
1
- # ### URL ###
2
-
3
- ### CONSTS ###
4
-
5
- ### DCLS ###
6
-
7
- ### OUTPUT ###