green_day 0.6.0 → 0.8.0

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
  SHA256:
3
- metadata.gz: 971ee30b1f0c5e28050c22c9dad43ec540df4b62a8c98732cc087bd6073264ce
4
- data.tar.gz: b466d89cbb1b7bf4b80bd4b6e6376c62b6bfab1582e0dacea346ceddd43e4996
3
+ metadata.gz: fe88e3d4f51c37f5ca6f0495f43f18ab1d8145c30d57eb45987c23d920bf1093
4
+ data.tar.gz: 42128ca97c3c9e0184a521d5c224103a1b2a9747e56387d0c63c41a1ca26016b
5
5
  SHA512:
6
- metadata.gz: 89fbaca8563074011b950df0241164a97e0fbb0659126b00cc5a7a04a6cd4169dd0a63ece3d4d245aa19ccbb71421b2841d733bb209e893af48f3c22aeb4db3e
7
- data.tar.gz: 02bcd53c57dd6c4d73e8871e0943cd494fe700b77ce61603d752f4f2ec4a97653288c9f9e03e4c9d91766d67d399a1647900ccd2ddd7a752d245310151057db4
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
- ```ruby
55
- RSpec.describe 'test' do
56
- it 'test with "2 900\\n"' do
57
- io = IO.popen("ruby abc150/A.rb", "w+")
58
- io.puts("2 900\\n")
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\\n")
64
+ expect(io.readlines.join).to eq("Yes\n")
61
65
  end
66
+ end
62
67
 
63
- it 'test with "1 501\\n"' do
64
- io = IO.popen("ruby abc150/A.rb", "w+")
65
- io.puts("1 501\\n")
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\\n")
76
+ expect(io.readlines.join).to eq("No\n")
68
77
  end
78
+ end
69
79
 
70
- it 'test with "4 2000\\n"' do
71
- io = IO.popen("ruby abc150/A.rb", "w+")
72
- io.puts("4 2000\\n")
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\\n")
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 'test' do
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}io = IO.popen("ruby #{submit_file_path}", "w+")
19
- #{tab}#{tab}io.puts(#{unify_cr_lf(input)})
20
- #{tab}#{tab}io.close_write
21
- #{tab}#{tab}expect(io.readlines.join).to eq(#{unify_cr_lf(output)})
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の文字がなくなる
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GreenDay
4
- VERSION = '0.6.0'
4
+ VERSION = '0.8.0'
5
5
  end
data/lib/green_day.rb CHANGED
@@ -5,5 +5,4 @@ require_relative 'green_day/cli'
5
5
 
6
6
  module GreenDay
7
7
  class Error < StandardError; end
8
- THREAD_COUNT = 6 # There are usually six questions on Atcoder.
9
8
  end
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.6.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-23 00:00:00.000000000 Z
11
+ date: 2023-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize