ruby_learner 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +17 -17
  4. data/{workshop → lib/datas}/emacs_help.org +0 -0
  5. data/lib/datas/final_history_sequential.txt +1 -0
  6. data/lib/ruby_learner/methods.rb +183 -24
  7. data/lib/ruby_learner/ruby_learner.rb +15 -7
  8. data/lib/ruby_learner/typing_practice.rb +6 -2
  9. data/lib/ruby_learner/version.rb +1 -1
  10. data/questions/sequential_check/section_1/part_1/lib/answer.rb +3 -9
  11. data/questions/sequential_check/section_1/part_1/lib/sentence.org +2 -9
  12. data/questions/sequential_check/section_1/part_1/lib/workplace.rb +1 -5
  13. data/questions/sequential_check/section_1/part_1/spec/workplace_spec.rb +6 -7
  14. data/questions/sequential_check/section_1/part_2/lib/answer.rb +4 -15
  15. data/questions/sequential_check/section_1/part_2/lib/sentence.org +2 -12
  16. data/questions/sequential_check/section_1/part_2/lib/workplace.rb +1 -5
  17. data/questions/sequential_check/section_1/part_2/spec/workplace_spec.rb +7 -9
  18. data/questions/sequential_check/section_1/part_3/lib/answer.rb +3 -0
  19. data/questions/sequential_check/section_1/part_3/lib/sentence.org +2 -0
  20. data/questions/sequential_check/section_1/part_3/lib/workplace.rb +1 -0
  21. data/questions/sequential_check/section_1/part_3/spec/spec_helper.rb +100 -0
  22. data/questions/sequential_check/section_1/part_3/spec/workplace_spec.rb +9 -0
  23. data/questions/sequential_check/section_10/part_1/lib/answer.rb +7 -0
  24. data/questions/sequential_check/section_10/part_1/lib/sentence.org +2 -0
  25. data/questions/sequential_check/section_10/part_1/lib/workplace.rb +1 -0
  26. data/questions/sequential_check/section_10/part_1/spec/spec_helper.rb +100 -0
  27. data/questions/sequential_check/section_10/part_1/spec/workplace_spec.rb +10 -0
  28. data/questions/sequential_check/section_10/part_2/lib/answer.rb +8 -0
  29. data/questions/sequential_check/section_10/part_2/lib/sentence.org +3 -0
  30. data/questions/sequential_check/section_10/part_2/lib/workplace.rb +1 -0
  31. data/questions/sequential_check/section_10/part_2/spec/spec_helper.rb +100 -0
  32. data/questions/sequential_check/section_10/part_2/spec/workplace_spec.rb +15 -0
  33. data/questions/sequential_check/section_11/part_1/lib/answer.rb +7 -0
  34. data/questions/sequential_check/section_11/part_1/lib/sentence.org +4 -0
  35. data/questions/sequential_check/section_11/part_1/lib/workplace.rb +1 -0
  36. data/questions/sequential_check/section_11/part_1/spec/spec_helper.rb +100 -0
  37. data/questions/sequential_check/section_11/part_1/spec/workplace_spec.rb +15 -0
  38. data/questions/sequential_check/section_11/part_2/lib/answer.rb +6 -0
  39. data/questions/sequential_check/section_11/part_2/lib/sentence.org +2 -0
  40. data/questions/sequential_check/section_11/part_2/lib/workplace.rb +1 -0
  41. data/questions/sequential_check/section_11/part_2/spec/spec_helper.rb +100 -0
  42. data/questions/sequential_check/section_11/part_2/spec/workplace_spec.rb +13 -0
  43. data/questions/sequential_check/section_2/part_1/lib/answer.rb +8 -0
  44. data/questions/sequential_check/section_2/part_1/lib/sentence.org +2 -0
  45. data/questions/sequential_check/section_2/part_1/lib/workplace.rb +1 -0
  46. data/questions/sequential_check/section_2/part_1/spec/spec_helper.rb +100 -0
  47. data/questions/sequential_check/section_2/part_1/spec/workplace_spec.rb +14 -0
  48. data/questions/sequential_check/section_2/part_2/lib/answer.rb +14 -0
  49. data/questions/sequential_check/section_2/part_2/lib/sentence.org +2 -0
  50. data/questions/sequential_check/section_2/part_2/lib/workplace.rb +1 -0
  51. data/questions/sequential_check/section_2/part_2/spec/spec_helper.rb +100 -0
  52. data/questions/sequential_check/section_2/part_2/spec/workplace_spec.rb +14 -0
  53. data/questions/sequential_check/section_3/part_1/lib/answer.rb +11 -0
  54. data/questions/sequential_check/section_3/part_1/lib/sentence.org +2 -0
  55. data/questions/sequential_check/section_3/part_1/lib/workplace.rb +1 -0
  56. data/questions/sequential_check/section_3/part_1/spec/spec_helper.rb +100 -0
  57. data/questions/sequential_check/section_3/part_1/spec/workplace_spec.rb +15 -0
  58. data/questions/sequential_check/section_4/part_1/lib/answer.rb +9 -0
  59. data/questions/sequential_check/section_4/part_1/lib/sentence.org +2 -0
  60. data/questions/sequential_check/section_4/part_1/lib/workplace.rb +2 -0
  61. data/questions/sequential_check/section_4/part_1/spec/spec_helper.rb +100 -0
  62. data/questions/sequential_check/section_4/part_1/spec/workplace_spec.rb +14 -0
  63. data/questions/sequential_check/section_5/part_1/lib/answer.rb +8 -0
  64. data/questions/sequential_check/section_5/part_1/lib/sentence.org +2 -0
  65. data/questions/sequential_check/section_5/part_1/lib/workplace.rb +1 -0
  66. data/questions/sequential_check/section_5/part_1/spec/spec_helper.rb +100 -0
  67. data/questions/sequential_check/section_5/part_1/spec/workplace_spec.rb +14 -0
  68. data/questions/sequential_check/section_5/part_2/lib/answer.rb +5 -0
  69. data/questions/sequential_check/section_5/part_2/lib/sentence.org +2 -0
  70. data/questions/sequential_check/section_5/part_2/lib/workplace.rb +1 -0
  71. data/questions/sequential_check/section_5/part_2/spec/spec_helper.rb +100 -0
  72. data/questions/sequential_check/section_5/part_2/spec/workplace_spec.rb +9 -0
  73. data/questions/sequential_check/section_6/part_1/lib/answer.rb +5 -0
  74. data/questions/sequential_check/section_6/part_1/lib/sentence.org +2 -0
  75. data/questions/sequential_check/section_6/part_1/lib/workplace.rb +1 -0
  76. data/questions/sequential_check/section_6/part_1/spec/spec_helper.rb +100 -0
  77. data/questions/sequential_check/section_6/part_1/spec/workplace_spec.rb +14 -0
  78. data/questions/sequential_check/section_6/part_2/lib/answer.rb +7 -0
  79. data/questions/sequential_check/section_6/part_2/lib/sentence.org +3 -0
  80. data/questions/sequential_check/section_6/part_2/lib/workplace.rb +1 -0
  81. data/questions/sequential_check/section_6/part_2/spec/spec_helper.rb +100 -0
  82. data/questions/sequential_check/section_6/part_2/spec/workplace_spec.rb +14 -0
  83. data/questions/sequential_check/section_6/part_3/lib/answer.rb +7 -0
  84. data/questions/sequential_check/section_6/part_3/lib/sentence.org +3 -0
  85. data/questions/sequential_check/section_6/part_3/lib/workplace.rb +1 -0
  86. data/questions/sequential_check/section_6/part_3/spec/spec_helper.rb +100 -0
  87. data/questions/sequential_check/section_6/part_3/spec/workplace_spec.rb +9 -0
  88. data/questions/sequential_check/section_6/part_4/lib/answer.rb +9 -0
  89. data/questions/sequential_check/section_6/part_4/lib/sentence.org +3 -0
  90. data/questions/sequential_check/section_6/part_4/lib/workplace.rb +1 -0
  91. data/questions/sequential_check/section_6/part_4/spec/spec_helper.rb +100 -0
  92. data/questions/sequential_check/section_6/part_4/spec/workplace_spec.rb +9 -0
  93. data/questions/sequential_check/section_7/part_1/lib/answer.rb +5 -0
  94. data/questions/sequential_check/section_7/part_1/lib/sentence.org +3 -0
  95. data/questions/sequential_check/section_7/part_1/lib/workplace.rb +1 -0
  96. data/questions/sequential_check/section_7/part_1/spec/spec_helper.rb +100 -0
  97. data/questions/sequential_check/section_7/part_1/spec/workplace_spec.rb +14 -0
  98. data/questions/sequential_check/section_7/part_2/lib/answer.rb +9 -0
  99. data/questions/sequential_check/section_7/part_2/lib/sentence.org +2 -0
  100. data/questions/sequential_check/section_7/part_2/lib/workplace.rb +1 -0
  101. data/questions/sequential_check/section_7/part_2/spec/spec_helper.rb +100 -0
  102. data/questions/sequential_check/section_7/part_2/spec/workplace_spec.rb +10 -0
  103. data/questions/sequential_check/section_8/part_1/lib/answer.rb +9 -0
  104. data/questions/sequential_check/section_8/part_1/lib/sentence.org +2 -0
  105. data/questions/sequential_check/section_8/part_1/lib/workplace.rb +1 -0
  106. data/questions/sequential_check/section_8/part_1/spec/spec_helper.rb +100 -0
  107. data/questions/sequential_check/section_8/part_1/spec/workplace_spec.rb +15 -0
  108. data/questions/sequential_check/section_9/part_1/lib/answer.rb +5 -0
  109. data/questions/sequential_check/section_9/part_1/lib/sentence.org +2 -0
  110. data/questions/sequential_check/section_9/part_1/lib/workplace.rb +1 -0
  111. data/questions/sequential_check/section_9/part_1/spec/spec_helper.rb +100 -0
  112. data/questions/sequential_check/section_9/part_1/spec/workplace_spec.rb +10 -0
  113. data/questions/sequential_check/section_9/part_2/lib/answer.rb +7 -0
  114. data/questions/sequential_check/section_9/part_2/lib/sentence.org +2 -0
  115. data/questions/sequential_check/section_9/part_2/lib/workplace.rb +1 -0
  116. data/questions/sequential_check/section_9/part_2/spec/spec_helper.rb +100 -0
  117. data/questions/sequential_check/section_9/part_2/spec/workplace_spec.rb +10 -0
  118. data/questions/sequential_check/section_9/part_3/lib/answer.rb +12 -0
  119. data/questions/sequential_check/section_9/part_3/lib/sentence.org +2 -0
  120. data/questions/sequential_check/section_9/part_3/lib/workplace.rb +1 -0
  121. data/questions/sequential_check/section_9/part_3/spec/spec_helper.rb +100 -0
  122. data/questions/sequential_check/section_9/part_3/spec/workplace_spec.rb +10 -0
  123. data/takahashi/docs/README.org +9 -0
  124. data/takahashi/docs/README.org~ +139 -0
  125. data/takahashi/docs/drill.html +189 -135
  126. data/takahashi/docs/drill.html~ +171 -187
  127. data/takahashi/docs/drill.org +163 -120
  128. data/takahashi/sample_prog/answer/10_2.rb +6 -0
  129. data/takahashi/sample_prog/answer/8_1.rb +9 -0
  130. data/takahashi/sample_prog/question/10_1.rb +2 -0
  131. data/takahashi/sample_prog/question/10_2.rb +3 -0
  132. data/takahashi/sample_prog/question/11_1.rb +4 -0
  133. data/takahashi/sample_prog/question/11_2.rb +2 -0
  134. data/takahashi/sample_prog/question/1_1.rb +2 -0
  135. data/takahashi/sample_prog/question/1_2.rb +2 -0
  136. data/takahashi/sample_prog/question/1_3.rb +2 -0
  137. data/takahashi/sample_prog/question/2_1.rb +2 -0
  138. data/takahashi/sample_prog/question/2_2.rb +2 -0
  139. data/takahashi/sample_prog/question/3_1.rb +2 -0
  140. data/takahashi/sample_prog/question/4_1.rb +2 -0
  141. data/takahashi/sample_prog/question/5_1.rb +2 -0
  142. data/takahashi/sample_prog/question/5_2.rb +2 -0
  143. data/takahashi/sample_prog/question/6_1.rb +2 -0
  144. data/takahashi/sample_prog/question/6_2.rb +3 -0
  145. data/takahashi/sample_prog/question/6_3.rb +3 -0
  146. data/takahashi/sample_prog/question/6_4.rb +3 -0
  147. data/takahashi/sample_prog/question/7_1.rb +3 -0
  148. data/takahashi/sample_prog/question/7_2.rb +2 -0
  149. data/takahashi/sample_prog/question/8_1.rb +2 -0
  150. data/takahashi/sample_prog/question/9_1.rb +2 -0
  151. data/takahashi/sample_prog/question/9_2.rb +2 -0
  152. data/takahashi/sample_prog/question/9_3.rb +2 -0
  153. data/workshop/emacs.d/#init# +1 -0
  154. data/workshop/emacs.d/init.el +8 -8
  155. data/workshop/emacs.d/ruby_learner_init.el +8 -8
  156. data/workshop/lib/for-def-read.rb +3 -0
  157. data/workshop/lib/for-read.txt +5 -0
  158. metadata +138 -7
  159. data/lib/ruby_learner/h.rb +0 -14
  160. data/lib/ruby_learner/random_h.rb +0 -16
  161. data/lib/ruby_learner/sequential_h.rb +0 -15
  162. data/workshop/training_data.txt +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8e467e2ece5ed832c2cb2e329ac6bcffb080344
4
- data.tar.gz: 7aba3bf7a60ebb8ef8111bbfd839a28bafa0aee9
3
+ metadata.gz: a3869d64ff647ab1b56c965f07268670fbc96c27
4
+ data.tar.gz: 40ce344b3d77c003be5d8e4385ad94ac8f41fa46
5
5
  SHA512:
6
- metadata.gz: df03c32c4d5bfb34f590c94faf32171e955602e6d9992143efedca1e7b7676a0c1d18d701b0718ec7fc17b5714da60c6bb423ab3c2fded61de6325419759b15b
7
- data.tar.gz: 3fe245a5704587eebac29f6c600abde1d60a7fcee844890039412544e0aed8f72ebbb97c61dfd92931a0ea5e2a90f3f27c4b2286de008f539d4eaec8411c2aab
6
+ metadata.gz: bc6358593f83e3ae9ea1923aa5cd27f09b0b30c367a0c1f742be75f868e509a9a0c743d22453dcb12a67cd8d33e28a11e55228adf4b64cbd8875f1601e8b3388
7
+ data.tar.gz: fbefbd17018e40ece793648ac3dd2ccb5cc93d511b628b707878baa98f920d44a5c82103e3a425fbf6c193c6a5cf3eb948dfef1204d1887a510aef9570e4f61f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_learner (1.0.0)
4
+ ruby_learner (1.0.1)
5
5
  colorize
6
6
  diff-lcs
7
7
  minitest (~> 5.10.3)
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
- emacs_key: confirm emacs key-bindings
38
- sequential_check [section:1~1] [part:1~2]: learning drill.
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
@@ -4,21 +4,147 @@
4
4
  # end
5
5
  require 'rubocop'
6
6
 
7
- def time_check(start_time: Time)
8
- end_time = Time.now
9
- elapsed_time = end_time - start_time - 1
10
- return elapsed_time
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 typing_discriminant(dir: workshop_dir)
14
- loop do
15
- flag_rspec = rspec_check(dir: dir)
16
- flag_rubocop = rubocop_check(file: "#{dir}/lib/workplace.rb", dir: dir)
17
- if flag_rspec == true && flag_rubocop == true
18
- break
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
- restore(file: "#{dir}/lib/workplace.rb", workshop_dir: dir)
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 rspec_check(dir: workshop_dir)
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 #{dir} && rspec spec/workplace_spec.rb"
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
- flag_rspec = true
229
+ flag_exit = true
73
230
  break
74
231
  elsif select == 'answer'
75
- system "cd #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/ruby_learner_init.el sentence.org workplace.rb"
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 #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/init.el sentence.org workplace.rb"
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: String, dir: workshop_dir)
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
- flag_rubocop = true
261
+ flag_exit = true
104
262
  break
105
263
  elsif select == 'answer'
106
- system "cd #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/ruby_learner_init.el sentence.org workplace.rb"
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 #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/init.el sentence.org workplace.rb"
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
- 0.times {
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(*_argv)
25
- system("cat #{@workshop_dir}/emacs_help.org")
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~1] [part:1~2]','learning drill'
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
- seq_dir = "#{@gem_dir}/questions/sequential_check/section_#{dir_num}/part_#{file_num}"
31
- typing_prac_class = TypingPractice.new(workshop_dir: @workshop_dir)
32
- typing_prac_class.prac_sequence(mode_dir: seq_dir)
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(*_argv)
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 ~/ruby_learner/workshop/emacs.d/init.el sentence.org workplace.rb"
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(dir: @workshop_dir)
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)
@@ -1,3 +1,3 @@
1
1
  module RubyLearner
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,9 +1,3 @@
1
- # 1.1-for_system.rb
2
-
3
- def for_system(aaa, bbb)
4
- answer = 0
5
- bbb.each do
6
- answer += aaa
7
- end
8
- answer
9
- end
1
+ # section_1/part_1/answer.rb
2
+ # 1-1-print.rb
3
+ print 'Hello, Ruby.'