green_day 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -17
- data/lib/green_day/test_builder.rb +13 -6
- data/lib/green_day/version.rb +1 -1
- data/lib/green_day.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe88e3d4f51c37f5ca6f0495f43f18ab1d8145c30d57eb45987c23d920bf1093
|
4
|
+
data.tar.gz: 42128ca97c3c9e0184a521d5c224103a1b2a9747e56387d0c63c41a1ca26016b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4cfe103456c189affea0abad843dbc64a5547354b72285e6d0819cd49829dc95de4b79ded1bac4a3edf7fe5956671ef4b1948dcb3d67c9409b3c9f4812d104
|
7
|
+
data.tar.gz: ec28a208aacc075115932aacdb0d4dea42e728e477960ab00772179cb57ab87043ede1d16ceccfca503161147cc4c01b4ef26668355e5bb3fea8de9ec376ba7d
|
data/README.md
CHANGED
@@ -50,33 +50,67 @@ For example
|
|
50
50
|
```
|
51
51
|
|
52
52
|
Example of output spec
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
RSpec.describe 'abc150/A.rb' do
|
56
|
+
it 'test with "2 900\n"' do
|
57
|
+
if ENV['GD_REPL']
|
58
|
+
File.chmod(0o755, 'abc150/A.rb')
|
59
|
+
system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "2 900\n\\004"; interact'))
|
60
|
+
else
|
61
|
+
io = IO.popen('ruby abc150/A.rb', 'w+')
|
62
|
+
io.puts("2 900\n")
|
59
63
|
io.close_write
|
60
|
-
expect(io.readlines.join).to eq("Yes
|
64
|
+
expect(io.readlines.join).to eq("Yes\n")
|
61
65
|
end
|
66
|
+
end
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
68
|
+
it 'test with "1 501\n"' do
|
69
|
+
if ENV['GD_REPL']
|
70
|
+
File.chmod(0o755, 'abc150/A.rb')
|
71
|
+
system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "1 501\n\\004"; interact'))
|
72
|
+
else
|
73
|
+
io = IO.popen('ruby abc150/A.rb', 'w+')
|
74
|
+
io.puts("1 501\n")
|
66
75
|
io.close_write
|
67
|
-
expect(io.readlines.join).to eq("No
|
76
|
+
expect(io.readlines.join).to eq("No\n")
|
68
77
|
end
|
78
|
+
end
|
69
79
|
|
70
|
-
|
71
|
-
|
72
|
-
|
80
|
+
it 'test with "4 2000\n"' do
|
81
|
+
if ENV['GD_REPL']
|
82
|
+
File.chmod(0o755, 'abc150/A.rb')
|
83
|
+
system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "4 2000\n\\004"; interact'))
|
84
|
+
else
|
85
|
+
io = IO.popen('ruby abc150/A.rb', 'w+')
|
86
|
+
io.puts("4 2000\n")
|
73
87
|
io.close_write
|
74
|
-
expect(io.readlines.join).to eq("Yes
|
88
|
+
expect(io.readlines.join).to eq("Yes\n")
|
75
89
|
end
|
76
|
-
|
77
90
|
end
|
78
|
-
```
|
79
91
|
|
92
|
+
end
|
93
|
+
|
94
|
+
```
|
95
|
+
## Debugging with REPL
|
96
|
+
You can debug your code with sample input and REPL by setting `GD_REPL` environment variable.
|
97
|
+
|
98
|
+
```
|
99
|
+
$ GD_REPL=1 bundle exec rspec abc150/spec/A_spec.rb
|
100
|
+
|
101
|
+
abc150/A.rb
|
102
|
+
spawn ruby abc150/A.rb
|
103
|
+
2 900
|
104
|
+
|
105
|
+
From: abc150/A.rb @ line 2 :
|
106
|
+
|
107
|
+
1: a, b = gets.split.map(&:to_i)
|
108
|
+
=> 2: binding.irb
|
109
|
+
3: puts "Yes"
|
110
|
+
|
111
|
+
irb(main):001:0> a
|
112
|
+
=> 2
|
113
|
+
```
|
80
114
|
## Development
|
81
115
|
|
82
116
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -6,22 +6,29 @@ module GreenDay
|
|
6
6
|
|
7
7
|
def build_test(submit_file_path, input_output_hash)
|
8
8
|
<<~SPEC
|
9
|
-
RSpec.describe '
|
9
|
+
RSpec.describe '#{submit_file_path}' do
|
10
10
|
#{input_output_hash.map { |input, output| build_example(submit_file_path, input, output) }.join("\n")}
|
11
11
|
end
|
12
12
|
SPEC
|
13
13
|
end
|
14
14
|
|
15
|
+
# rubocop:disable Metrics/AbcSize
|
15
16
|
def build_example(submit_file_path, input, output)
|
16
17
|
<<~SPEC
|
17
|
-
#{tab}it 'test with #{unify_cr_lf(input)}' do
|
18
|
-
#{tab}#{tab}
|
19
|
-
#{tab}#{tab}
|
20
|
-
#{tab}#{tab}
|
21
|
-
#{tab}#{tab}
|
18
|
+
#{tab}it 'test with #{unify_cr_lf(input).chomp}' do
|
19
|
+
#{tab}#{tab}if ENV['GD_REPL']
|
20
|
+
#{tab}#{tab}#{tab}File.chmod(0o755, '#{submit_file_path}')
|
21
|
+
#{tab}#{tab}#{tab}system(%q(expect -c 'set timeout 2; spawn ruby #{submit_file_path}; send #{unify_cr_lf("#{input}\\004")}; interact'))
|
22
|
+
#{tab}#{tab}else
|
23
|
+
#{tab}#{tab}#{tab}io = IO.popen('ruby #{submit_file_path}', 'w+')
|
24
|
+
#{tab}#{tab}#{tab}io.puts(#{unify_cr_lf(input)})
|
25
|
+
#{tab}#{tab}#{tab}io.close_write
|
26
|
+
#{tab}#{tab}#{tab}expect(io.readlines.join).to eq(#{unify_cr_lf(output)})
|
27
|
+
#{tab}#{tab}end
|
22
28
|
#{tab}end
|
23
29
|
SPEC
|
24
30
|
end
|
31
|
+
# rubocop:enable Metrics/AbcSize
|
25
32
|
|
26
33
|
def unify_cr_lf(string)
|
27
34
|
return unless string # たまに画像で例を出してくるとsampleの文字がなくなる
|
data/lib/green_day/version.rb
CHANGED
data/lib/green_day.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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qwyng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|