green_day 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +12 -44
- data/.rubocop.yml +1 -1
- data/green_day.gemspec +2 -1
- data/lib/green_day/cli.rb +31 -8
- data/lib/green_day/snippet_builder.rb +17 -0
- data/lib/green_day/test_builder.rb +6 -4
- data/lib/green_day/version.rb +1 -1
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3f3fbe2293b67258b8ac02f28db7c0660eb4f7a7a18d07816bf4b3e1e616df
|
4
|
+
data.tar.gz: a13045a2ffc2266ccd2ebbd4eea4ad99605af4f24de9fd3a1b2b503ab718b872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa65f82bc5b568a4d954b5a1546020f327b06ece50089d905c0877ae08ba08780456668dc6f219830284c86e012318251714e2319812714a7f9a9a17de91fd6a
|
7
|
+
data.tar.gz: 1c08eeacdc7e22142ff5522f2bac98af0c68914d62ccf629bda4b60a5d3d10385ed8cec972687b7123bc4cc1070a81c41c9a90995f1ab6ed9169a4f2ca98cd54
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,60 +1,28 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches: [ master ]
|
4
7
|
|
5
8
|
jobs:
|
6
|
-
|
7
|
-
|
8
|
-
runs-on: ${{ matrix.runner }}
|
9
|
-
|
9
|
+
rspec:
|
10
|
+
runs-on: ubuntu-latest
|
10
11
|
strategy:
|
11
|
-
fail-fast: false
|
12
|
-
|
13
12
|
matrix:
|
14
13
|
ruby:
|
15
|
-
- 2.
|
16
|
-
- 2.7.0
|
17
|
-
include:
|
18
|
-
- ruby: 2.3.3
|
19
|
-
runner: ubuntu-16.04
|
20
|
-
- ruby: 2.7.0
|
21
|
-
runner: ubuntu-latest
|
22
|
-
|
14
|
+
- 2.7.1
|
23
15
|
steps:
|
24
16
|
- uses: actions/checkout@v2
|
25
|
-
|
26
|
-
|
27
|
-
uses: masa-iwasaki/setup-rbenv@1.1.0
|
28
|
-
|
29
|
-
- name: Cache RBENV_ROOT
|
30
|
-
uses: actions/cache@v1
|
31
|
-
id: cache_rbenv
|
17
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
18
|
+
uses: actions/setup-ruby@v1
|
32
19
|
with:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
- name: Reinstall libssl-dev
|
37
|
-
run: |
|
38
|
-
set -xe
|
39
|
-
sudo apt-get remove -y libssl-dev
|
40
|
-
sudo apt-get install -y libssl-dev=1.0.2g-1ubuntu4.15
|
41
|
-
if: matrix.runner == 'ubuntu-16.04'
|
42
|
-
|
43
|
-
- name: Install Ruby
|
44
|
-
env:
|
45
|
-
RBENV_VERSION: ${{ matrix.ruby }}
|
46
|
-
run: |
|
47
|
-
set -xe
|
48
|
-
eval "$(rbenv init -)"
|
49
|
-
rbenv install -s $RBENV_VERSION
|
50
|
-
gem install bundler || true
|
51
|
-
|
52
|
-
- name: test with Rake
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
- name: Rspec with rake
|
53
22
|
env:
|
54
23
|
USER_NAME: ${{ secrets.USER_NAME }}
|
55
24
|
PASSWORD: ${{ secrets.PASSWORD }}
|
56
|
-
|
25
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
57
26
|
run: |
|
58
|
-
eval "$(rbenv init -)"
|
59
27
|
bundle install --jobs 4 --retry 3
|
60
28
|
bundle exec rake
|
data/.rubocop.yml
CHANGED
data/green_day.gemspec
CHANGED
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'rspec', '~> 3.0'
|
32
32
|
spec.add_dependency 'thor'
|
33
33
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
34
|
+
spec.add_development_dependency 'codecov'
|
34
35
|
spec.add_development_dependency 'dotenv'
|
35
|
-
spec.add_development_dependency 'rake', '
|
36
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
36
37
|
spec.add_development_dependency 'rubocop'
|
37
38
|
end
|
data/lib/green_day/cli.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'thor'
|
4
|
-
require 'io/console'
|
5
4
|
require_relative 'atcoder_client'
|
6
5
|
require_relative 'contest'
|
7
6
|
require_relative 'test_builder'
|
7
|
+
require_relative 'snippet_builder'
|
8
8
|
|
9
9
|
module GreenDay
|
10
10
|
class Cli < Thor
|
@@ -12,7 +12,8 @@ module GreenDay
|
|
12
12
|
def login
|
13
13
|
print 'username:'
|
14
14
|
username = STDIN.gets.chomp!
|
15
|
-
|
15
|
+
print 'password:'
|
16
|
+
password = STDIN.gets.chomp!
|
16
17
|
|
17
18
|
AtcoderClient.new.login(username, password)
|
18
19
|
end
|
@@ -23,14 +24,36 @@ module GreenDay
|
|
23
24
|
FileUtils.makedirs("#{contest_name}/spec")
|
24
25
|
|
25
26
|
contest.tasks.each do |task|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
create_submit_file!(contest_name, task)
|
28
|
+
create_spec_file!(contest_name, task)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def create_submit_file!(contest_name, task)
|
35
|
+
File.open(submit_file_path(contest_name, task), 'w') do |f|
|
36
|
+
f.write(SnippetBuilder.build)
|
37
|
+
end
|
38
|
+
end
|
29
39
|
|
30
|
-
|
31
|
-
|
32
|
-
|
40
|
+
def create_spec_file!(contest_name, task)
|
41
|
+
test =
|
42
|
+
TestBuilder.build_test(
|
43
|
+
submit_file_path(contest_name, task),
|
44
|
+
task.input_output_hash
|
45
|
+
)
|
46
|
+
File.open(spec_file_path(contest_name, task), 'w') do |f|
|
47
|
+
f.write(test)
|
33
48
|
end
|
34
49
|
end
|
50
|
+
|
51
|
+
def submit_file_path(contest_name, task)
|
52
|
+
"#{contest_name}/#{task.code}.rb"
|
53
|
+
end
|
54
|
+
|
55
|
+
def spec_file_path(contest_name, task)
|
56
|
+
"#{contest_name}/spec/#{task.code}_spec.rb"
|
57
|
+
end
|
35
58
|
end
|
36
59
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GreenDay
|
4
|
+
module SnippetBuilder
|
5
|
+
ARRAY_INPUT_SNIPPET = 'gets.split.map(&:to_i)'
|
6
|
+
MULTIPLE_LINE_INPUT_SNIPPET =
|
7
|
+
'readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }'
|
8
|
+
|
9
|
+
module_function
|
10
|
+
|
11
|
+
def build
|
12
|
+
[ARRAY_INPUT_SNIPPET, MULTIPLE_LINE_INPUT_SNIPPET]
|
13
|
+
.map { |snippet| '# ' + snippet }
|
14
|
+
.join("\n") + "\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -4,20 +4,20 @@ module GreenDay
|
|
4
4
|
module TestBuilder
|
5
5
|
module_function
|
6
6
|
|
7
|
-
def build_test(
|
7
|
+
def build_test(submit_file_path, input_output_hash)
|
8
8
|
<<~SPEC
|
9
9
|
require 'rspec'
|
10
10
|
|
11
11
|
RSpec.describe 'test' do
|
12
|
-
#{input_output_hash.map { |input, output| build_example(
|
12
|
+
#{input_output_hash.map { |input, output| build_example(submit_file_path, input, output) }.join("\n")}
|
13
13
|
end
|
14
14
|
SPEC
|
15
15
|
end
|
16
16
|
|
17
|
-
def build_example(
|
17
|
+
def build_example(submit_file_path, input, output)
|
18
18
|
<<~SPEC
|
19
19
|
#{tab}it 'test with #{unify_cr_lf(input)}' do
|
20
|
-
#{tab}#{tab}io = IO.popen("ruby #{
|
20
|
+
#{tab}#{tab}io = IO.popen("ruby #{submit_file_path}", "w+")
|
21
21
|
#{tab}#{tab}io.puts(#{unify_cr_lf(input)})
|
22
22
|
#{tab}#{tab}io.close_write
|
23
23
|
#{tab}#{tab}expect(io.readlines.join).to eq(#{unify_cr_lf(output)})
|
@@ -26,6 +26,8 @@ module GreenDay
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def unify_cr_lf(string)
|
29
|
+
return unless string # たまに画像で例を出してくるとsampleの文字がなくなる
|
30
|
+
|
29
31
|
string.gsub(/\R/, "\n").dump
|
30
32
|
end
|
31
33
|
|
data/lib/green_day/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: green_day
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qwyng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: codecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: dotenv
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +126,16 @@ dependencies:
|
|
112
126
|
name: rake
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
131
|
+
version: 12.3.3
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: 12.3.3
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rubocop
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +176,7 @@ files:
|
|
162
176
|
- lib/green_day/atcoder_client.rb
|
163
177
|
- lib/green_day/cli.rb
|
164
178
|
- lib/green_day/contest.rb
|
179
|
+
- lib/green_day/snippet_builder.rb
|
165
180
|
- lib/green_day/task.rb
|
166
181
|
- lib/green_day/test_builder.rb
|
167
182
|
- lib/green_day/version.rb
|