eturem 0.3.3 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 64d7d985440e56ceded0d1713d1bb8e3a7f42285
4
- data.tar.gz: f8a30a97dba553b7e7c2f0de962b2551e6ff383a
2
+ SHA256:
3
+ metadata.gz: 6f7d954f618abe8fcf4f93cf3090a13ba9ef7ddca3c3ef56404e00e435c45432
4
+ data.tar.gz: 021fa72979dd1c3c1ea0a98b8d5fef4be838e7b70ccf1bfd9845cdb74d5a73e4
5
5
  SHA512:
6
- metadata.gz: fc2a5be8cd2f5471f15f0a635a6dac10e3e28eccaf169f792d64c34cd854c7b9798b2f96049ee47ffca20daf07e7885cc9677549608b161aed2478201634b051
7
- data.tar.gz: d62c5c694dbf69cee649e34dbf1cb36c2223c0cc78bf375d8d07c41d03a381fce26a3167378f42235af36f1d53f33ce0bdb9ec60b9987a2292efe7d57e6a94f9
6
+ metadata.gz: b3d9767cb1cee6cc3488c4a3ba10e2a28f8d3678c0248a55274d7e4541bcdd31882dca11ce731915a5c17b16a93750c0790043e6c3f967af522ebe3a72accd9b
7
+ data.tar.gz: eac6deef0d5b16d83c038bca2ea11b457fc7e6966c4867f2c1e85ecf781ab64d8329103b025bca75390d30fbb8b8b8b3a22ce2fe7c7e1991f0bf131d73899820
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,74 +1,74 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at nodai2h.itc@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at nodai2h.itc@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in eturem.gemspec
6
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in eturem.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 nodai2hITC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018-2020 nodai2hITC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.ja.md CHANGED
@@ -1,134 +1,223 @@
1
- # Eturem
2
-
3
- Ruby のエラーメッセージを、初心者にわかりやすく表示するための gem です。
4
-
5
- Easy To Understand Ruby Error Message の略。
6
-
7
- ## インストールと使用方法
8
-
9
- $ gem install eturem
10
-
11
- でインストールし、
12
-
13
- $ ruby -returem/ja <your_script.rb>
14
-
15
- と使用すればよいのですが、最初に書いたとおり初心者が使用することを想定した gem ですので、そんなことを初心者に強いるのは酷というもの。だれか詳しい人が、事前に ```gem install eturem``` した上で、環境変数 RUBYOPT に ```-returem/ja``` を追加しておいてあげましょう。
16
-
17
- ## 使用するとどうなるか
18
-
19
- * エラーメッセージが日本語で表示される。
20
- * エラー箇所周辺が表示される。
21
- * エラーの種類によっては、原因を特定するためのさらなる情報が表示される。
22
-
23
- ### 例1:SyntaxError
24
-
25
- ```ruby
26
- if gets.to_i == 1
27
- if gets.to_i == 2
28
- puts "なんたらかんたら"
29
- # 内側の if に対応する end を忘れてしまった!
30
- end
31
- ```
32
-
33
- 通常の環境で実行すると、次のようなエラーが表示されます。
34
-
35
- ```
36
- example1.rb:5: syntax error, unexpected end-of-input, expecting keyword_end
37
- ```
38
-
39
- 英語の苦手な人ではこの時点で拒否反応が出るでしょうし、そうでなくとも「end-of-input」や「keyword_end」が何を意味しているのか、初心者には掴みにくいのではないでしょうか。
40
-
41
- Eturem を使用すると、次のようなエラー表示になります。
42
-
43
- ```
44
- ファイル"example1.rb" 5行目でエラーが発生しました。
45
- (ただし、実際のエラーの原因はおそらくもっと前にあります。)
46
- 構文エラーです。endが足りません。「if」に対応する「end」があるか確認してください。
47
- 3: puts "なんたらかんたら"
48
- 4: # 内側の if に対応する end を忘れてしまった!
49
- => 5: end
50
- ```
51
-
52
- このように、日本語でわかりやすくエラーを表示してくれます。
53
-
54
- ### 例2:NameError
55
-
56
- ```ruby
57
- prayer_life = 100
58
- # ↑スペルミス!
59
- # 中略
60
- # ↓このスペルは正しいが、上でミスしたことでエラー発生。
61
- if player_life > 0
62
- # 後略
63
- ```
64
-
65
- 通常の環境で実行すると、次のようなエラーが表示されます。
66
-
67
- ```
68
- example2.rb:5:in `<main>': undefined local variable or method `player_life' for main:Object (NameError)
69
- Did you mean? prayer_life
70
- ```
71
-
72
- did_you_mean のおかげで昔より格段にわかりやすくなったとはいえ、それでも英語に壁を感じる人はいますし、またこの例の場合実際にミスをしたのは1行目にもかかわらず「5行目でエラー」と表示されてしまうため、「え?5行目を何度見てもミスなんて無いよ?」と困ってしまう人もいるでしょう。
73
-
74
- Eturem を使用すると、次のようなエラー表示になります。(実際には色付き)
75
-
76
- ```
77
- ファイル"example2.rb" 5行目でエラーが発生しました。
78
- 変数/メソッド「player_life」は存在しません。「prayer_life」の入力ミスではありませんか?
79
- 1: prayer_life = 100
80
- :
81
- 3: # 中略
82
- 4: # ↓このスペルは正しいが、上でミスしたことでエラー発生。
83
- => 5: if player_life > 0
84
- 6: # 後略
85
- ```
86
-
87
- このように、エラー発生箇所周辺だけではなく、did_you_mean がサジェストしてくれた変数の使用行も同時に表示してくれるので、ミスをしたのが実は1行目であることに気付きやすくなるのではないでしょうか。
88
-
89
- ### 例3:ArgumentError
90
-
91
- ```ruby
92
- def foo(a, b)
93
- end
94
- # 中略
95
- foo(1)
96
- ```
97
-
98
- 通常の環境で実行すると、次のようなエラーが表示されます。
99
-
100
- ```
101
- Traceback (most recent call last):
102
- 1: from example3.rb:4:in `<main>'
103
- example3.rb:1:in `foo': wrong number of arguments (given 1, expected 2) (ArgumentError)
104
- ```
105
-
106
- このように、ArgumentError のエラー発生行は、メソッド定義行(この場合1行目)になってしまいます。しかし実際に ArgumentError が発生するときの原因は、メソッド定義部分ではなく、呼び出し部分であることがほとんどではないでしょうか?
107
-
108
- この例の場合 Traceback に「from example3.rb:4」と表示されてはいますが、初心者にはやはりわかりにくいのではないかと思われます。
109
-
110
- Eturem を使用すると、次のようなエラー表示になります。
111
-
112
- ```
113
- ファイル"example3.rb" 4行目でエラーが発生しました。
114
- 引数の数が正しくありません。「foo」は本来2個の引数を取りますが、1個の引数が渡されています。
115
- 2: end
116
- 3: # 中略
117
- => 4: foo(1)
118
- ```
119
-
120
- このように、呼び出し行をエラー発生行として表示してくれます。
121
-
122
- ## Contributing
123
-
124
- 「こう表示した方がよりわかりやすいのでは?」等のご意見ありましたら、よろしく御願いします。
125
-
126
- Bug reports and pull requests are welcome on GitHub at https://github.com/nodai2hITC/eturem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
127
-
128
- ## License
129
-
130
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
131
-
132
- ## Code of Conduct
133
-
134
- Everyone interacting in the Eturem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nodai2hITC/eturem/blob/master/CODE_OF_CONDUCT.md).
1
+ # Eturem
2
+
3
+ Ruby のエラーメッセージを、初心者にわかりやすく表示するための gem です。
4
+
5
+ Easy To Understand Ruby Error Message の略。
6
+
7
+ ## インストールと使用方法
8
+
9
+ $ gem install eturem
10
+
11
+ でインストールし、
12
+
13
+ $ ruby -returem/ja <your_script.rb>
14
+
15
+ または
16
+
17
+ $ eturem lang=ja <your_script.rb>
18
+
19
+ と使用すればよいのですが、最初に書いたとおり初心者が使用することを想定した gem ですので、そんなことを初心者に強いるのは酷というもの。だれか詳しい人が、事前に ```gem install eturem``` した上で、環境変数 RUBYOPT に ```-returem/ja``` を追加しておいてあげましょう。
20
+
21
+ ## 使用するとどうなるか
22
+
23
+ * エラーメッセージが日本語で表示される。
24
+ * エラー箇所周辺が表示される。
25
+ * エラーの種類によっては、原因を特定するためのさらなる情報が表示される。
26
+
27
+ ### 例1:SyntaxError
28
+
29
+ ```ruby
30
+ if gets.to_i == 1
31
+ if gets.to_i == 2
32
+ puts "なんたらかんたら"
33
+ # 内側の if に対応する end を忘れてしまった!
34
+ end
35
+ ```
36
+
37
+ 通常の環境で実行すると、次のようなエラーが表示されます。
38
+
39
+ ```
40
+ example1.rb:5: syntax error, unexpected end-of-input, expecting keyword_end
41
+ ```
42
+
43
+ 英語の苦手な人ではこの時点で拒否反応が出るでしょうし、そうでなくとも「end-of-input」や「keyword_end」が何を意味しているのか、初心者には掴みにくいのではないでしょうか。
44
+
45
+ Eturem を使用すると、次のようなエラー表示になります。
46
+
47
+ ```
48
+ 【エラー】ファイル"example1.rb" 5行目:
49
+ (ただし、実際のエラーの原因はおそらくもっと前にあります。)
50
+ 構文エラーです。endが足りません。「if」に対応する「end」があるか確認してください。
51
+ 3: puts "なんたらかんたら"
52
+ 4: # 内側の if に対応する end を忘れてしまった!
53
+ => 5: end
54
+ ```
55
+
56
+ このように、日本語でわかりやすくエラーを表示してくれます。
57
+
58
+ ### 例2:NameError
59
+
60
+ ```ruby
61
+ prayer_life = 100
62
+ # ↑スペルミス!
63
+ # 中略
64
+ # ↓このスペルは正しいが、上でミスしたことでエラー発生。
65
+ if player_life > 0
66
+ # 後略
67
+ ```
68
+
69
+ 通常の環境で実行すると、次のようなエラーが表示されます。
70
+
71
+ ```
72
+ example2.rb:5:in `<main>': undefined local variable or method `player_life' for main:Object (NameError)
73
+ Did you mean? prayer_life
74
+ ```
75
+
76
+ did_you_mean のおかげで昔より格段にわかりやすくなったとはいえ、それでも英語に壁を感じる人はいますし、またこの例の場合実際にミスをしたのは1行目にもかかわらず「5行目でエラー」と表示されてしまうため、「え?5行目を何度見てもミスなんて無いよ?」と困ってしまう人もいるでしょう。
77
+
78
+ Eturem を使用すると、次のようなエラー表示になります。(実際には色付き)
79
+
80
+ ```
81
+ 【エラー】ファイル"example2.rb" 5行目:
82
+ 変数/メソッド「player_life」は存在しません。「prayer_life」の入力ミスではありませんか?
83
+ 1: prayer_life = 100
84
+ :
85
+ 3: # 中略
86
+ 4: # ↓このスペルは正しいが、上でミスしたことでエラー発生。
87
+ => 5: if player_life > 0
88
+ 6: # 後略
89
+ ```
90
+
91
+ このように、エラー発生箇所周辺だけではなく、did_you_mean がサジェストしてくれた変数の使用行も同時に表示してくれるので、ミスをしたのが実は1行目であることに気付きやすくなるのではないでしょうか。
92
+
93
+ ### 例3:ArgumentError
94
+
95
+ ```ruby
96
+ def foo(a, b)
97
+ end
98
+ # 中略
99
+ foo(1)
100
+ ```
101
+
102
+ 通常の環境で実行すると、次のようなエラーが表示されます。
103
+
104
+ ```
105
+ Traceback (most recent call last):
106
+ 1: from example3.rb:4:in `<main>'
107
+ example3.rb:1:in `foo': wrong number of arguments (given 1, expected 2) (ArgumentError)
108
+ ```
109
+
110
+ このように、ArgumentError のエラー発生行は、メソッド定義行(この場合1行目)になってしまいます。しかし実際に ArgumentError が発生するときの原因は、メソッド定義部分ではなく、呼び出し部分であることがほとんどではないでしょうか?
111
+
112
+ この例の場合 Traceback に「from example3.rb:4」と表示されてはいますが、初心者にはやはりわかりにくいのではないかと思われます。
113
+
114
+ Eturem を使用すると、次のようなエラー表示になります。
115
+
116
+ ```
117
+ 【エラー】ファイル"example3.rb" 4行目:
118
+ 引数の数が正しくありません。「foo」は本来2個の引数を取りますが、1個の引数が渡されています。
119
+ 2: end
120
+ 3: # 中略
121
+ => 4: foo(1)
122
+ ```
123
+
124
+ このように、呼び出し行をエラー発生行として表示してくれます。
125
+
126
+ ### 例4:warning
127
+
128
+ 0.4.0 から、warning に対してもサポートができるようになりました。
129
+
130
+ ```
131
+ 【警告】ファイル"example4.rb" 2行目:
132
+ 条件式部分で「 = 」が使われています。「 == 」の間違いではありませんか?
133
+ => 2: puts "a" if a = 1
134
+ ```
135
+
136
+ 現状あまり多くの種類の警告に対応できてはいませんが、上記のように日本語での警告に加えて該当行を表示することができます。
137
+
138
+ ### 例5:エラー発生時に自動で binding.irb
139
+
140
+ 変数の値が不適切だったためにエラーが起きた可能性がある場合、エラーが起きた瞬間の変数の値を調べる必要があります。そうした際には「エラー発生箇所の直前に binding.irb を入れて調べる」という手がありますが、そうするとたまにしか起きないエラーの場合何度も binding.irb が動いてしまって面倒です。
141
+
142
+ そこで、後述する設定ファイル .eturem で設定するか、あるいはプログラム中に `$eturem_repl = "irb"` と入れておくことで、エラー発生時に自動的に binding.irb することができます。
143
+
144
+ なお、この機能だけを切り出した gem「[autoirb](https://github.com/nodai2hITC/autoirb)」もあります。
145
+
146
+ ### その他細かなこと
147
+
148
+ #### 全角空白・全角記号による NameError
149
+
150
+ 日本人ならきっと誰もがやったことがあり、そして意外と気付けない全角空白や全角記号によるエラー。通常の NameError の場合とは異なるメッセージでわかりやすくしています。(下の表示ではわかりませんが、実際には全角空白部分に下線が引かれています。)
151
+
152
+ ```
153
+ 【エラー】ファイル"example5.rb" 1行目:(NoMethodError)
154
+ スクリプト中に全角空白が混じっています。
155
+ => 1: puts "こんにちは世界"
156
+ ```
157
+
158
+ #### 大文字・小文字を間違えた場合の NameError
159
+
160
+ did_you_mean は、例えば `Time.now` と書くべきところを `time.now` と間違えて小文字で書いてしまった場合、 `Time` をサジェストしないようになっています。(サジェスト範囲を広げると誤反応が多くなるため、敢えてそうしているのだそうです。)
161
+
162
+ とはいえ、初心者は大文字小文字が区別されるという意識が無く、つい小文字で入力してしまうことが少なからずあるように思えます。そこでスペルが同一で大文字小文字のみが異なる場合に限り、定数もサジェスト対象になるようにしています。
163
+
164
+ ```
165
+ 【エラー】ファイル"example6.rb" 1行目:(NameError)
166
+ 変数/メソッド「time」は存在しません。「Time」の入力ミスではありませんか?
167
+ => 1: start_time = time.now
168
+ ```
169
+
170
+ ## .eturem ファイルによる設定
171
+
172
+ HOME またはカレントディレクトリに「.eturem」というファイルを用意すると、詳細設定ができます。(下の例の設定が、各項目を省略した際に使用される初期値です。)
173
+
174
+ ```
175
+ enable: true
176
+ debug: false
177
+ lang: en
178
+ output_backtrace: true
179
+ output_original: true
180
+ output_script: true
181
+ override_warning: true
182
+ use_coderay: false
183
+ before_line_num: 2
184
+ after_line_num: 2
185
+ repl: nil
186
+ ```
187
+
188
+ - enable: eturem の使用/不使用を切り替えます。
189
+ - debug: eturem 自体をデバッグするための機能なので、通常は使う必要はありません。
190
+ - lang: 表示言語を切り替えます。ただし `-returem/ja` のように言語を指定して使用した場合、この設定よりもそちらが優先されます。
191
+ - output_backtrace: バックトレース表示の有無を切り替えます。
192
+ - output_original: Ruby 本来のエラーメッセージの表示の有無を切り替えます。
193
+ - output_script: エラーの起きた個所のスクリプト表示の有無を切り替えます。
194
+ - override_warning: 警告に対してもわかりやすいメッセージを表示するかを設定します。
195
+ - before_line_num / after_line_num: スクリプト表示の際、エラー行の前後何行を表示するかを設定します。
196
+ - repl: irb または pry と書いておくと、エラー発生時に自動的に binding.irb / binding.pry します。
197
+
198
+ ## 簡単な仕組み
199
+
200
+ ```ruby
201
+ begin
202
+ load($PROGRAM_NAME)
203
+ rescue Exception => e
204
+ # エラー表示処理
205
+ end
206
+ exit
207
+ ```
208
+
209
+ 実際はもう少しいろいろやっていますが、このように本来のスクリプト実行が始まる前に `-returem` オプションで eturem を呼び出し、そこから `load` でスクリプトを実行しているのがポイントです。これにより、SyntaxError 等も取得できるようになっています。
210
+
211
+ ## Contributing
212
+
213
+ 「こう表示した方がよりわかりやすいのでは?」等のご意見ありましたら、よろしく御願いします。
214
+
215
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nodai2hITC/eturem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
216
+
217
+ ## License
218
+
219
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
220
+
221
+ ## Code of Conduct
222
+
223
+ Everyone interacting in the Eturem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nodai2hITC/eturem/blob/master/CODE_OF_CONDUCT.md).