ruby_learner 1.0.1 → 1.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +17 -17
- data/{workshop → lib/datas}/emacs_help.org +0 -0
- data/lib/datas/final_history_sequential.txt +1 -0
- data/lib/ruby_learner/methods.rb +183 -24
- data/lib/ruby_learner/ruby_learner.rb +15 -7
- data/lib/ruby_learner/typing_practice.rb +6 -2
- data/lib/ruby_learner/version.rb +1 -1
- data/questions/sequential_check/section_1/part_1/lib/answer.rb +3 -9
- data/questions/sequential_check/section_1/part_1/lib/sentence.org +2 -9
- data/questions/sequential_check/section_1/part_1/lib/workplace.rb +1 -5
- data/questions/sequential_check/section_1/part_1/spec/workplace_spec.rb +6 -7
- data/questions/sequential_check/section_1/part_2/lib/answer.rb +4 -15
- data/questions/sequential_check/section_1/part_2/lib/sentence.org +2 -12
- data/questions/sequential_check/section_1/part_2/lib/workplace.rb +1 -5
- data/questions/sequential_check/section_1/part_2/spec/workplace_spec.rb +7 -9
- data/questions/sequential_check/section_1/part_3/lib/answer.rb +3 -0
- data/questions/sequential_check/section_1/part_3/lib/sentence.org +2 -0
- data/questions/sequential_check/section_1/part_3/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_1/part_3/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_1/part_3/spec/workplace_spec.rb +9 -0
- data/questions/sequential_check/section_10/part_1/lib/answer.rb +7 -0
- data/questions/sequential_check/section_10/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_10/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_10/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_10/part_1/spec/workplace_spec.rb +10 -0
- data/questions/sequential_check/section_10/part_2/lib/answer.rb +8 -0
- data/questions/sequential_check/section_10/part_2/lib/sentence.org +3 -0
- data/questions/sequential_check/section_10/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_10/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_10/part_2/spec/workplace_spec.rb +15 -0
- data/questions/sequential_check/section_11/part_1/lib/answer.rb +7 -0
- data/questions/sequential_check/section_11/part_1/lib/sentence.org +4 -0
- data/questions/sequential_check/section_11/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_11/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_11/part_1/spec/workplace_spec.rb +15 -0
- data/questions/sequential_check/section_11/part_2/lib/answer.rb +6 -0
- data/questions/sequential_check/section_11/part_2/lib/sentence.org +2 -0
- data/questions/sequential_check/section_11/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_11/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_11/part_2/spec/workplace_spec.rb +13 -0
- data/questions/sequential_check/section_2/part_1/lib/answer.rb +8 -0
- data/questions/sequential_check/section_2/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_2/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_2/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_2/part_1/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_2/part_2/lib/answer.rb +14 -0
- data/questions/sequential_check/section_2/part_2/lib/sentence.org +2 -0
- data/questions/sequential_check/section_2/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_2/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_2/part_2/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_3/part_1/lib/answer.rb +11 -0
- data/questions/sequential_check/section_3/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_3/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_3/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_3/part_1/spec/workplace_spec.rb +15 -0
- data/questions/sequential_check/section_4/part_1/lib/answer.rb +9 -0
- data/questions/sequential_check/section_4/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_4/part_1/lib/workplace.rb +2 -0
- data/questions/sequential_check/section_4/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_4/part_1/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_5/part_1/lib/answer.rb +8 -0
- data/questions/sequential_check/section_5/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_5/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_5/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_5/part_1/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_5/part_2/lib/answer.rb +5 -0
- data/questions/sequential_check/section_5/part_2/lib/sentence.org +2 -0
- data/questions/sequential_check/section_5/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_5/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_5/part_2/spec/workplace_spec.rb +9 -0
- data/questions/sequential_check/section_6/part_1/lib/answer.rb +5 -0
- data/questions/sequential_check/section_6/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_6/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_6/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_6/part_1/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_6/part_2/lib/answer.rb +7 -0
- data/questions/sequential_check/section_6/part_2/lib/sentence.org +3 -0
- data/questions/sequential_check/section_6/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_6/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_6/part_2/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_6/part_3/lib/answer.rb +7 -0
- data/questions/sequential_check/section_6/part_3/lib/sentence.org +3 -0
- data/questions/sequential_check/section_6/part_3/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_6/part_3/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_6/part_3/spec/workplace_spec.rb +9 -0
- data/questions/sequential_check/section_6/part_4/lib/answer.rb +9 -0
- data/questions/sequential_check/section_6/part_4/lib/sentence.org +3 -0
- data/questions/sequential_check/section_6/part_4/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_6/part_4/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_6/part_4/spec/workplace_spec.rb +9 -0
- data/questions/sequential_check/section_7/part_1/lib/answer.rb +5 -0
- data/questions/sequential_check/section_7/part_1/lib/sentence.org +3 -0
- data/questions/sequential_check/section_7/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_7/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_7/part_1/spec/workplace_spec.rb +14 -0
- data/questions/sequential_check/section_7/part_2/lib/answer.rb +9 -0
- data/questions/sequential_check/section_7/part_2/lib/sentence.org +2 -0
- data/questions/sequential_check/section_7/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_7/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_7/part_2/spec/workplace_spec.rb +10 -0
- data/questions/sequential_check/section_8/part_1/lib/answer.rb +9 -0
- data/questions/sequential_check/section_8/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_8/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_8/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_8/part_1/spec/workplace_spec.rb +15 -0
- data/questions/sequential_check/section_9/part_1/lib/answer.rb +5 -0
- data/questions/sequential_check/section_9/part_1/lib/sentence.org +2 -0
- data/questions/sequential_check/section_9/part_1/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_9/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_9/part_1/spec/workplace_spec.rb +10 -0
- data/questions/sequential_check/section_9/part_2/lib/answer.rb +7 -0
- data/questions/sequential_check/section_9/part_2/lib/sentence.org +2 -0
- data/questions/sequential_check/section_9/part_2/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_9/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_9/part_2/spec/workplace_spec.rb +10 -0
- data/questions/sequential_check/section_9/part_3/lib/answer.rb +12 -0
- data/questions/sequential_check/section_9/part_3/lib/sentence.org +2 -0
- data/questions/sequential_check/section_9/part_3/lib/workplace.rb +1 -0
- data/questions/sequential_check/section_9/part_3/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_9/part_3/spec/workplace_spec.rb +10 -0
- data/takahashi/docs/README.org +9 -0
- data/takahashi/docs/README.org~ +139 -0
- data/takahashi/docs/drill.html +189 -135
- data/takahashi/docs/drill.html~ +171 -187
- data/takahashi/docs/drill.org +163 -120
- data/takahashi/sample_prog/answer/10_2.rb +6 -0
- data/takahashi/sample_prog/answer/8_1.rb +9 -0
- data/takahashi/sample_prog/question/10_1.rb +2 -0
- data/takahashi/sample_prog/question/10_2.rb +3 -0
- data/takahashi/sample_prog/question/11_1.rb +4 -0
- data/takahashi/sample_prog/question/11_2.rb +2 -0
- data/takahashi/sample_prog/question/1_1.rb +2 -0
- data/takahashi/sample_prog/question/1_2.rb +2 -0
- data/takahashi/sample_prog/question/1_3.rb +2 -0
- data/takahashi/sample_prog/question/2_1.rb +2 -0
- data/takahashi/sample_prog/question/2_2.rb +2 -0
- data/takahashi/sample_prog/question/3_1.rb +2 -0
- data/takahashi/sample_prog/question/4_1.rb +2 -0
- data/takahashi/sample_prog/question/5_1.rb +2 -0
- data/takahashi/sample_prog/question/5_2.rb +2 -0
- data/takahashi/sample_prog/question/6_1.rb +2 -0
- data/takahashi/sample_prog/question/6_2.rb +3 -0
- data/takahashi/sample_prog/question/6_3.rb +3 -0
- data/takahashi/sample_prog/question/6_4.rb +3 -0
- data/takahashi/sample_prog/question/7_1.rb +3 -0
- data/takahashi/sample_prog/question/7_2.rb +2 -0
- data/takahashi/sample_prog/question/8_1.rb +2 -0
- data/takahashi/sample_prog/question/9_1.rb +2 -0
- data/takahashi/sample_prog/question/9_2.rb +2 -0
- data/takahashi/sample_prog/question/9_3.rb +2 -0
- data/workshop/emacs.d/#init# +1 -0
- data/workshop/emacs.d/init.el +8 -8
- data/workshop/emacs.d/ruby_learner_init.el +8 -8
- data/workshop/lib/for-def-read.rb +3 -0
- data/workshop/lib/for-read.txt +5 -0
- metadata +138 -7
- data/lib/ruby_learner/h.rb +0 -14
- data/lib/ruby_learner/random_h.rb +0 -16
- data/lib/ruby_learner/sequential_h.rb +0 -15
- data/workshop/training_data.txt +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3869d64ff647ab1b56c965f07268670fbc96c27
|
|
4
|
+
data.tar.gz: 40ce344b3d77c003be5d8e4385ad94ac8f41fa46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc6358593f83e3ae9ea1923aa5cd27f09b0b30c367a0c1f742be75f868e509a9a0c743d22453dcb12a67cd8d33e28a11e55228adf4b64cbd8875f1601e8b3388
|
|
7
|
+
data.tar.gz: fbefbd17018e40ece793648ac3dd2ccb5cc93d511b628b707878baa98f920d44a5c82103e3a425fbf6c193c6a5cf3eb948dfef1204d1887a510aef9570e4f61f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# RubyLearner
|
|
2
2
|
|
|
3
|
-
Ruby mastering application
|
|
3
|
+
Ruby mastering application.
|
|
4
|
+
It checks your code using rspec and rubocop.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -18,24 +19,13 @@ Or install it yourself as:
|
|
|
18
19
|
|
|
19
20
|
$ gem install ruby_learner
|
|
20
21
|
|
|
21
|
-
Now it is not release. If you want to use it, you must under guides:
|
|
22
|
-
|
|
23
|
-
$ git clone git@github.com:Takaki0403/ruby_learner.git
|
|
24
|
-
|
|
25
|
-
In this clone directory:
|
|
26
|
-
|
|
27
|
-
$ rake build
|
|
28
|
-
$ rake install:local
|
|
29
|
-
|
|
30
|
-
<Attention> If your Home_directory has ruby_learner, you must delete it.
|
|
31
|
-
|
|
32
|
-
$ rm -rf ~/ruby_learner
|
|
33
|
-
|
|
34
22
|
## Usage
|
|
35
23
|
```ruby
|
|
36
24
|
Usage: ruby_learner [options]
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
Options: emacs_key - confirm emacs key-bindings.
|
|
26
|
+
sequential_check [section:1~11] [part:1~] - learning drill.
|
|
27
|
+
-drill - confirm drill numbers
|
|
28
|
+
-next - learning next to final history
|
|
39
29
|
```
|
|
40
30
|
|
|
41
31
|
In learning in this app, you can choice 3 mode.
|
|
@@ -43,7 +33,6 @@ Mode 1: you can continue to answer the question:
|
|
|
43
33
|
|
|
44
34
|
$ [RET]
|
|
45
35
|
|
|
46
|
-
|
|
47
36
|
Mode 2: you can confirm answer example.
|
|
48
37
|
|
|
49
38
|
$ answer + [RET]
|
|
@@ -52,6 +41,17 @@ Mode 3: you can stop answer the question.
|
|
|
52
41
|
|
|
53
42
|
$ exit + [RET]
|
|
54
43
|
|
|
44
|
+
## Workshop
|
|
45
|
+
|
|
46
|
+
This app makes a directory in your Home-Directory, 'ruby_learner'. If you confirm your learning history, you should check ruby_learner/workshop/restore.
|
|
47
|
+
|
|
48
|
+
## If it cannot be executed due to an error
|
|
49
|
+
|
|
50
|
+
I think the cause is your workshop-directory. Please execute this command in your Home-Directory.
|
|
51
|
+
|
|
52
|
+
$ rm -rf ruby_learner
|
|
53
|
+
|
|
54
|
+
|
|
55
55
|
## Development
|
|
56
56
|
|
|
57
57
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1-1
|
data/lib/ruby_learner/methods.rb
CHANGED
|
@@ -4,21 +4,147 @@
|
|
|
4
4
|
# end
|
|
5
5
|
require 'rubocop'
|
|
6
6
|
|
|
7
|
-
def
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
def drill_contents
|
|
8
|
+
puts "section_1 1~3"
|
|
9
|
+
puts "section_2 1~2"
|
|
10
|
+
puts "section_3 1"
|
|
11
|
+
puts "section_4 1"
|
|
12
|
+
puts "section_5 1~2"
|
|
13
|
+
puts "section_6 1~4"
|
|
14
|
+
puts "section_7 1~2"
|
|
15
|
+
puts "section_8 1"
|
|
16
|
+
puts "section_9 1~3"
|
|
17
|
+
puts "section_10 1~2"
|
|
18
|
+
puts "section_11 1~2"
|
|
11
19
|
end
|
|
12
20
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
def final_history(gem_dir)
|
|
22
|
+
docs_dir = "#{gem_dir}/lib/datas"
|
|
23
|
+
final_history = ''
|
|
24
|
+
final_sec = 0
|
|
25
|
+
final_par = 0
|
|
26
|
+
Dir::chdir(docs_dir){
|
|
27
|
+
File.open("final_history_sequential.txt") do |f|
|
|
28
|
+
final_history = f.gets
|
|
29
|
+
end
|
|
30
|
+
final_sec = final_history.match(/(.*)\-/)[1].to_i
|
|
31
|
+
final_par = final_history.match(/\-(.*)/)[1].to_i
|
|
32
|
+
}
|
|
33
|
+
return final_sec, final_par
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def next_question(final_sec, final_par)
|
|
37
|
+
if final_sec == 1
|
|
38
|
+
if final_par == 1
|
|
39
|
+
next_sec = 1
|
|
40
|
+
next_par = 2
|
|
41
|
+
elsif final_par == 2
|
|
42
|
+
next_sec = 1
|
|
43
|
+
next_par = 3
|
|
44
|
+
else
|
|
45
|
+
next_sec = 2
|
|
46
|
+
next_par = 1
|
|
47
|
+
end
|
|
48
|
+
elsif final_sec == 2
|
|
49
|
+
if final_par == 1
|
|
50
|
+
next_sec = 2
|
|
51
|
+
next_par = 2
|
|
52
|
+
else
|
|
53
|
+
next_sec = 3
|
|
54
|
+
next_par = 1
|
|
55
|
+
end
|
|
56
|
+
elsif final_sec == 3
|
|
57
|
+
next_sec = 4
|
|
58
|
+
next_par = 1
|
|
59
|
+
elsif final_sec == 4
|
|
60
|
+
next_sec = 5
|
|
61
|
+
next_par = 1
|
|
62
|
+
elsif final_sec == 5
|
|
63
|
+
if final_par == 1
|
|
64
|
+
next_sec = 5
|
|
65
|
+
next_par = 2
|
|
66
|
+
else
|
|
67
|
+
next_sec = 6
|
|
68
|
+
next_par = 1
|
|
69
|
+
end
|
|
70
|
+
elsif final_sec == 6
|
|
71
|
+
if final_par == 1
|
|
72
|
+
next_sec = 6
|
|
73
|
+
next_par = 2
|
|
74
|
+
elsif final_par == 2
|
|
75
|
+
next_sec = 6
|
|
76
|
+
next_par = 3
|
|
77
|
+
elsif final_par == 3
|
|
78
|
+
next_sec = 6
|
|
79
|
+
next_par = 4
|
|
80
|
+
else
|
|
81
|
+
next_sec = 7
|
|
82
|
+
next_par = 1
|
|
83
|
+
end
|
|
84
|
+
elsif final_sec == 7
|
|
85
|
+
if final_par == 1
|
|
86
|
+
next_sec = 7
|
|
87
|
+
next_par = 2
|
|
88
|
+
else
|
|
89
|
+
next_sec = 8
|
|
90
|
+
next_par = 1
|
|
91
|
+
end
|
|
92
|
+
elsif final_sec == 8
|
|
93
|
+
next_sec = 9
|
|
94
|
+
next_par = 1
|
|
95
|
+
elsif final_sec == 9
|
|
96
|
+
if final_par == 1
|
|
97
|
+
next_sec = 9
|
|
98
|
+
next_par = 2
|
|
99
|
+
elsif final_par == 2
|
|
100
|
+
next_sec = 9
|
|
101
|
+
next_par = 3
|
|
102
|
+
else
|
|
103
|
+
next_sec = 10
|
|
104
|
+
next_par = 1
|
|
105
|
+
end
|
|
106
|
+
elsif final_sec == 10
|
|
107
|
+
if final_par == 1
|
|
108
|
+
next_sec = 10
|
|
109
|
+
next_par = 2
|
|
110
|
+
else
|
|
111
|
+
next_sec = 11
|
|
112
|
+
next_par = 1
|
|
113
|
+
end
|
|
114
|
+
else
|
|
115
|
+
if final_par == 1
|
|
116
|
+
next_sec = 11
|
|
117
|
+
next_par = 2
|
|
118
|
+
else
|
|
119
|
+
next_sec = 1
|
|
120
|
+
next_par = 1
|
|
19
121
|
end
|
|
20
122
|
end
|
|
21
|
-
|
|
123
|
+
|
|
124
|
+
return next_sec, next_par
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def write_final_history(gem_dir, current_sec, current_par)
|
|
128
|
+
docs_dir = "#{gem_dir}/lib/datas"
|
|
129
|
+
Dir::chdir(docs_dir){
|
|
130
|
+
File.open("final_history_sequential.txt","w") do |f|
|
|
131
|
+
f.puts("#{current_sec}-#{current_par}")
|
|
132
|
+
end
|
|
133
|
+
}
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def sequential_check_main(gem_dir, workshop_dir ,sec, par)
|
|
137
|
+
puts "section_#{sec}/part_#{par}"
|
|
138
|
+
seq_dir = "#{gem_dir}/questions/sequential_check/section_#{sec}/part_#{par}"
|
|
139
|
+
typing_prac_class = TypingPractice.new(workshop_dir: workshop_dir)
|
|
140
|
+
typing_prac_class.prac_sequence(mode_dir: seq_dir)
|
|
141
|
+
write_final_history(gem_dir, sec, par)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def time_check(start_time: Time)
|
|
145
|
+
end_time = Time.now
|
|
146
|
+
elapsed_time = end_time - start_time - 1
|
|
147
|
+
return elapsed_time
|
|
22
148
|
end
|
|
23
149
|
|
|
24
150
|
def instruct_print
|
|
@@ -31,6 +157,7 @@ def init_mk_files(gem_dir: String, workshop_dir: String)
|
|
|
31
157
|
if Dir.exist?(workshop_dir) != true then
|
|
32
158
|
FileUtils.mkdir_p(workshop_dir)
|
|
33
159
|
system("cp -R #{gem_dir}/workshop/* #{workshop_dir}")
|
|
160
|
+
system("cd #{workshop_dir} && mv emacs.d .emacs.d")
|
|
34
161
|
end
|
|
35
162
|
end
|
|
36
163
|
|
|
@@ -50,18 +177,48 @@ def mk_training_data(elapsed_time: Time, prac_dir: String)
|
|
|
50
177
|
end
|
|
51
178
|
end
|
|
52
179
|
|
|
53
|
-
def
|
|
180
|
+
def typing_discriminant(workshop_dir)
|
|
181
|
+
file = "#{workshop_dir}/lib/workplace.rb"
|
|
182
|
+
loop do
|
|
183
|
+
flag_rspec, flag_rs_exit = rspec_check(workshop_dir)
|
|
184
|
+
if flag_rs_exit == true
|
|
185
|
+
break
|
|
186
|
+
end
|
|
187
|
+
flag_rubocop, flag_rub_exit = rubocop_check(file, workshop_dir)
|
|
188
|
+
if flag_rub_exit == true
|
|
189
|
+
break
|
|
190
|
+
end
|
|
191
|
+
if flag_rspec == true && flag_rubocop == true
|
|
192
|
+
puts "**********************************"
|
|
193
|
+
puts "Final Error Check"
|
|
194
|
+
puts "**********************************"
|
|
195
|
+
stdout, stderr, status = Open3.capture3("rspec #{workshop_dir}/spec/workplace_spec.rb")
|
|
196
|
+
if stdout[0] == '.'
|
|
197
|
+
puts "your code is perfect."
|
|
198
|
+
puts 'If you want to run your code, you execute the following command.'
|
|
199
|
+
puts " $ ruby #{workshop_dir}/lib/workplace.rb"
|
|
200
|
+
break
|
|
201
|
+
else
|
|
202
|
+
puts "not perfect, please fix your code."
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
restore(file: "#{workshop_dir}/lib/workplace.rb", workshop_dir: workshop_dir)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def rspec_check(workshop_dir)
|
|
54
210
|
puts "**********************************"
|
|
55
211
|
puts "RSpec Error Check"
|
|
56
212
|
puts "**********************************"
|
|
57
213
|
count = 0
|
|
58
214
|
flag_rspec = false
|
|
215
|
+
flag_exit = false
|
|
59
216
|
loop do
|
|
60
217
|
count += 1
|
|
61
218
|
puts "---------------------------"
|
|
62
219
|
puts "Rspec try: #{count}"
|
|
63
220
|
puts "---------------------------"
|
|
64
|
-
flag_rspec = system "cd #{
|
|
221
|
+
flag_rspec = system "cd #{workshop_dir} && rspec spec/workplace_spec.rb"
|
|
65
222
|
if flag_rspec == true
|
|
66
223
|
puts "Rspec check is clear!"
|
|
67
224
|
break
|
|
@@ -69,24 +226,25 @@ def rspec_check(dir: workshop_dir)
|
|
|
69
226
|
instruct_print
|
|
70
227
|
select = STDIN.gets.chomp
|
|
71
228
|
if select == 'exit'
|
|
72
|
-
|
|
229
|
+
flag_exit = true
|
|
73
230
|
break
|
|
74
231
|
elsif select == 'answer'
|
|
75
|
-
system "cd #{
|
|
232
|
+
system "cd #{workshop_dir}/lib && emacs -nw -q -l #{workshop_dir}/.emacs.d/ruby_learner_init.el sentence.org workplace.rb"
|
|
76
233
|
else
|
|
77
|
-
system "cd #{
|
|
234
|
+
system "cd #{workshop_dir}/lib && emacs -nw -q -l #{workshop_dir}/.emacs.d/init.el sentence.org workplace.rb"
|
|
78
235
|
end
|
|
79
236
|
end
|
|
80
237
|
end
|
|
81
|
-
return flag_rspec
|
|
238
|
+
return flag_rspec, flag_exit
|
|
82
239
|
end
|
|
83
240
|
|
|
84
|
-
def rubocop_check(file
|
|
241
|
+
def rubocop_check(file, workshop_dir)
|
|
85
242
|
puts "**********************************"
|
|
86
243
|
puts "Rubocop Error Check"
|
|
87
244
|
puts "**********************************"
|
|
88
245
|
count = 0
|
|
89
246
|
flag_rubocop = false
|
|
247
|
+
flag_exit = false
|
|
90
248
|
loop do
|
|
91
249
|
count += 1
|
|
92
250
|
puts "---------------------------"
|
|
@@ -100,22 +258,22 @@ def rubocop_check(file: String, dir: workshop_dir)
|
|
|
100
258
|
instruct_print
|
|
101
259
|
select = STDIN.gets.chomp
|
|
102
260
|
if select == 'exit'
|
|
103
|
-
|
|
261
|
+
flag_exit = true
|
|
104
262
|
break
|
|
105
263
|
elsif select == 'answer'
|
|
106
|
-
system "cd #{
|
|
264
|
+
system "cd #{workshop_dir}/lib && emacs -nw -q -l #{workshop_dir}/.emacs.d/ruby_learner_init.el sentence.org workplace.rb"
|
|
107
265
|
else
|
|
108
|
-
system "cd #{
|
|
266
|
+
system "cd #{workshop_dir}/lib && emacs -nw -q -l #{workshop_dir}/.emacs.d/init.el sentence.org workplace.rb"
|
|
109
267
|
end
|
|
110
268
|
end
|
|
111
269
|
end
|
|
112
|
-
return flag_rubocop
|
|
270
|
+
return flag_rubocop, flag_exit
|
|
113
271
|
end
|
|
114
272
|
|
|
115
273
|
def restore(file: String, workshop_dir: String)
|
|
116
274
|
restore_file = ""
|
|
117
275
|
line = File.open("#{workshop_dir}/lib/answer.rb") do |f|
|
|
118
|
-
|
|
276
|
+
1.times {
|
|
119
277
|
f.gets
|
|
120
278
|
}
|
|
121
279
|
restore_file = f.gets
|
|
@@ -124,7 +282,8 @@ def restore(file: String, workshop_dir: String)
|
|
|
124
282
|
restore_file.delete!("#")
|
|
125
283
|
Dir::chdir("#{workshop_dir}/restore"){
|
|
126
284
|
file_count = Dir.glob("*.rb").count
|
|
127
|
-
restore_file.insert(-5, "[#{file_count}]")
|
|
285
|
+
# restore_file.insert(-5, "[#{file_count}]")
|
|
286
|
+
restore_file.insert(0, "[#{file_count}]")
|
|
128
287
|
}
|
|
129
288
|
system "touch #{workshop_dir}/restore/#{restore_file}"
|
|
130
289
|
system "cp #{workshop_dir}/lib/workplace.rb #{workshop_dir}/restore/#{restore_file}"
|
|
@@ -21,19 +21,27 @@ module RubyLearner
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
desc 'emacs_key', 'check emacs key-bindings'
|
|
24
|
-
def emacs_key
|
|
25
|
-
system("cat #{@
|
|
24
|
+
def emacs_key
|
|
25
|
+
system("cat #{@gem_dir}/lib/datas/emacs_help.org")
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
desc 'sequential_check [section:1~
|
|
28
|
+
desc 'sequential_check [section:1~11] [part:1~]','learning drill'
|
|
29
|
+
option :next, aliases: "-n", type: :boolean
|
|
30
|
+
option :drill, aliases: "-d", type: :boolean
|
|
29
31
|
def sequential_check(*_argv, dir_num, file_num)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
if options[:drill]
|
|
33
|
+
drill_contents
|
|
34
|
+
elsif options[:next]
|
|
35
|
+
final_sec, final_par = final_history(@gem_dir)
|
|
36
|
+
next_sec, next_par = next_question(final_sec, final_par)
|
|
37
|
+
sequential_check_main(@gem_dir, @workshop_dir, next_sec, next_par)
|
|
38
|
+
else
|
|
39
|
+
sequential_check_main(@gem_dir, @workshop_dir, dir_num, file_num)
|
|
40
|
+
end
|
|
33
41
|
end
|
|
34
42
|
|
|
35
43
|
desc 'random_check', 'typing and editing practice.'
|
|
36
|
-
def random_check
|
|
44
|
+
def random_check
|
|
37
45
|
rand_num = rand(1..2)
|
|
38
46
|
rand_dir = "#{@gem_dir}/questions/random_check/section_#{rand_num}"
|
|
39
47
|
typing_practice = TypingPractice.new(workshop_dir: @workshop_dir)
|
|
@@ -5,15 +5,19 @@ class TypingPractice
|
|
|
5
5
|
|
|
6
6
|
def initialize(workshop_dir: String)
|
|
7
7
|
@workshop_dir = workshop_dir
|
|
8
|
+
gem_location = Open3.capture3('gem environment gemdir')
|
|
9
|
+
app_vers = Open3.capture3('gem list ruby_learner')
|
|
10
|
+
rl_ver = app_vers[0].chomp.tr(' ', '-').delete('()')
|
|
11
|
+
@gem_dir = File.join(gem_location[0].chomp, "/gems/#{rl_ver}")
|
|
8
12
|
end
|
|
9
13
|
def prac_sequence(mode_dir: String)
|
|
10
14
|
FileUtils.cp("#{mode_dir}/lib/workplace.rb", "#{@workshop_dir}/lib/workplace.rb")
|
|
11
15
|
FileUtils.cp("#{mode_dir}/lib/sentence.org", "#{@workshop_dir}/lib/sentence.org")
|
|
12
16
|
FileUtils.cp("#{mode_dir}/lib/answer.rb", "#{@workshop_dir}/lib/answer.rb")
|
|
13
17
|
FileUtils.cp("#{mode_dir}/spec/workplace_spec.rb", "#{@workshop_dir}/spec/workplace_spec.rb")
|
|
14
|
-
system "cd #{@workshop_dir}/lib && emacs -nw -q -l
|
|
18
|
+
system "cd #{@workshop_dir}/lib && emacs -nw -q -l #{@workshop_dir}/.emacs.d/init.el sentence.org workplace.rb"
|
|
15
19
|
start_time = Time.now
|
|
16
|
-
typing_discriminant(
|
|
20
|
+
typing_discriminant(@workshop_dir)
|
|
17
21
|
elapsed_time = time_check(start_time: start_time)
|
|
18
22
|
p "#{elapsed_time} sec"
|
|
19
23
|
# mk_training_data(elapsed_time: elapsed_time, prac_dir: @prac_dir)
|
data/lib/ruby_learner/version.rb
CHANGED