editor_learner 1.0.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +6 -0
- data/answer.rb +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/.ipynb_checkpoints/Untitled-checkpoint.ipynb +177 -0
- data/docs/.ipynb_checkpoints/Untitled1-checkpoint.ipynb +6 -0
- data/docs/.ipynb_checkpoints/final_reserch-checkpoint.ipynb +75 -0
- data/docs/Untitled.ipynb +167 -0
- data/docs/final_reserch.ipynb +75 -0
- data/editor_learner.gemspec +40 -0
- data/exe/editor_learner +4 -0
- data/h.rb +14 -0
- data/lib/.DS_Store +0 -0
- data/lib/answer.rb +1 -0
- data/lib/editor_learner/version.rb +3 -0
- data/lib/editor_learner.rb +123 -0
- data/lib/new_terminal +25 -0
- data/lib/question/.DS_Store +0 -0
- data/lib/question/ruby_1/1.rb +6 -0
- data/lib/question/ruby_1/2.rb +11 -0
- data/lib/question/ruby_1/3.rb +16 -0
- data/lib/question/ruby_1/4.rb +19 -0
- data/lib/question/ruby_2/1.rb +11 -0
- data/lib/question/ruby_3/1.rb +11 -0
- data/lib/question/ruby_3/2.rb +22 -0
- data/lib/question/test/1.rb +1 -0
- data/lib/question/test/2.rb +1 -0
- data/lib/question/test/3.rb +1 -0
- data/lib/question/test/4.rb +1 -0
- data/lib/question.rb +1 -0
- data/lib/random_check_question/1.rb +11 -0
- data/lib/random_check_question/2.rb +9 -0
- data/lib/random_check_question/3.rb +2 -0
- data/lib/random_check_question/4.rb +5 -0
- data/lib/random_h.rb +14 -0
- data/lib/sequential_check_question/ruby_1/1.rb +11 -0
- data/lib/sequential_check_question/ruby_1/2.rb +16 -0
- data/lib/sequential_check_question/ruby_1/3.rb +19 -0
- data/lib/sequential_check_question/ruby_1/q.rb +19 -0
- data/lib/sequential_check_question/ruby_2/1.rb +19 -0
- data/lib/sequential_check_question/ruby_2/2.rb +21 -0
- data/lib/sequential_check_question/ruby_2/3.rb +25 -0
- data/lib/sequential_check_question/ruby_2/q.rb +19 -0
- data/lib/sequential_check_question/ruby_3/1.rb +11 -0
- data/lib/sequential_check_question/ruby_3/2.rb +16 -0
- data/lib/sequential_check_question/ruby_3/3.rb +15 -0
- data/lib/sequential_check_question/ruby_3/q.rb +11 -0
- data/lib/sequential_check_question/ruby_4/1.rb +11 -0
- data/lib/sequential_check_question/ruby_4/2.rb +14 -0
- data/lib/sequential_check_question/ruby_4/3.rb +14 -0
- data/lib/sequential_check_question/ruby_5/1.rb +18 -0
- data/lib/sequential_check_question/ruby_5/2.rb +29 -0
- data/lib/sequential_check_question/ruby_5/3.rb +27 -0
- data/lib/sequential_check_question/ruby_6/1.rb +10 -0
- data/lib/sequential_check_question/ruby_6/2.rb +23 -0
- data/lib/sequential_check_question/ruby_6/3.rb +34 -0
- data/lib/sequential_h.rb +13 -0
- data/question.rb +19 -0
- data/workshop/#answer.rb# +1 -0
- data/workshop/answer.rb +0 -0
- data/workshop/question.rb +0 -0
- data/workshop/random_h.rb +14 -0
- data/workshop/ruby_1/1.rb +11 -0
- data/workshop/ruby_1/2.rb +11 -0
- data/workshop/ruby_1/3.rb +0 -0
- data/workshop/ruby_1/q.rb +16 -0
- data/workshop/ruby_1/sequential_h.rb +13 -0
- data/workshop/ruby_2/1.rb +0 -0
- data/workshop/ruby_2/2.rb +0 -0
- data/workshop/ruby_2/3.rb +0 -0
- data/workshop/ruby_2/q.rb +0 -0
- data/workshop/ruby_2/sequential_h.rb +13 -0
- data/workshop/ruby_3/1.rb +0 -0
- data/workshop/ruby_3/2.rb +0 -0
- data/workshop/ruby_3/3.rb +0 -0
- data/workshop/ruby_3/q.rb +0 -0
- data/workshop/ruby_3/sequential_h.rb +13 -0
- data/workshop/ruby_4/1.rb +0 -0
- data/workshop/ruby_4/2.rb +0 -0
- data/workshop/ruby_4/3.rb +0 -0
- data/workshop/ruby_4/q.rb +0 -0
- data/workshop/ruby_4/sequential_h.rb +13 -0
- data/workshop/ruby_5/1.rb +18 -0
- data/workshop/ruby_5/2.rb +0 -0
- data/workshop/ruby_5/3.rb +0 -0
- data/workshop/ruby_5/q.rb +18 -0
- data/workshop/ruby_5/sequential_h.rb +13 -0
- data/workshop/ruby_6/1.rb +0 -0
- data/workshop/ruby_6/2.rb +0 -0
- data/workshop/ruby_6/3.rb +0 -0
- data/workshop/ruby_6/q.rb +0 -0
- data/workshop/ruby_6/sequential_h.rb +13 -0
- metadata +242 -0
data/docs/Untitled.ipynb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "markdown",
|
5
|
+
"metadata": {
|
6
|
+
"toc": "true"
|
7
|
+
},
|
8
|
+
"source": [
|
9
|
+
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
|
10
|
+
"<div class=\"toc\" style=\"margin-top: 1em;\"><ul class=\"toc-item\"><li><span><a href=\"#command-lineによるemacs操作習熟プログラム\" data-toc-modified-id=\"command-lineによるemacs操作習熟プログラム-1\"><span class=\"toc-item-num\">1 </span>command lineによるemacs操作習熟プログラム</a></span></li><li><span><a href=\"#仕様\" data-toc-modified-id=\"仕様-2\"><span class=\"toc-item-num\">2 </span>仕様</a></span></li><li><span><a href=\"#実装のメモ\" data-toc-modified-id=\"実装のメモ-3\"><span class=\"toc-item-num\">3 </span>実装のメモ</a></span><ul class=\"toc-item\"><li><span><a href=\"#gemのデフォルト構造\" data-toc-modified-id=\"gemのデフォルト構造-3.1\"><span class=\"toc-item-num\">3.1 </span>gemのデフォルト構造</a></span></li></ul></li></ul></div>"
|
11
|
+
]
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"cell_type": "markdown",
|
15
|
+
"metadata": {},
|
16
|
+
"source": [
|
17
|
+
"# command lineによるemacs操作習熟プログラム"
|
18
|
+
]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"cell_type": "markdown",
|
22
|
+
"metadata": {},
|
23
|
+
"source": [
|
24
|
+
"* random_check\n",
|
25
|
+
"* sequential check\n",
|
26
|
+
" * 実装上の問題点,\n",
|
27
|
+
" * \n",
|
28
|
+
"\n",
|
29
|
+
"目的の違い.仕様を変えている.\n",
|
30
|
+
"をメモっとかなあかん.\n",
|
31
|
+
"\n",
|
32
|
+
"なぜ? \n",
|
33
|
+
"\n",
|
34
|
+
"storyを書いていくんやよ.\n",
|
35
|
+
"storyで一番分かりやすいのは,\n",
|
36
|
+
"\n",
|
37
|
+
"1. 出来上がりました.なぜそうしたか?\n",
|
38
|
+
"1. 初期バージョンは\n",
|
39
|
+
"1. 問題\n",
|
40
|
+
"1. 解決する方法を考えて\n",
|
41
|
+
"1. あたらしいバージョンにしました.\n",
|
42
|
+
"\n",
|
43
|
+
"* どういうソフトにするかもわからんだ.\n",
|
44
|
+
"* 最初は\n",
|
45
|
+
" * typer tortoisは何をするソフト?\n",
|
46
|
+
" * editor learner\n",
|
47
|
+
"* random checkでも悪くないよね.\n",
|
48
|
+
" * \n",
|
49
|
+
"* fizz_buzzには合わない.\n",
|
50
|
+
"\n",
|
51
|
+
"* 想定している学習者\n",
|
52
|
+
" * 栃木,rubyの学習をしていない\n",
|
53
|
+
" * テキストはよむ.\n",
|
54
|
+
" * プロジェクトをちゃんとやってるかどうかをチェック,\n",
|
55
|
+
" * タイムは必要?\n",
|
56
|
+
" * ちぇっくの仕方を\n",
|
57
|
+
" * 手順を確認していく?\n",
|
58
|
+
" * testではどうする?\n",
|
59
|
+
"\n",
|
60
|
+
"* random checkの使い方をするか?\n",
|
61
|
+
" * git clone...\n",
|
62
|
+
" * rake install:localでinstall\n",
|
63
|
+
" * .editor_learnerをつくって(pwdから情報をとるように)\n",
|
64
|
+
" * そこにquestion.rb answer.rbが作られて\n",
|
65
|
+
" * 一致をcheck.\n",
|
66
|
+
" * 次の回は,上書きする...\n",
|
67
|
+
"\n",
|
68
|
+
"* sequential checkの使い方?\n",
|
69
|
+
" * gem install editor_learner\n",
|
70
|
+
" * pwdに作る...\n",
|
71
|
+
" * そこにdirectoryを作っていく.\n",
|
72
|
+
" * その情報をもとに,次のquestion.rb answer.rbを決定\n",
|
73
|
+
" * 一致をcheck.\n",
|
74
|
+
" \n",
|
75
|
+
"* やってるかのcheck??\n"
|
76
|
+
]
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"cell_type": "markdown",
|
80
|
+
"metadata": {},
|
81
|
+
"source": [
|
82
|
+
"# 仕様\n",
|
83
|
+
"* 特定のdirectoryで立ち上げると\n",
|
84
|
+
"* 例題がcopyされる,跡が残るのがいいのでは...\n",
|
85
|
+
"* emacsで編集して\n",
|
86
|
+
"* 時間で評価\n",
|
87
|
+
"* 記録は??"
|
88
|
+
]
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"cell_type": "markdown",
|
92
|
+
"metadata": {
|
93
|
+
"collapsed": true
|
94
|
+
},
|
95
|
+
"source": [
|
96
|
+
"# 実装のメモ\n",
|
97
|
+
"\n",
|
98
|
+
"## gemのデフォルト構造\n",
|
99
|
+
"gemはdefaultでどこに入る?\n",
|
100
|
+
"* gem envでinstall先がわかる\n",
|
101
|
+
"* fileを置いておくか?\n",
|
102
|
+
"* File.extend_path('../lib',__FILE__)\n",
|
103
|
+
"* ENV, cwd\n"
|
104
|
+
]
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"cell_type": "code",
|
108
|
+
"execution_count": null,
|
109
|
+
"metadata": {
|
110
|
+
"collapsed": true
|
111
|
+
},
|
112
|
+
"outputs": [],
|
113
|
+
"source": []
|
114
|
+
}
|
115
|
+
],
|
116
|
+
"metadata": {
|
117
|
+
"kernelspec": {
|
118
|
+
"display_name": "Python 3",
|
119
|
+
"language": "python",
|
120
|
+
"name": "python3"
|
121
|
+
},
|
122
|
+
"language_info": {
|
123
|
+
"codemirror_mode": {
|
124
|
+
"name": "ipython",
|
125
|
+
"version": 3
|
126
|
+
},
|
127
|
+
"file_extension": ".py",
|
128
|
+
"mimetype": "text/x-python",
|
129
|
+
"name": "python",
|
130
|
+
"nbconvert_exporter": "python",
|
131
|
+
"pygments_lexer": "ipython3",
|
132
|
+
"version": "3.6.2"
|
133
|
+
},
|
134
|
+
"latex_envs": {
|
135
|
+
"LaTeX_envs_menu_present": true,
|
136
|
+
"autocomplete": true,
|
137
|
+
"bibliofile": "biblio.bib",
|
138
|
+
"cite_by": "apalike",
|
139
|
+
"current_citInitial": 1,
|
140
|
+
"eqLabelWithNumbers": true,
|
141
|
+
"eqNumInitial": 1,
|
142
|
+
"hotkeys": {
|
143
|
+
"equation": "Ctrl-E",
|
144
|
+
"itemize": "Ctrl-I"
|
145
|
+
},
|
146
|
+
"labels_anchors": false,
|
147
|
+
"latex_user_defs": false,
|
148
|
+
"report_style_numbering": false,
|
149
|
+
"user_envs_cfg": false
|
150
|
+
},
|
151
|
+
"toc": {
|
152
|
+
"nav_menu": {
|
153
|
+
"height": "49px",
|
154
|
+
"width": "251px"
|
155
|
+
},
|
156
|
+
"number_sections": true,
|
157
|
+
"sideBar": true,
|
158
|
+
"skip_h1_title": false,
|
159
|
+
"toc_cell": true,
|
160
|
+
"toc_position": {},
|
161
|
+
"toc_section_display": "block",
|
162
|
+
"toc_window_display": true
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"nbformat": 4,
|
166
|
+
"nbformat_minor": 2
|
167
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "markdown",
|
5
|
+
"metadata": {
|
6
|
+
"toc": true
|
7
|
+
},
|
8
|
+
"source": [
|
9
|
+
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
|
10
|
+
"<div class=\"toc\" style=\"margin-top: 1em;\"><ul class=\"toc-item\"><li><span><a href=\"#h\" data-toc-modified-id=\"h-1\"><span class=\"toc-item-num\">1 </span>h</a></span></li></ul></div>"
|
11
|
+
]
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"cell_type": "markdown",
|
15
|
+
"metadata": {},
|
16
|
+
"source": [
|
17
|
+
"# h"
|
18
|
+
]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"cell_type": "markdown",
|
22
|
+
"metadata": {},
|
23
|
+
"source": []
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"cell_type": "code",
|
27
|
+
"execution_count": null,
|
28
|
+
"metadata": {
|
29
|
+
"collapsed": true
|
30
|
+
},
|
31
|
+
"outputs": [],
|
32
|
+
"source": []
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"cell_type": "code",
|
36
|
+
"execution_count": null,
|
37
|
+
"metadata": {
|
38
|
+
"collapsed": true
|
39
|
+
},
|
40
|
+
"outputs": [],
|
41
|
+
"source": []
|
42
|
+
}
|
43
|
+
],
|
44
|
+
"metadata": {
|
45
|
+
"kernelspec": {
|
46
|
+
"display_name": "Python 3",
|
47
|
+
"language": "python",
|
48
|
+
"name": "python3"
|
49
|
+
},
|
50
|
+
"language_info": {
|
51
|
+
"codemirror_mode": {
|
52
|
+
"name": "ipython",
|
53
|
+
"version": 3
|
54
|
+
},
|
55
|
+
"file_extension": ".py",
|
56
|
+
"mimetype": "text/x-python",
|
57
|
+
"name": "python",
|
58
|
+
"nbconvert_exporter": "python",
|
59
|
+
"pygments_lexer": "ipython3",
|
60
|
+
"version": "3.6.2"
|
61
|
+
},
|
62
|
+
"toc": {
|
63
|
+
"nav_menu": {},
|
64
|
+
"number_sections": true,
|
65
|
+
"sideBar": true,
|
66
|
+
"skip_h1_title": false,
|
67
|
+
"toc_cell": true,
|
68
|
+
"toc_position": {},
|
69
|
+
"toc_section_display": "block",
|
70
|
+
"toc_window_display": true
|
71
|
+
}
|
72
|
+
},
|
73
|
+
"nbformat": 4,
|
74
|
+
"nbformat_minor": 2
|
75
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "editor_learner/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "editor_learner"
|
8
|
+
spec.version = EditorLearner::VERSION
|
9
|
+
spec.authors = ["Souki Wada"]
|
10
|
+
spec.email = [""]
|
11
|
+
spec.summary = %q{This is ruby learning system}
|
12
|
+
spec.description = %q{This gem can improve your edding abity}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
#if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
#else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_dependency "thor"
|
36
|
+
spec.add_dependency "colorize"
|
37
|
+
spec.add_dependency "minitest", "~> 5.10.3"
|
38
|
+
spec.add_dependency "diff-lcs"
|
39
|
+
|
40
|
+
end
|
data/exe/editor_learner
ADDED
data/h.rb
ADDED
@@ -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
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/answer.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
I am hero
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'colorize'
|
3
|
+
require 'thor'
|
4
|
+
require "editor_learner/version"
|
5
|
+
require 'diff-lcs'
|
6
|
+
|
7
|
+
module EditorLearner
|
8
|
+
class CLI < Thor
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
@prac_dir="#{ENV['HOME']}/editor_learner/workshop"
|
13
|
+
if File.exist?(@prac_dir) != true then
|
14
|
+
FileUtils.mkdir_p(@prac_dir)
|
15
|
+
FileUtils.touch("#{@prac_dir}/question.rb")
|
16
|
+
FileUtils.touch("#{@prac_dir}/answer.rb")
|
17
|
+
FileUtils.touch("#{@prac_dir}/random_h.rb")
|
18
|
+
FileUtils.cp("#{ENV['HOME']}/editor_learner/lib/random_h.rb", "#{@prac_dir}/random_h.rb")
|
19
|
+
end
|
20
|
+
range = 1..6
|
21
|
+
range_ruby = 1..3
|
22
|
+
range.each{|num|
|
23
|
+
if File.exist?("#{@prac_dir}/ruby_#{num}") != true then
|
24
|
+
FileUtils.mkdir("#{@prac_dir}/ruby_#{num}")
|
25
|
+
FileUtils.touch("#{@prac_dir}/ruby_#{num}/q.rb")
|
26
|
+
FileUtils.touch("#{@prac_dir}/ruby_#{num}/sequential_h.rb")
|
27
|
+
FileUtils.cp("#{ENV['HOME']}/editor_learner/lib/sequential_h.rb", "#{@prac_dir}/ruby_#{num}/sequential_h.rb")
|
28
|
+
range_ruby.each{|n|
|
29
|
+
FileUtils.touch("#{@prac_dir}/ruby_#{num}/#{n}.rb")
|
30
|
+
}
|
31
|
+
end
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'delete [number~number]', 'delete the ruby_file choose number to delete file'
|
36
|
+
|
37
|
+
def delete(n, m)
|
38
|
+
range = n..m
|
39
|
+
range.each{|num|
|
40
|
+
if File.exist?("#{@prac_dir}/ruby_#{num}") == true then
|
41
|
+
system "rm -rf #{@prac_dir}/ruby_#{num}"
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'sequential_check [lessen_number] [1~3number] ','sequential check your typing skill and edit skill choose number'
|
47
|
+
def sequential_check(*argv, n, m)
|
48
|
+
l = m.to_i - 1
|
49
|
+
@seq_dir = "lib/sequential_check_question"
|
50
|
+
q_rb = "ruby_#{n}/#{m}.rb"
|
51
|
+
@seqnm_dir = File.join(@seq_dir,q_rb)
|
52
|
+
@pracnm_dir = "#{ENV['HOME']}/editor_learner/workshop/ruby_#{n}/#{m}.rb"
|
53
|
+
@seqnq_dir = "lib/sequential_check_question/ruby_#{n}/q.rb"
|
54
|
+
@pracnq_dir = "#{ENV['HOME']}/editor_learner/workshop/ruby_#{n}/q.rb"
|
55
|
+
@seqnl_dir = "lib/sequential_check_question/ruby_#{n}/#{l}.rb"
|
56
|
+
@pracnl_dir = "#{ENV['HOME']}/editor_learner/workshop/ruby_#{n}/#{l}.rb"
|
57
|
+
puts "check starting ..."
|
58
|
+
puts "type following commands on the terminal"
|
59
|
+
src_dir = File.expand_path('../..', __FILE__)
|
60
|
+
FileUtils.cp(File.join(src_dir, "#{@seqnm_dir}"), "#{@pracnq_dir}")
|
61
|
+
if l != 0 && FileUtils.compare_file("#{@pracnm_dir}", "#{@pracnq_dir}") != true
|
62
|
+
FileUtils.compare_file("#{@pracnl_dir}", (File.join(src_dir, "#{@seqnl_dir}"))) == true
|
63
|
+
FileUtils.cp("#{@pracnl_dir}", "#{@pracnm_dir}")
|
64
|
+
end
|
65
|
+
|
66
|
+
if FileUtils.compare_file(@pracnm_dir, @pracnq_dir) != true then
|
67
|
+
system "osascript -e 'tell application \"Terminal\" to do script \"cd #{@prac_dir}/ruby_#{n} \" '"
|
68
|
+
loop do
|
69
|
+
a = STDIN.gets.chomp
|
70
|
+
if a == "check" && FileUtils.compare_file("#{@pracnm_dir}", "#{@pracnq_dir}") == true then
|
71
|
+
puts "ruby_#{n}/#{m}.rb is done!"
|
72
|
+
break
|
73
|
+
elsif FileUtils.compare_file("#{@pracnm_dir}", "#{@pracnq_dir}") != true then
|
74
|
+
@inputdata = File.open("#{@pracnm_dir}").readlines
|
75
|
+
@checkdata = File.open("#{@pracnq_dir}").readlines
|
76
|
+
diffs = Diff::LCS.diff("#{@inputdata}", "#{@checkdata}")
|
77
|
+
diffs.each do |diff|
|
78
|
+
p diff
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
else
|
83
|
+
p "ruby_#{n}/#{m}.rb is finished!"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'random_check', 'ramdom check your typing and edit skill.'
|
88
|
+
def random_check(*argv)
|
89
|
+
random = rand(1..4)
|
90
|
+
p random
|
91
|
+
s = "#{random}.rb"
|
92
|
+
puts "check starting ..."
|
93
|
+
puts "type following commands on the terminal"
|
94
|
+
puts "> emacs question.rb answer.rb"
|
95
|
+
|
96
|
+
src_dir = File.expand_path('../..', __FILE__) # "Users/souki/editor_learner"
|
97
|
+
|
98
|
+
FileUtils.cp(File.join(src_dir, "lib/random_check_question//#{s}"), "#{@prac_dir}/question.rb")
|
99
|
+
open_terminal
|
100
|
+
|
101
|
+
start_time = Time.now
|
102
|
+
loop do
|
103
|
+
sleep(1)
|
104
|
+
if File.exist?("#{@prac_dir}/question.rb") && File.exist?("#{@prac_dir}/answer.rb") then
|
105
|
+
if FileUtils.compare_file("#{@prac_dir}/question.rb", "#{@prac_dir}/answer.rb") == true then
|
106
|
+
break
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end_time = Time.now
|
111
|
+
time = end_time - start_time - 1
|
112
|
+
|
113
|
+
puts "#{time} sec"
|
114
|
+
end
|
115
|
+
|
116
|
+
no_commands do
|
117
|
+
def open_terminal
|
118
|
+
pwd = Dir.pwd
|
119
|
+
system "osascript -e 'tell application \"Terminal\" to do script \"cd #{@prac_dir} \" '"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/new_terminal
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'thor'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
module NewTerminal
|
6
|
+
class CLI < Thor
|
7
|
+
default_task :open
|
8
|
+
desc 'version', 'version'
|
9
|
+
def version
|
10
|
+
puts '0.0.1'.green
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'open [DIR]', 'open new terminal on DIR or pwd'
|
14
|
+
def open(*argv)
|
15
|
+
if argv[0]==nil
|
16
|
+
pwd = Dir.pwd
|
17
|
+
else
|
18
|
+
pwd = File.realdirpath(argv[0])
|
19
|
+
end
|
20
|
+
system "osascript -e 'tell application \"Terminal\" to do script \"cd #{pwd} \" '"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
NewTerminal::CLI.start(ARGV)
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
def fizz_buzz(n)
|
2
|
+
if n % 15 == 0
|
3
|
+
'Fizz Buzz'
|
4
|
+
elsif n % 3 == 0
|
5
|
+
'Fizz'
|
6
|
+
elsif n % 5 == 0
|
7
|
+
'Buzz'
|
8
|
+
else
|
9
|
+
n.to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
puts fizz_buzz(1)
|
14
|
+
puts fizz_buzz(2)
|
15
|
+
puts fizz_buzz(3)
|
16
|
+
puts fizz_buzz(4)
|
17
|
+
puts fizz_buzz(5)
|
18
|
+
puts fizz_buzz(6)
|
19
|
+
puts fizz_buzz(15)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
def fizz_buzz(n)
|
2
|
+
if n % 15 == 0
|
3
|
+
'Fizz Buzz'
|
4
|
+
elsif n % 3 == 0
|
5
|
+
'Fizz'
|
6
|
+
elsif n % 5 == 0
|
7
|
+
'Buzz'
|
8
|
+
else
|
9
|
+
n.to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'minitest/autorun'
|
14
|
+
|
15
|
+
class FizzBuzzTest < Minitest::Test
|
16
|
+
def test_fizz_buzz
|
17
|
+
assert_equal '1', fizz_buzz(1)
|
18
|
+
assert_equal '2', fizz_buzz(2)
|
19
|
+
assert_equal 'Fizz', fizz_buzz(3)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
hello
|
@@ -0,0 +1 @@
|
|
1
|
+
initialize
|
@@ -0,0 +1 @@
|
|
1
|
+
require
|
@@ -0,0 +1 @@
|
|
1
|
+
def hello
|
data/lib/question.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
I am hero
|
data/lib/random_h.rb
ADDED
@@ -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
|