ruby_learner 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +58 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +65 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/new_terminal +25 -0
  13. data/bin/setup +8 -0
  14. data/docs/happy_ruby/RussOlsen_EloquentRuby_c1.pdf +0 -0
  15. data/docs/happy_ruby/RussOlsen_EloquentRuby_c5.pdf +0 -0
  16. data/docs/happy_ruby/TanoshiiRuby_v3_c23.pdf +0 -0
  17. data/docs/happy_ruby/TanoshiiRuby_v5_c1.pdf +0 -0
  18. data/docs/happy_ruby/TanoshiiRuby_v5_c2-3.pdf +0 -0
  19. data/docs/happy_ruby/c2.ipynb +479 -0
  20. data/docs/happy_ruby/c3_4.ipynb +237 -0
  21. data/docs/seminar/8-1.org +18 -0
  22. data/exe/ruby_learner +5 -0
  23. data/lib/ruby_learner/h.rb +14 -0
  24. data/lib/ruby_learner/methods.rb +131 -0
  25. data/lib/ruby_learner/random_h.rb +16 -0
  26. data/lib/ruby_learner/ruby_learner.rb +43 -0
  27. data/lib/ruby_learner/sequential_h.rb +15 -0
  28. data/lib/ruby_learner/typing_practice.rb +21 -0
  29. data/lib/ruby_learner/version.rb +3 -0
  30. data/questions/random_check/.rspec +1 -0
  31. data/questions/random_check/random_h.rb +16 -0
  32. data/questions/random_check/section_1/.rspec +1 -0
  33. data/questions/random_check/section_1/lib/answer.rb +15 -0
  34. data/questions/random_check/section_1/lib/sentence.org +9 -0
  35. data/questions/random_check/section_1/lib/workplace.rb +5 -0
  36. data/questions/random_check/section_1/spec/spec_helper.rb +100 -0
  37. data/questions/random_check/section_1/spec/workplace_spec.rb +10 -0
  38. data/questions/random_check/section_2/.rspec +1 -0
  39. data/questions/random_check/section_2/lib/answer.rb +17 -0
  40. data/questions/random_check/section_2/lib/sentence.org +12 -0
  41. data/questions/random_check/section_2/lib/workplace.rb +5 -0
  42. data/questions/random_check/section_2/spec/.rspec +1 -0
  43. data/questions/random_check/section_2/spec/spec_helper.rb +100 -0
  44. data/questions/random_check/section_2/spec/workplace_spec.rb +11 -0
  45. data/questions/sequential_check/section_1/part_1/lib/answer.rb +9 -0
  46. data/questions/sequential_check/section_1/part_1/lib/sentence.org +9 -0
  47. data/questions/sequential_check/section_1/part_1/lib/workplace.rb +5 -0
  48. data/questions/sequential_check/section_1/part_1/spec/spec_helper.rb +100 -0
  49. data/questions/sequential_check/section_1/part_1/spec/workplace_spec.rb +10 -0
  50. data/questions/sequential_check/section_1/part_2/lib/answer.rb +16 -0
  51. data/questions/sequential_check/section_1/part_2/lib/sentence.org +12 -0
  52. data/questions/sequential_check/section_1/part_2/lib/workplace.rb +5 -0
  53. data/questions/sequential_check/section_1/part_2/spec/.rspec +1 -0
  54. data/questions/sequential_check/section_1/part_2/spec/spec_helper.rb +100 -0
  55. data/questions/sequential_check/section_1/part_2/spec/workplace_spec.rb +11 -0
  56. data/ruby_learner.gemspec +41 -0
  57. data/takahashi/docs/README.org +139 -0
  58. data/takahashi/docs/drill.html +875 -0
  59. data/takahashi/docs/drill.html~ +877 -0
  60. data/takahashi/docs/drill.org +446 -0
  61. data/takahashi/docs/ruby_for_beginner.html +2642 -0
  62. data/takahashi/docs/ruby_for_beginner.org +1430 -0
  63. data/takahashi/sample_prog/answer/10_1.rb +5 -0
  64. data/takahashi/sample_prog/answer/11_1.rb +5 -0
  65. data/takahashi/sample_prog/answer/11_2.rb +4 -0
  66. data/takahashi/sample_prog/answer/1_1.rb +1 -0
  67. data/takahashi/sample_prog/answer/1_2.rb +1 -0
  68. data/takahashi/sample_prog/answer/1_3.rb +1 -0
  69. data/takahashi/sample_prog/answer/2_1.rb +5 -0
  70. data/takahashi/sample_prog/answer/2_2.rb +12 -0
  71. data/takahashi/sample_prog/answer/3_1.rb +10 -0
  72. data/takahashi/sample_prog/answer/4_1.rb +7 -0
  73. data/takahashi/sample_prog/answer/5_1.rb +6 -0
  74. data/takahashi/sample_prog/answer/5_2.rb +3 -0
  75. data/takahashi/sample_prog/answer/6_1.rb +3 -0
  76. data/takahashi/sample_prog/answer/6_2.rb +5 -0
  77. data/takahashi/sample_prog/answer/6_3.rb +5 -0
  78. data/takahashi/sample_prog/answer/6_4.rb +7 -0
  79. data/takahashi/sample_prog/answer/7_1.rb +3 -0
  80. data/takahashi/sample_prog/answer/7_2.rb +8 -0
  81. data/takahashi/sample_prog/answer/9_1.rb +3 -0
  82. data/takahashi/sample_prog/answer/9_2.rb +5 -0
  83. data/takahashi/sample_prog/answer/9_3.rb +10 -0
  84. data/takahashi/sample_prog/answer/hello.rb +3 -0
  85. data/workshop/.rspec +1 -0
  86. data/workshop/emacs.d/ac-comphist.dat +50 -0
  87. data/workshop/emacs.d/cp5022x.el +156 -0
  88. data/workshop/emacs.d/elpa/archives/gnu/archive-contents +1240 -0
  89. data/workshop/emacs.d/elpa/archives/melpa/archive-contents +2 -0
  90. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-autoloads.el +65 -0
  91. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.el +551 -0
  92. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.elc +0 -0
  93. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-pkg.el +6 -0
  94. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.el +2164 -0
  95. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.elc +0 -0
  96. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ada-mode +72 -0
  97. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c++-mode +99 -0
  98. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c-mode +55 -0
  99. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/caml-mode +231 -0
  100. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojure-mode +580 -0
  101. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojurescript-mode +475 -0
  102. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/coq-mode +278 -0
  103. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/css-mode +874 -0
  104. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/erlang-mode +216 -0
  105. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ess-julia-mode +37 -0
  106. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/go-mode +25 -0
  107. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/haskell-mode +679 -0
  108. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/java-mode +53 -0
  109. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/js-mode +148 -0
  110. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/julia-mode +37 -0
  111. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/lua-mode +21 -0
  112. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/nim-mode +70 -0
  113. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/objc-mode +161 -0
  114. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/octave-mode +46 -0
  115. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/php-mode +6144 -0
  116. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/python-mode +379 -0
  117. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/qml-mode +183 -0
  118. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ruby-mode +181 -0
  119. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scala-mode +1347 -0
  120. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scheme-mode +216 -0
  121. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sclang-mode +1481 -0
  122. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sh-mode +182 -0
  123. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/swift-mode +87 -0
  124. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tcl-mode +172 -0
  125. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ts-mode +797 -0
  126. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tuareg-mode +231 -0
  127. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/verilog-mode +313 -0
  128. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-autoloads.el +16 -0
  129. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-pkg.el +2 -0
  130. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.el +90 -0
  131. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.elc +0 -0
  132. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-autoloads.el +26 -0
  133. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-pkg.el +2 -0
  134. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.el +877 -0
  135. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.elc +0 -0
  136. data/workshop/emacs.d/elpa/haml-mode-readme.txt +8 -0
  137. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.el +918 -0
  138. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.elc +0 -0
  139. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-autoloads.el +32 -0
  140. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-pkg.el +8 -0
  141. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.el +912 -0
  142. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.elc +0 -0
  143. data/workshop/emacs.d/elpa/ox-bibtex-chinese-readme.txt +21 -0
  144. data/workshop/emacs.d/elpa/popup-20160709.729/popup-autoloads.el +15 -0
  145. data/workshop/emacs.d/elpa/popup-20160709.729/popup-pkg.el +2 -0
  146. data/workshop/emacs.d/elpa/popup-20160709.729/popup.el +1432 -0
  147. data/workshop/emacs.d/elpa/popup-20160709.729/popup.elc +0 -0
  148. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-autoloads.el +33 -0
  149. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-pkg.el +2 -0
  150. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.el +470 -0
  151. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.elc +0 -0
  152. data/workshop/emacs.d/elpa/yaml-mode-readme.txt +25 -0
  153. data/workshop/emacs.d/haml-mode-master/.gitignore +1 -0
  154. data/workshop/emacs.d/haml-mode-master/.mailmap +2 -0
  155. data/workshop/emacs.d/haml-mode-master/MIT-LICENSE +20 -0
  156. data/workshop/emacs.d/haml-mode-master/README.md +47 -0
  157. data/workshop/emacs.d/haml-mode-master/haml-mode.el +887 -0
  158. data/workshop/emacs.d/iceberg_theme.el +202 -0
  159. data/workshop/emacs.d/init-open-recentf.el +133 -0
  160. data/workshop/emacs.d/init.el +229 -0
  161. data/workshop/emacs.d/inits/line-num.el +264 -0
  162. data/workshop/emacs.d/install-elisp.el +366 -0
  163. data/workshop/emacs.d/markdown-mode/markdown-mode.el +5978 -0
  164. data/workshop/emacs.d/notes +12 -0
  165. data/workshop/emacs.d/processing-mode/processing-mode.el +275 -0
  166. data/workshop/emacs.d/recentf +31 -0
  167. data/workshop/emacs.d/ruby-mode/inf-ruby.el +416 -0
  168. data/workshop/emacs.d/ruby-mode/rdoc-mode.el +130 -0
  169. data/workshop/emacs.d/ruby-mode/ruby-electric.el +205 -0
  170. data/workshop/emacs.d/ruby-mode/ruby-mode.el +1496 -0
  171. data/workshop/emacs.d/ruby-mode/ruby-style.el +78 -0
  172. data/workshop/emacs.d/ruby-mode/rubydb2x.el +104 -0
  173. data/workshop/emacs.d/ruby-mode/rubydb3x.el +115 -0
  174. data/workshop/emacs.d/ruby_learner_init.el +244 -0
  175. data/workshop/emacs.d/themes/dracula-theme.el +431 -0
  176. data/workshop/emacs.d/themes/iceberg-theme.el +205 -0
  177. data/workshop/emacs.d/themes/my-misterioso-theme.el +109 -0
  178. data/workshop/emacs.d/themes/my-wombat-theme.el +121 -0
  179. data/workshop/emacs.d/wiki-mode/wiki.el +976 -0
  180. data/workshop/emacs_help.org +34 -0
  181. data/workshop/lib/answer.rb +1 -0
  182. data/workshop/lib/sentence.org +1 -0
  183. data/workshop/lib/workplace.rb +1 -0
  184. data/workshop/restore/empty.rb +0 -0
  185. data/workshop/spec/spec_helper.rb +100 -0
  186. data/workshop/spec/workplace_spec.rb +1 -0
  187. data/workshop/training_data.txt +3 -0
  188. metadata +343 -0
@@ -0,0 +1,237 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "toc": "true"
7
+ },
8
+ "source": [
9
+ "# Table of Contents\n",
10
+ " <p><div class=\"lev1 toc-item\"><a href=\"#テキスト\" data-toc-modified-id=\"テキスト-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>テキスト</a></div><div class=\"lev1 toc-item\"><a href=\"#配列(Array)\" data-toc-modified-id=\"配列(Array)-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>配列(Array)</a></div><div class=\"lev2 toc-item\"><a href=\"#size\" data-toc-modified-id=\"size-21\"><span class=\"toc-item-num\">2.1&nbsp;&nbsp;</span>size</a></div><div class=\"lev2 toc-item\"><a href=\"#each\" data-toc-modified-id=\"each-22\"><span class=\"toc-item-num\">2.2&nbsp;&nbsp;</span>each</a></div><div class=\"lev1 toc-item\"><a href=\"#ハッシュ(hash)\" data-toc-modified-id=\"ハッシュ(hash)-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>ハッシュ(hash)</a></div><div class=\"lev2 toc-item\"><a href=\"#シンボル\" data-toc-modified-id=\"シンボル-31\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>シンボル</a></div><div class=\"lev2 toc-item\"><a href=\"#操作\" data-toc-modified-id=\"操作-32\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>操作</a></div><div class=\"lev2 toc-item\"><a href=\"#each---key,-val\" data-toc-modified-id=\"each---key,-val-33\"><span class=\"toc-item-num\">3.3&nbsp;&nbsp;</span>each - key, val</a></div><div class=\"lev1 toc-item\"><a href=\"#正規表現(Regular-expression)\" data-toc-modified-id=\"正規表現(Regular-expression)-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>正規表現(Regular expression)</a></div><div class=\"lev1 toc-item\"><a href=\"#CLI(Command-Line-Interface)c4\" data-toc-modified-id=\"CLI(Command-Line-Interface)c4-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>CLI(Command Line Interface)c4</a></div><div class=\"lev1 toc-item\"><a href=\"#課題\" data-toc-modified-id=\"課題-6\"><span class=\"toc-item-num\">6&nbsp;&nbsp;</span>課題</a></div>"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "markdown",
15
+ "metadata": {},
16
+ "source": [
17
+ "# テキスト\n",
18
+ "\n",
19
+ "* [たのしいruby c3-4](TanoshiiRuby_v5_c2-3.pdf)"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "markdown",
24
+ "metadata": {},
25
+ "source": [
26
+ "# 配列(Array)"
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "code",
31
+ "execution_count": 3,
32
+ "metadata": {},
33
+ "outputs": [
34
+ {
35
+ "data": {
36
+ "text/plain": [
37
+ "[\"小林\", \"林\", \"高野\", \"森岡\"]"
38
+ ]
39
+ },
40
+ "execution_count": 3,
41
+ "metadata": {},
42
+ "output_type": "execute_result"
43
+ }
44
+ ],
45
+ "source": [
46
+ "names = ['小林', '林', '高野', '森岡']"
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "markdown",
51
+ "metadata": {},
52
+ "source": [
53
+ "## size\n",
54
+ "## each"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": 6,
60
+ "metadata": {},
61
+ "outputs": [
62
+ {
63
+ "name": "stdout",
64
+ "output_type": "stream",
65
+ "text": [
66
+ "小林\n",
67
+ "林\n",
68
+ "高野\n",
69
+ "森岡\n"
70
+ ]
71
+ },
72
+ {
73
+ "data": {
74
+ "text/plain": [
75
+ "[\"小林\", \"林\", \"高野\", \"森岡\"]"
76
+ ]
77
+ },
78
+ "execution_count": 6,
79
+ "metadata": {},
80
+ "output_type": "execute_result"
81
+ }
82
+ ],
83
+ "source": [
84
+ "# each_name.rb\n",
85
+ "names = ['小林', '林', '高野', '森岡']\n",
86
+ "names.each{|name|\n",
87
+ " puts name\n",
88
+ "}"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "markdown",
93
+ "metadata": {},
94
+ "source": [
95
+ "# ハッシュ(hash)"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "markdown",
100
+ "metadata": {},
101
+ "source": [
102
+ "## シンボル\n",
103
+ "## 操作\n",
104
+ "## each - key, val"
105
+ ]
106
+ },
107
+ {
108
+ "cell_type": "markdown",
109
+ "metadata": {},
110
+ "source": [
111
+ "# 正規表現(Regular expression)"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "markdown",
116
+ "metadata": {
117
+ "collapsed": true
118
+ },
119
+ "source": [
120
+ "# CLI(Command Line Interface)c4\n",
121
+ "\n",
122
+ "* /Users/bob/Github/TeamNishitani/ruby_novice/docs/happy_ruby\n",
123
+ "* grepもどきの作成"
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "markdown",
128
+ "metadata": {},
129
+ "source": [
130
+ "# 課題"
131
+ ]
132
+ },
133
+ {
134
+ "cell_type": "markdown",
135
+ "metadata": {
136
+ "collapsed": true
137
+ },
138
+ "source": [
139
+ "これをclassにすると以下のとおり.\n",
140
+ "```ruby\n",
141
+ "class Hello\n",
142
+ " def hello(name=\"Ruby\")\n",
143
+ " return \"Hello, #{name}.\"\n",
144
+ " end\n",
145
+ "end\n",
146
+ "```\n",
147
+ "さらにrspecを付け足すと,\n",
148
+ "```ruby\n",
149
+ "describe Hello do\n",
150
+ " it 'should return greeting' do\n",
151
+ " text = 'Hello, Ruby!'\n",
152
+ " hello = Hello.new\n",
153
+ " expect(hello.hello).to eq text\n",
154
+ " end\n",
155
+ "end\n",
156
+ "```\n",
157
+ "\n",
158
+ "となる.rspecまで考えるとprintをmethod内でしちゃうのではなく,returnして欲しいよね.\n",
159
+ "```bash\n",
160
+ "rspec hello_name_spec.rb Mon Sep 4 17:07:29 2017\n",
161
+ "\n",
162
+ "Hello\n",
163
+ " should return greeting\n",
164
+ "\n",
165
+ "Finished in 0.0011 seconds (files took 0.16208 seconds to load)\n",
166
+ "1 example, 0 failures\n",
167
+ "\n",
168
+ "```"
169
+ ]
170
+ },
171
+ {
172
+ "cell_type": "code",
173
+ "execution_count": null,
174
+ "metadata": {
175
+ "collapsed": true
176
+ },
177
+ "outputs": [],
178
+ "source": []
179
+ }
180
+ ],
181
+ "metadata": {
182
+ "kernelspec": {
183
+ "display_name": "Ruby 2.2.2",
184
+ "language": "ruby",
185
+ "name": "ruby"
186
+ },
187
+ "language_info": {
188
+ "file_extension": ".rb",
189
+ "mimetype": "application/x-ruby",
190
+ "name": "ruby",
191
+ "version": "2.2.2"
192
+ },
193
+ "latex_envs": {
194
+ "LaTeX_envs_menu_present": true,
195
+ "autocomplete": true,
196
+ "bibliofile": "biblio.bib",
197
+ "cite_by": "apalike",
198
+ "current_citInitial": 1,
199
+ "eqLabelWithNumbers": true,
200
+ "eqNumInitial": 1,
201
+ "hotkeys": {
202
+ "equation": "Ctrl-E",
203
+ "itemize": "Ctrl-I"
204
+ },
205
+ "labels_anchors": false,
206
+ "latex_user_defs": false,
207
+ "report_style_numbering": false,
208
+ "user_envs_cfg": false
209
+ },
210
+ "toc": {
211
+ "colors": {
212
+ "hover_highlight": "#DAA520",
213
+ "navigate_num": "#000000",
214
+ "navigate_text": "#333333",
215
+ "running_highlight": "#FF0000",
216
+ "selected_highlight": "#FFD700",
217
+ "sidebar_border": "#EEEEEE",
218
+ "wrapper_background": "#FFFFFF"
219
+ },
220
+ "moveMenuLeft": true,
221
+ "nav_menu": {
222
+ "height": "84px",
223
+ "width": "252px"
224
+ },
225
+ "navigate_menu": true,
226
+ "number_sections": true,
227
+ "sideBar": true,
228
+ "threshold": 4,
229
+ "toc_cell": true,
230
+ "toc_section_display": "block",
231
+ "toc_window_display": true,
232
+ "widenNotebook": false
233
+ }
234
+ },
235
+ "nbformat": 4,
236
+ "nbformat_minor": 2
237
+ }
@@ -0,0 +1,18 @@
1
+ #+STARTUP: indent nolineimages
2
+
3
+ * Document化
4
+ ** アプリの説明書の作成
5
+ - Readme と org にまとめる
6
+ * ruby_learnerについて
7
+ ** 高橋さん(楽しいruby)
8
+ - 回答例をrubocopで精査を行う
9
+ - 文章に責任を持つ
10
+ ** システムについて
11
+ - 見直し(Restore)機能(回答履歴を残しておく。ファイル名はわかりやすく)
12
+ - randomcheck廃止。secentialに変更。
13
+ - rspec完了後、rubocopで異常個所の出力(同時にabc_size_checkも)
14
+ - 振る舞いに責任を持つ
15
+
16
+ ** 一通り終わってから
17
+ - 楽しいRuby(第3版)の22,23章を参考に
18
+ - 一種のツールの作成になるのかな?
data/exe/ruby_learner ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "ruby_learner/ruby_learner.rb"
4
+
5
+ RubyLearner::CLI.start(ARGV)
@@ -0,0 +1,14 @@
1
+ # to open q.rb
2
+ # c-x 2: split window vertically
3
+ # c-x c-f: find file and input q.rb
4
+ # open a.rb as above
5
+ # c-x 3: split window horizontally
6
+ # c-x c-f: find file and input a.rb
7
+ # move the other window
8
+ # c-x o: other windw
9
+ # then edit a.rb as q.rb
10
+
11
+ # c-a: move ahead
12
+ # c-d: delete character
13
+ # c-x c-s: save file
14
+ # c-x c-c: quit edit
@@ -0,0 +1,131 @@
1
+ # -*- coding: utf-8 -*-
2
+ # def open_terminal(init_dir: String)
3
+ # system "osascript -e 'tell application \"Terminal\" to do script \"cd #{init_dir} \" '"
4
+ # end
5
+ require 'rubocop'
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
11
+ end
12
+
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
19
+ end
20
+ end
21
+ restore(file: "#{dir}/lib/workplace.rb", workshop_dir: dir)
22
+ end
23
+
24
+ def instruct_print
25
+ puts "continue >>> [RET]"
26
+ puts "stop >>> 'exit' + [RET]"
27
+ puts "check answer >>> 'answer' + [RET]"
28
+ end
29
+
30
+ def init_mk_files(gem_dir: String, workshop_dir: String)
31
+ if Dir.exist?(workshop_dir) != true then
32
+ FileUtils.mkdir_p(workshop_dir)
33
+ system("cp -R #{gem_dir}/workshop/* #{workshop_dir}")
34
+ end
35
+ end
36
+
37
+ def get_app_ver(app_name: String)
38
+ app_vers = Open3.capture3("gem list #{app_name}")
39
+ latest_ver = app_vers[0].chomp.gsub(' (', '-').gsub(')','')
40
+ return latest_ver
41
+ end
42
+
43
+ def mk_training_data(elapsed_time: Time, prac_dir: String)
44
+ training_file = "#{prac_dir}/training_data.txt"
45
+ if File.exist?(training_file) != true then
46
+ FileUtils.touch(training_file)
47
+ end
48
+ File.open(training_file, "a") do |file|
49
+ file.puts("#{Time.now} #{elapsed_time.truncate(2)} sec")
50
+ end
51
+ end
52
+
53
+ def rspec_check(dir: workshop_dir)
54
+ puts "**********************************"
55
+ puts "RSpec Error Check"
56
+ puts "**********************************"
57
+ count = 0
58
+ flag_rspec = false
59
+ loop do
60
+ count += 1
61
+ puts "---------------------------"
62
+ puts "Rspec try: #{count}"
63
+ puts "---------------------------"
64
+ flag_rspec = system "cd #{dir} && rspec spec/workplace_spec.rb"
65
+ if flag_rspec == true
66
+ puts "Rspec check is clear!"
67
+ break
68
+ else
69
+ instruct_print
70
+ select = STDIN.gets.chomp
71
+ if select == 'exit'
72
+ flag_rspec = true
73
+ break
74
+ elsif select == 'answer'
75
+ system "cd #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/ruby_learner_init.el sentence.org workplace.rb"
76
+ else
77
+ system "cd #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/init.el sentence.org workplace.rb"
78
+ end
79
+ end
80
+ end
81
+ return flag_rspec
82
+ end
83
+
84
+ def rubocop_check(file: String, dir: workshop_dir)
85
+ puts "**********************************"
86
+ puts "Rubocop Error Check"
87
+ puts "**********************************"
88
+ count = 0
89
+ flag_rubocop = false
90
+ loop do
91
+ count += 1
92
+ puts "---------------------------"
93
+ puts "Rubocop try: #{count}"
94
+ puts "---------------------------"
95
+ flag_rubocop = system "rubocop #{file}"
96
+ if flag_rubocop == true
97
+ puts 'Rubocop check is clear!'
98
+ break
99
+ else
100
+ instruct_print
101
+ select = STDIN.gets.chomp
102
+ if select == 'exit'
103
+ flag_rubocop = true
104
+ break
105
+ elsif select == 'answer'
106
+ system "cd #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/ruby_learner_init.el sentence.org workplace.rb"
107
+ else
108
+ system "cd #{dir}/lib && emacs -nw -q -l #{dir}/emacs.d/init.el sentence.org workplace.rb"
109
+ end
110
+ end
111
+ end
112
+ return flag_rubocop
113
+ end
114
+
115
+ def restore(file: String, workshop_dir: String)
116
+ restore_file = ""
117
+ line = File.open("#{workshop_dir}/lib/answer.rb") do |f|
118
+ 0.times {
119
+ f.gets
120
+ }
121
+ restore_file = f.gets
122
+ end
123
+ restore_file.gsub!(" ", "")
124
+ restore_file.delete!("#")
125
+ Dir::chdir("#{workshop_dir}/restore"){
126
+ file_count = Dir.glob("*.rb").count
127
+ restore_file.insert(-5, "[#{file_count}]")
128
+ }
129
+ system "touch #{workshop_dir}/restore/#{restore_file}"
130
+ system "cp #{workshop_dir}/lib/workplace.rb #{workshop_dir}/restore/#{restore_file}"
131
+ end
@@ -0,0 +1,16 @@
1
+ # to open question.rb
2
+ # c-x 2: split window vertically
3
+ # c-x c-f: find file and input question.rb
4
+ # open a.rb as above
5
+ # c-x 3: split window horizontally
6
+ # c-x c-f: find file and input answer.rb
7
+ # move the other window
8
+ # c-x o: other windw
9
+ # then edit answer.rb as question.rb
10
+
11
+ # c-a: move ahead
12
+ # c-d: delete character
13
+ # c-x c-s: save file
14
+ # c-x c-c: quit edit
15
+ # c-k: kill the line
16
+ # c-y: paste of killed line
@@ -0,0 +1,43 @@
1
+ require 'fileutils'
2
+ require 'colorize'
3
+ require 'thor'
4
+ require 'ruby_learner/version.rb'
5
+ require 'diff-lcs'
6
+ require 'open3'
7
+ require 'ruby_learner/methods.rb'
8
+ require 'ruby_learner/typing_practice.rb'
9
+
10
+ module RubyLearner
11
+ # editor_learner CLI main class
12
+ class CLI < Thor
13
+ def initialize(*args)
14
+ super
15
+ @workshop_dir = "#{ENV['HOME']}/ruby_learner/workshop"
16
+ gem_location = Open3.capture3('gem environment gemdir')
17
+ app_vers = Open3.capture3('gem list ruby_learner')
18
+ rl_ver = app_vers[0].chomp.tr(' ', '-').delete('()')
19
+ @gem_dir = File.join(gem_location[0].chomp, "/gems/#{rl_ver}")
20
+ init_mk_files(gem_dir: @gem_dir, workshop_dir: @workshop_dir)
21
+ end
22
+
23
+ desc 'emacs_key', 'check emacs key-bindings'
24
+ def emacs_key(*_argv)
25
+ system("cat #{@workshop_dir}/emacs_help.org")
26
+ end
27
+
28
+ desc 'sequential_check [section:1~1] [part:1~2]','learning drill'
29
+ 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)
33
+ end
34
+
35
+ desc 'random_check', 'typing and editing practice.'
36
+ def random_check(*_argv)
37
+ rand_num = rand(1..2)
38
+ rand_dir = "#{@gem_dir}/questions/random_check/section_#{rand_num}"
39
+ typing_practice = TypingPractice.new(workshop_dir: @workshop_dir)
40
+ typing_practice.prac_sequence(mode_dir: rand_dir)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ #to open q.rb
2
+ # c-x 2: find file and input q.rb
3
+ # c-x c-f: find file and input q.rb
4
+ # open 1~3.rb as above
5
+ # c-x 3: split find file and input 1~3.rb
6
+ # move the other window
7
+ # c-x o: other window
8
+ # then edit 1~3.rb q.rb
9
+
10
+ # c-a:move ahead
11
+ # c-d: delete character
12
+ # c-x c-s: save file
13
+ # c-x c-c: quit edit
14
+ # c-k: kill the line
15
+ # c-y: paste of killed line
@@ -0,0 +1,21 @@
1
+ require 'fileutils'
2
+ require 'ruby_learner/methods.rb'
3
+
4
+ class TypingPractice
5
+
6
+ def initialize(workshop_dir: String)
7
+ @workshop_dir = workshop_dir
8
+ end
9
+ def prac_sequence(mode_dir: String)
10
+ FileUtils.cp("#{mode_dir}/lib/workplace.rb", "#{@workshop_dir}/lib/workplace.rb")
11
+ FileUtils.cp("#{mode_dir}/lib/sentence.org", "#{@workshop_dir}/lib/sentence.org")
12
+ FileUtils.cp("#{mode_dir}/lib/answer.rb", "#{@workshop_dir}/lib/answer.rb")
13
+ 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"
15
+ start_time = Time.now
16
+ typing_discriminant(dir: @workshop_dir)
17
+ elapsed_time = time_check(start_time: start_time)
18
+ p "#{elapsed_time} sec"
19
+ # mk_training_data(elapsed_time: elapsed_time, prac_dir: @prac_dir)
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module RubyLearner
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,16 @@
1
+ # to open question.rb
2
+ # c-x 2: split window vertically
3
+ # c-x c-f: find file and input question.rb
4
+ # open a.rb as above
5
+ # c-x 3: split window horizontally
6
+ # c-x c-f: find file and input answer.rb
7
+ # move the other window
8
+ # c-x o: other windw
9
+ # then edit answer.rb as question.rb
10
+
11
+ # c-a: move ahead
12
+ # c-d: delete character
13
+ # c-x c-s: save file
14
+ # c-x c-c: quit edit
15
+ # c-k: kill the line
16
+ # c-y: paste of killed line
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,15 @@
1
+ # section_1/workplace.rb
2
+
3
+ repeat_count = ARGV[0].to_i
4
+ math_num = ARGV[1].to_i
5
+
6
+ def for_system(a, b)
7
+ answer = 0
8
+ for i in 0..b do
9
+ answer = answer + a
10
+ end
11
+ return answer
12
+ end
13
+
14
+ a = for_system(repeat: repeat_count, math: math_num)
15
+ # puts a
@@ -0,0 +1,9 @@
1
+ #+STARTUP: indent nolineimages
2
+ # section_1/sentence.org
3
+
4
+ * for文の使い方
5
+ - 繰り返しの基本ですよー
6
+
7
+ * 問題文
8
+ - 繰り返し処理を用いて足し算してよ
9
+ - for_system(a, b)を用いて
@@ -0,0 +1,5 @@
1
+ # section_1/workplacs.rb
2
+
3
+ def for_system(a, b)
4
+
5
+ end
@@ -0,0 +1,100 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # This setting enables warnings. It's recommended, but in some cases may
70
+ # be too noisy due to issues in dependencies.
71
+ config.warnings = true
72
+
73
+ # Many RSpec users commonly either run the entire suite or an individual
74
+ # file, and it's useful to allow more verbose output when running an
75
+ # individual spec file.
76
+ if config.files_to_run.one?
77
+ # Use the documentation formatter for detailed output,
78
+ # unless a formatter has already been configured
79
+ # (e.g. via a command-line flag).
80
+ config.default_formatter = "doc"
81
+ end
82
+
83
+ # Print the 10 slowest examples and example groups at the
84
+ # end of the spec run, to help surface which specs are running
85
+ # particularly slow.
86
+ config.profile_examples = 10
87
+
88
+ # Run specs in random order to surface order dependencies. If you find an
89
+ # order dependency and want to debug it, you can fix the order by providing
90
+ # the seed, which is printed after each run.
91
+ # --seed 1234
92
+ config.order = :random
93
+
94
+ # Seed global randomization in this process using the `--seed` CLI option.
95
+ # Setting this allows you to use `--seed` to deterministically reproduce
96
+ # test failures related to randomization by passing the same `--seed` value
97
+ # as the one that triggered the failure.
98
+ Kernel.srand config.seed
99
+ =end
100
+ end
@@ -0,0 +1,10 @@
1
+ require 'workplace.rb'
2
+
3
+ RSpec.describe "A loop" do
4
+ it "given 2 and 2, return 6" do
5
+ expect(for_system(2, 2)).to eq(6)
6
+ end
7
+ it "given 3 and 3, return 8" do
8
+ expect(for_system(3, 2)).to eq(9)
9
+ end
10
+ end