ruby_learner 1.2.6 → 1.2.7
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 +3 -3
- data/contents/datas/emacs.d/black/init.el +8 -1
- data/contents/datas/emacs.d/white/init.el +8 -0
- data/contents/datas/sequential_mode.txt +1 -0
- data/contents/workshop/rubocop.yml +2 -0
- data/docs/{thesis/manual.org → manual.org} +0 -0
- data/docs/{todo → seminar}/9-27.org +0 -0
- data/docs/thesis/final_presentation/IMRD/ctrlZ_fg_method.org +7 -0
- data/docs/thesis/final_presentation/IMRD/why_not_web.org +9 -0
- data/docs/thesis/{mid_term.pptx → midterm_presentation/others/5464_takaki_midterm.pptx} +0 -0
- data/docs/thesis/midterm_presentation/others/mid_term.pptx +0 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/.ruby_learner.tex.swp +0 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/jlisting.sty +216 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/rspec_rubocop.png +0 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/ruby_learner.aux +22 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/ruby_learner.dvi +0 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/ruby_learner.log +152 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/ruby_learner.md +35 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/ruby_learner.pdf +0 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/ruby_learner.tex +79 -0
- data/docs/thesis/midterm_presentation/ruby_learner_thesis/test.md +39 -0
- data/docs/thesis/{competing_services.org → research/competing_services.org} +0 -0
- data/lib/ruby_learner/common.rb +0 -29
- data/lib/ruby_learner/copspec.rb +49 -0
- data/lib/ruby_learner/pair_timer.rb +9 -19
- data/lib/ruby_learner/restore.rb +81 -0
- data/lib/ruby_learner/{typing_practice.rb → rubocop_rspec_check.rb} +25 -24
- data/lib/ruby_learner/ruby_learner.rb +47 -56
- data/lib/ruby_learner/sequential_check.rb +110 -0
- data/lib/ruby_learner/sequential_check_real.rb +29 -0
- data/lib/ruby_learner/version.rb +1 -1
- metadata +25 -11
- data/docs/thesis/~$mid_term.pptx +0 -0
- data/lib/ruby_learner/popup_per_time_for_background.rb +0 -14
- data/lib/ruby_learner/practice_datas.txt +0 -0
- data/lib/ruby_learner/sequential_main.rb +0 -207
@@ -0,0 +1,35 @@
|
|
1
|
+
背景
|
2
|
+
====
|
3
|
+
|
4
|
+
小傾角粒界エネルギーはRead-Shockleyの転位模型で理論的に説明されている[\[1\]](#ReadShockley).
|
5
|
+
この重要な帰結として,粒界エネルギーは粒界を構成するに必要な
|
6
|
+
幾何学的転位のバーガースベクトルの大きさに依存する.
|
7
|
+
経験的ポテンシャル(EAM)を用いた計算(図1:青点線)では,その予測に従って,
|
8
|
+
金属の\[100\]方位の対称傾角粒界の0度と90度の立ち上がり角に違いが見られる[\[2\]](#TschoppMcdowell).
|
9
|
+
しかし,測定された実験結果(図1:緑実線)にはそのような差異はなく,
|
10
|
+
どちらも同じ角度である[\[3\]](#Otsuki).
|
11
|
+
これらの齟齬は数値的にはわずかであるが,転位論の信ぴょう性に関わる問題である[\[4\]](#Suzuki).
|
12
|
+
本研究では,どちらが正しいかを確認するため,第一原理計算をおこなった.
|
13
|
+
|
14
|
+
![Alの\[100\]方位の対称傾角粒界エネルギー, EAMの計算結果(青点線),実測値(緑実線),および第一原理計算値(赤破線).0度,90度近辺の青直線はEAMの立ち上がり角を示す.](./all_plots.png)
|
15
|
+
|
16
|
+
手法
|
17
|
+
====
|
18
|
+
|
19
|
+
第一原理計算にはVASPを用いた.計算条件は次の通りである.KPOINTは,粒界のモデルのサイズが粒界傾角によりそれぞれ違うため,VASPが用意している自動生成を用いた.Alは$d-$電子を含まないのでlength=50で行った.擬ポテンシャルにはPAWを用いた.エネルギーカットオフは300eVで計算した.緩和は原子緩和を共役勾配法による自動(IBRION
|
20
|
+
= 2)で,外部形状は手動で緩和させて最安定のエネルギーを求めた.
|
21
|
+
|
22
|
+
結果
|
23
|
+
====
|
24
|
+
|
25
|
+
図\[fig:one\]に赤破線で第一原理計算の結果を示した.
|
26
|
+
計算結果はEAMを用いた結果に近い値を示している.
|
27
|
+
しかし,計算に用いる系の原子サイズを大きくすると計算値は単調に減少する.
|
28
|
+
これは,周期的境界条件にともなう転位間の相互作用や拘束の影響が考えられ,
|
29
|
+
十分に原子緩和が完了していないことが予測される.
|
30
|
+
発表ではEAMを用いたエネルギー解析を踏まえて, 転位論への影響を考察する.
|
31
|
+
|
32
|
+
1. <a name="ReadShockley">W. T. Read Jr., and W. Shockley, “Imperfection in nearly perfect crystals”, ed. by W. Shockley, (Wiley, New York, 1952) pp.352–76. </a>
|
33
|
+
1. <a name="TschoppMcdowell">M. A. Tschopp and D. L. Mcdowell, Phil. Mag., <span>**87**</span>(2007), 3871. </a>
|
34
|
+
1. <a name="Otsuki">A. Otsuki, J. Materials Science, <span>**40**</span>(2005), 3219. </a>
|
35
|
+
1. <a name="Suzuki">「転位論入門」鈴木秀次, (1967 アグネ),p.77,p.350. </a>
|
@@ -0,0 +1,79 @@
|
|
1
|
+
\documentclass[a4j,twocolumn]{jsarticle}
|
2
|
+
\usepackage[dvipdfmx]{graphicx}
|
3
|
+
\usepackage{url}
|
4
|
+
|
5
|
+
\setlength{\textheight}{275mm}
|
6
|
+
\headheight 5mm
|
7
|
+
\topmargin -30mm
|
8
|
+
\textwidth 185mm
|
9
|
+
\oddsidemargin -15mm
|
10
|
+
\evensidemargin -15mm
|
11
|
+
\pagestyle{empty}
|
12
|
+
|
13
|
+
|
14
|
+
\begin{document}
|
15
|
+
|
16
|
+
\title{Rubygemsを用いたプログラミング言語Ruby学習の効率化}
|
17
|
+
\author{情報科学科 \hspace{5mm} 27015464 \hspace{5mm} 大津隆輝}
|
18
|
+
\date{}
|
19
|
+
\maketitle
|
20
|
+
|
21
|
+
\section{背景}
|
22
|
+
西谷研究室ではプログラミング言語Rubyを使用して,言語学習や卒業研究を行なっている.
|
23
|
+
つまり,3年生はRubyの習得が早ければ自分の研究の為の時間を確保できる.
|
24
|
+
しかし,個人で言語学習を行う際のハードルは高いものである\cite{Oshimi}.
|
25
|
+
その原因として,言語に対しての知識がない初心者にとって環境構築や学習の教材選びは非常に困難であることが要因の一つではないかと考えられる.環境構築なしで教材選びも必要ない言語学習サービスにはProgate\cite{Progate}やcodecademy\cite{codecademy}等があるが,環境構築という部分を排斥しているが故にそのサービス外での学習に一定の壁が生じているのではないかと考える.
|
26
|
+
\par
|
27
|
+
また,近年ではコードをGitで管理することで,チーム内でのコード編集の履歴をメンバーがそれぞれ確認することが出来るので,チームでの開発が管理しやすくなった\cite{GitDevelopment}.このような開発では他人の書いたコードを読み解き,それに適切な形で自分のコードを書き加える能力が必要となる.そう言った意味でも,近年の言語学習は動くだけのコードを書くのではなく言語が持つスタイルについてもきちんと学ぶ必要があると考える.
|
28
|
+
\par
|
29
|
+
そこで本研究では,環境構築の自動化に加え,Rubyの体系的な言語学習とプログラミングスタイルの学習ができるアプリケーションを開発し,Rubyを容易に学習できる環境を整え,実践的な学習を提供することで,個人のスキル向上の効率化を目指す.
|
30
|
+
\section{手法}
|
31
|
+
本研究ではGemアプリケーションruby\_learner\cite{RubyGems}を作成することで学習支援を行う.
|
32
|
+
このアプリケーションの主な機能はemacsを用いたRubyの学習(体系的な学習・実際の開発習慣の習得)・開発環境構築の自動化である.
|
33
|
+
上記の機能のうちRubyの学習には,テキストと課題の提供を行うことで使用者のインプット・アウトプットを通して記憶の定着を促す.
|
34
|
+
\par
|
35
|
+
学習の手順として,アプリ使用者にはテキストを読んでから課題に挑戦してもらう.
|
36
|
+
課題挑戦時に使用者の回答コードが適切なものであるかを2つのチェック項目から判断する(図\ref{fig:one}).
|
37
|
+
一つ目は,コードが期待される振る舞いをしているかである.
|
38
|
+
期待される振る舞いの確認とは課題の意図する通りに使用者の回答コードが動作しているかの確認である.
|
39
|
+
これはRSpecファイル\cite{rspec}と呼ばれるRuby向けのテストコードを記述するファイルを用いることで実装する.
|
40
|
+
このチェック項目を設けることで,本研究の先駆けとなったeditor\_learner\cite{editor_learner}とは違い,使用者の独創性を尊重するコードテストを行うことができる.
|
41
|
+
二つ目のチェック項目は,コードがRubyのプログラミングスタイルを遵守できているかの確認である.
|
42
|
+
%Rubyのプログラミングスタイルには
|
43
|
+
%・インデントは2スペース
|
44
|
+
%・クラス名はキャメルでそれ以外はスネーク
|
45
|
+
%・不要な改行がないか
|
46
|
+
%等が挙げられる.
|
47
|
+
これはrubyのプログラミングスタイルをチェックするGemアプリケーションRuboCop\cite{rubocop}を用いることで実装する.
|
48
|
+
このチェック項目を設けることで,使用者は自分のコード内に存在するプログラミングスタイルから外れている部分を確認することができる.
|
49
|
+
これら二つのチェック項目をクリアして課題の正解としている.
|
50
|
+
|
51
|
+
\begin{figure}[h]
|
52
|
+
\vspace{0\baselineskip}
|
53
|
+
\begin{center}
|
54
|
+
\includegraphics[width=70mm]{./rspec_rubocop.png}
|
55
|
+
\caption{ruby\_learnerのrspecとrubocopを用いた2段階チェック構造.}
|
56
|
+
\label{fig:one}
|
57
|
+
\end{center}
|
58
|
+
\end{figure}
|
59
|
+
|
60
|
+
環境構築の自動化は,本アプリ外でもアプリ内で行った環境でRubyの開発が行えるようにrubocop等のアプリケーションの自動インストールやemacsの設定ファイルの提供などを行う.
|
61
|
+
|
62
|
+
\section{予想される結果}
|
63
|
+
使用者は本アプリを通して,Rubyのプログラミングスタイルを遵守した上で期待される振る舞いをするコードの作成能力を習得する.また,その知識をアプリ外でも実戦で使える環境を手に入れることができる.上記の二つの効果により,使用者はアプリ外での言語学習も効率的に行えると考える.
|
64
|
+
|
65
|
+
\vspace{0.5\baselineskip}
|
66
|
+
|
67
|
+
{\small\setlength\baselineskip{10pt} % 参考文献は小さめの文字で行間を詰めてある
|
68
|
+
\begin{thebibliography}{9}
|
69
|
+
\bibitem{Oshimi} 「Learning Style Inventoryを用いたプログラミング初学者のための教材レコメンドシステムの提案」押見太雄, (2017) p.1.
|
70
|
+
\bibitem{Progate} Progate. \url{https://prog-8.com/mypage}.
|
71
|
+
\bibitem{codecademy} codecademy. \url{https://www.codecademy.com/}.
|
72
|
+
\bibitem{GitDevelopment} Git. \url{https://git-scm.com/book/ja/v2/}.
|
73
|
+
\bibitem{RubyGems} RubyGems. \url{https://rubygems.org}.
|
74
|
+
\bibitem{rspec} RSpec. \url{http://rspec.info/about/}.
|
75
|
+
\bibitem{editor_learner} editor\_learner 1.1.2, Souki Wada. \url{https://rubygems.org/gems/editor_learner/}.
|
76
|
+
\bibitem{rubocop} RuboCop. \url{http://batsov.com/rubocop/}.
|
77
|
+
\end{thebibliography}
|
78
|
+
}
|
79
|
+
\end{document}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
背景
|
2
|
+
====
|
3
|
+
|
4
|
+
小傾角粒界エネルギーはRead-Shockleyの転位模型で理論的に説明されている[@ReadShockley].
|
5
|
+
この重要な帰結として,粒界エネルギーは粒界を構成するに必要な
|
6
|
+
幾何学的転位のバーガースベクトルの大きさに依存する.
|
7
|
+
経験的ポテンシャル(EAM)を用いた計算(図1:青点線)では,その予測に従って,
|
8
|
+
金属の\[100\]方位の対称傾角粒界の0度と90度の立ち上がり角に違いが見られる[@TschoppMcdowell].
|
9
|
+
しかし,測定された実験結果(図1:緑実線)にはそのような差異はなく,
|
10
|
+
どちらも同じ角度である[@Otsuki].
|
11
|
+
これらの齟齬は数値的にはわずかであるが,転位論の信ぴょう性に関わる問題である[@Suzuki].
|
12
|
+
本研究では,どちらが正しいかを確認するため,第一原理計算をおこなった.
|
13
|
+
|
14
|
+
![Alの\[100\]方位の対称傾角粒界エネルギー, EAMの計算結果(青点線),
|
15
|
+
実測値(緑実線),および第一原理計算値(赤破線).0度,90度近辺の青直線はEAMの立ち上がり角を示す.<span
|
16
|
+
data-label="fig:one"></span>](./all_plots.png){width="80mm"}
|
17
|
+
|
18
|
+
手法
|
19
|
+
====
|
20
|
+
|
21
|
+
第一原理計算にはVASPを用いた.計算条件は次の通りである.KPOINTは,粒界のモデルのサイズが粒界傾角によりそれぞれ違うため,VASPが用意している自動生成を用いた.Alは$d-$電子を含まないのでlength=50で行った.擬ポテンシャルにはPAWを用いた.エネルギーカットオフは300eVで計算した.緩和は原子緩和を共役勾配法による自動(IBRION
|
22
|
+
= 2)で,外部形状は手動で緩和させて最安定のエネルギーを求めた.
|
23
|
+
|
24
|
+
結果
|
25
|
+
====
|
26
|
+
|
27
|
+
図\[fig:one\]に赤破線で第一原理計算の結果を示した.
|
28
|
+
計算結果はEAMを用いた結果に近い値を示している.
|
29
|
+
しかし,計算に用いる系の原子サイズを大きくすると計算値は単調に減少する.
|
30
|
+
これは,周期的境界条件にともなう転位間の相互作用や拘束の影響が考えられ,
|
31
|
+
十分に原子緩和が完了していないことが予測される.
|
32
|
+
発表ではEAMを用いたエネルギー解析を踏まえて, 転位論への影響を考察する.
|
33
|
+
|
34
|
+
<span>9</span> W. T. Read Jr., and W. Shockley, “Imperfection in nearly
|
35
|
+
perfect crystals”, ed. by W. Shockley, (Wiley, New York, 1952)
|
36
|
+
pp.352–76. M. A. Tschopp and D. L. Mcdowell, Phil. Mag.,
|
37
|
+
<span>**87**</span>(2007), 3871. A. Otsuki, J. Materials Science,
|
38
|
+
<span>**40**</span>(2005), 3219. 「転位論入門」鈴木秀次, (1967 アグネ),
|
39
|
+
p.77,p.350.
|
File without changes
|
data/lib/ruby_learner/common.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
require 'time'
|
2
2
|
|
3
3
|
class Common
|
4
|
-
def save_restore(file: String, local_dir: String, elapsed_time: Time)
|
5
|
-
restore_file = ""
|
6
|
-
line = File.open("#{local_dir}/workshop/lib/answer.rb") do |f|
|
7
|
-
1.times {
|
8
|
-
f.gets
|
9
|
-
}
|
10
|
-
restore_file = f.gets
|
11
|
-
end
|
12
|
-
restore_file.gsub!(" ", "")
|
13
|
-
restore_file.delete!("#")
|
14
|
-
restore_file_for_csv = restore_file.match(/\d-\d/)[0]
|
15
|
-
Dir::chdir("#{local_dir}/restore"){
|
16
|
-
file_count = Dir.glob("*.rb").count
|
17
|
-
restore_file.insert(0, "[#{file_count}]")
|
18
|
-
}
|
19
|
-
system "touch #{local_dir}/restore/#{restore_file}"
|
20
|
-
system "cp #{local_dir}/workshop/lib/workplace.rb #{local_dir}/restore/#{restore_file}"
|
21
|
-
now_time = Time.now
|
22
|
-
file = File.open("#{local_dir}/practice_datas.csv", "a") do |f|
|
23
|
-
f.puts "#{now_time.year}/#{now_time.month}/#{now_time.day},#{now_time.hour}:#{now_time.min}:#{now_time.sec},#{elapsed_time},#{restore_file_for_csv}"
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
4
|
|
28
5
|
def time_check(start_time: Time)
|
29
6
|
end_time = Time.now
|
@@ -31,12 +8,6 @@ class Common
|
|
31
8
|
return elapsed_time
|
32
9
|
end
|
33
10
|
|
34
|
-
def instruct_print
|
35
|
-
puts "continue >>> [RET]"
|
36
|
-
puts "stop >>> 'exit' + [RET]"
|
37
|
-
puts "check answer >>> 'answer' + [RET]"
|
38
|
-
end
|
39
|
-
|
40
11
|
def init_mk_files(gem_dir: String, local_dir: String)
|
41
12
|
gem_contents_dir = "#{gem_dir}/contents"
|
42
13
|
if Dir.exist?(local_dir) != true then
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module CopSpec
|
2
|
+
|
3
|
+
def copspec(file_path)
|
4
|
+
@file = file_path
|
5
|
+
root = @file.match(/.*\/lib/)[0]
|
6
|
+
@spec = "#{root[0..root.size-5]}/spec"
|
7
|
+
flag_rspec = rspec_check
|
8
|
+
return if !flag_rspec
|
9
|
+
flag_rubocop = rubocop_check
|
10
|
+
return if !flag_rubocop
|
11
|
+
puts "**********************************"
|
12
|
+
puts "Final Error Check"
|
13
|
+
puts "**********************************"
|
14
|
+
flag_final = check("rspec", @spec)
|
15
|
+
if flag_final
|
16
|
+
puts "your code is perfect."
|
17
|
+
else
|
18
|
+
puts "not perfect, please fix your code."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
module_function :copspec
|
22
|
+
|
23
|
+
def self.rspec_check
|
24
|
+
puts "**********************************"
|
25
|
+
puts "RSpec Error Check"
|
26
|
+
puts "**********************************"
|
27
|
+
return check("rspec", @spec)
|
28
|
+
end
|
29
|
+
private_class_method :rspec_check
|
30
|
+
|
31
|
+
def self.rubocop_check
|
32
|
+
puts "**********************************"
|
33
|
+
puts "Rubocop Error Check"
|
34
|
+
puts "**********************************"
|
35
|
+
return check("rubocop", @file)
|
36
|
+
end
|
37
|
+
private_class_method :rubocop_check
|
38
|
+
|
39
|
+
def self.check(check_mode, file)
|
40
|
+
flag_check = false
|
41
|
+
flag_check = system "#{check_mode} #{file}"
|
42
|
+
if flag_check
|
43
|
+
puts "#{check_mode} check is clear!"
|
44
|
+
end
|
45
|
+
return flag_check
|
46
|
+
end
|
47
|
+
private_class_method :check
|
48
|
+
|
49
|
+
end
|
@@ -1,23 +1,13 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Thread.kill(self)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def popup_per_time_for_non_exe(time)
|
18
|
-
popup_file = File.expand_path("popup_per_time_for_background.rb", __FILE__)
|
19
|
-
p popup_file
|
20
|
-
system("ruby #{popup_file} #{time} &")
|
3
|
+
time = ARGV[0].to_i
|
4
|
+
|
5
|
+
loop do
|
6
|
+
sleep time
|
7
|
+
system('afplay /System/Library/Sounds/Submarine.aiff')
|
8
|
+
o, e, s = Open3.capture3("osascript -e 'tell app \"System Events\" to display dialog \"#{time}s passed.\nPut cancel to stop pair-mode.\nPut OK to continue pair-mode.\"'")
|
9
|
+
if o != "button returned:OK\n"
|
10
|
+
Open3.capture3("osascript -e 'tell app \"System Events\" to display dialog \"pair_popup_mode is stopped.\"'")
|
11
|
+
break
|
21
12
|
end
|
22
|
-
|
23
13
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class Restore
|
2
|
+
def initialize
|
3
|
+
@local_dir = "#{ENV['HOME']}/.ruby_learner"
|
4
|
+
@restore_dir = "#{@local_dir}/restore"
|
5
|
+
end
|
6
|
+
|
7
|
+
def save(file: String, elapsed_time: Time)
|
8
|
+
restore_file = ""
|
9
|
+
line = File.open("#{@local_dir}/workshop/lib/answer.rb") do |f|
|
10
|
+
1.times {
|
11
|
+
f.gets
|
12
|
+
}
|
13
|
+
restore_file = f.gets
|
14
|
+
end
|
15
|
+
restore_file.gsub!(" ", "")
|
16
|
+
restore_file.delete!("#")
|
17
|
+
for_csv(restore_file, elapsed_time)
|
18
|
+
Dir::chdir("#{@local_dir}/restore") do
|
19
|
+
file_count = Dir.glob("*.rb").count
|
20
|
+
restore_file.insert(0, "[#{file_count}]")
|
21
|
+
end
|
22
|
+
system "touch #{@local_dir}/restore/#{restore_file}"
|
23
|
+
system "cp #{@local_dir}/workshop/lib/workplace.rb #{@local_dir}/restore/#{restore_file}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def output
|
27
|
+
sorted_restores = sort
|
28
|
+
if sorted_restores.size < 20
|
29
|
+
puts sorted_restores
|
30
|
+
else
|
31
|
+
system("ls #{@restore_dir}")
|
32
|
+
puts "\nlast 5 restore history."
|
33
|
+
puts sorted_restores[-5..-1], "\n"
|
34
|
+
end
|
35
|
+
instruct
|
36
|
+
end
|
37
|
+
|
38
|
+
def open(num)
|
39
|
+
sorted_restores = sort
|
40
|
+
case num
|
41
|
+
when 0..sorted_restores.size-1
|
42
|
+
filename = sorted_restores[num]
|
43
|
+
system("emacs #{@restore_dir}/#{filename}")
|
44
|
+
else
|
45
|
+
puts "you have #{sorted_restores.size} restore_files."
|
46
|
+
puts "you must put 'ruby_learner -r 0~#{sorted_restores.size - 1}.'"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def instruct
|
53
|
+
puts "If you want to open a restore_file, you execute 'ruby_learner -r [number]'"
|
54
|
+
puts "ex) ruby_learner -r 3"
|
55
|
+
print "If you want to remove all restore_files, you execute 'ruby_learner -r -f'"
|
56
|
+
end
|
57
|
+
|
58
|
+
def for_csv(restore_file, elapsed_time)
|
59
|
+
now_time = Time.now
|
60
|
+
restore_file.gsub!(" ", "")
|
61
|
+
restore_file.delete!("#")
|
62
|
+
sec_par = restore_file.match(/\d*-\d*/)[0]
|
63
|
+
file = File.open("#{@local_dir}/practice_datas.csv", "a") do |f|
|
64
|
+
f.puts "#{now_time.year}/#{now_time.month}/#{now_time.day},#{now_time.hour}:#{now_time.min}:#{now_time.sec},#{elapsed_time},#{sec_par}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def sort
|
69
|
+
restores = []
|
70
|
+
dir = Dir.open(@restore_dir)
|
71
|
+
dir.each do |file|
|
72
|
+
if file != '.' && file != '..' && file != '.empty.rb'
|
73
|
+
restores << file.slice(1..file.length)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
sorted_restores = restores.sort_by{|item| item.to_i}
|
77
|
+
sorted_restores.each{|item| item.insert(0, "[")}
|
78
|
+
dir.close
|
79
|
+
sorted_restores
|
80
|
+
end
|
81
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'ruby_learner/common.rb'
|
3
|
-
require 'ruby_learner/
|
3
|
+
require 'ruby_learner/restore'
|
4
4
|
require 'rubocop'
|
5
5
|
|
6
|
-
class
|
6
|
+
class RubocopRspecCheck
|
7
7
|
|
8
8
|
def initialize(local_dir, gem_dir)
|
9
9
|
@local_dir = local_dir
|
@@ -16,29 +16,21 @@ class TypingPractice
|
|
16
16
|
theme_color = f.gets.chomp
|
17
17
|
end
|
18
18
|
@emacs_dir = "#{@datas_dir}/.emacs.d/#{theme_color}"
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def action(mode_dir: String, is_copy: Bool)
|
22
22
|
start_time = Time.now
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
if is_copy
|
24
|
+
%w{lib/workplace.rb lib/sentence.org lib/answer.rb spec/workplace_spec.rb}.each do |path|
|
25
|
+
FileUtils.cp("#{mode_dir}/#{path}", "#{@workshop_dir}/#{path}")
|
26
|
+
end
|
27
|
+
end
|
27
28
|
system "cd #{@workshop_dir}/lib && emacs -nw -q -l #{@emacs_dir}/init.el sentence.org workplace.rb"
|
28
|
-
typing_discriminant(start_time: start_time)
|
29
|
-
end
|
30
|
-
|
31
|
-
def typing_discriminant(start_time: Time)
|
32
|
-
p 'typing_discriminant'
|
33
29
|
loop do
|
34
30
|
flag_rspec, flag_rs_exit = rspec_check
|
35
|
-
if flag_rs_exit == true
|
36
|
-
break
|
37
|
-
end
|
31
|
+
break if flag_rs_exit == true
|
38
32
|
flag_rubocop, flag_rub_exit = rubocop_check
|
39
|
-
if flag_rub_exit == true
|
40
|
-
break
|
41
|
-
end
|
33
|
+
break if flag_rub_exit == true
|
42
34
|
if flag_rspec == true && flag_rubocop == true
|
43
35
|
puts "**********************************"
|
44
36
|
puts "Final Error Check"
|
@@ -56,7 +48,16 @@ class TypingPractice
|
|
56
48
|
end
|
57
49
|
elapsed_time = Common.allocate.time_check(start_time: start_time)
|
58
50
|
p "#{elapsed_time} sec"
|
59
|
-
|
51
|
+
restore = Restore.new
|
52
|
+
restore.save(file: "#{@workshop_dir}/lib/workplace.rb", elapsed_time: elapsed_time)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def instruct_print
|
58
|
+
puts "continue >>> [RET]"
|
59
|
+
puts "stop >>> 'exit' + [RET]"
|
60
|
+
puts "check answer >>> 'answer' + [RET]"
|
60
61
|
end
|
61
62
|
|
62
63
|
def rspec_check
|
@@ -64,7 +65,7 @@ class TypingPractice
|
|
64
65
|
puts "RSpec Error Check"
|
65
66
|
puts "**********************************"
|
66
67
|
file = "#{@workshop_dir}/spec/workplace_spec.rb"
|
67
|
-
return
|
68
|
+
return loop_per_checks("rspec", file)
|
68
69
|
end
|
69
70
|
|
70
71
|
def rubocop_check
|
@@ -72,10 +73,10 @@ class TypingPractice
|
|
72
73
|
puts "Rubocop Error Check"
|
73
74
|
puts "**********************************"
|
74
75
|
file = "#{@workshop_dir}/lib/workplace.rb"
|
75
|
-
return
|
76
|
+
return loop_per_checks("rubocop", file)
|
76
77
|
end
|
77
78
|
|
78
|
-
def
|
79
|
+
def loop_per_checks(check_mode, file)
|
79
80
|
count = 0
|
80
81
|
flag_check = false
|
81
82
|
flag_exit = false
|
@@ -89,7 +90,7 @@ class TypingPractice
|
|
89
90
|
puts "#{check_mode} check is clear!"
|
90
91
|
break
|
91
92
|
else
|
92
|
-
|
93
|
+
instruct_print
|
93
94
|
select = STDIN.gets.chomp
|
94
95
|
if select == 'exit'
|
95
96
|
flag_exit = true
|