eturem 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.md +5 -4
- data/lib/eturem/base.rb +13 -11
- data/lib/eturem/ja.rb +18 -3
- data/lib/eturem/version.rb +1 -1
- data/lib/eturem.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cafde349114833d7d2ec857ff349c9b90be5d1ec
|
4
|
+
data.tar.gz: d80d846f4b2e628dab97a0e81cec9f64d3a162f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7614e84b0e772b45d733c2fa25587855c314c7b10bdaf5052a4647ab2a666da4c08b233dfafb921ca7f8a3bcfd47833232a9488146d14221d242adf7d81b884
|
7
|
+
data.tar.gz: 2c6cc910538e61fb935788b9f47390129f7d1896caeebb170bd14dde8c986232b04eaa1d91d2c190deb3a7f42d941a9d47bbf4b7afbc24e872d1bee0953c7131
|
data/README.ja.md
CHANGED
@@ -41,8 +41,9 @@ example1.rb:5: syntax error, unexpected end-of-input, expecting keyword_end
|
|
41
41
|
Eturem を使用すると、次のようなエラー表示になります。
|
42
42
|
|
43
43
|
```
|
44
|
-
ファイル"example1.rb" 5
|
45
|
-
|
44
|
+
ファイル"example1.rb" 5行目でエラーが発生しました。
|
45
|
+
(ただし、実際のエラーの原因はおそらくもっと前にあります。)
|
46
|
+
構文エラーです。endが足りません。「if」に対応する「end」があるか確認してください。
|
46
47
|
3: puts "なんたらかんたら"
|
47
48
|
4: # 内側の if に対応する end を忘れてしまった!
|
48
49
|
=> 5: end
|
@@ -85,7 +86,7 @@ Eturem を使用すると、次のようなエラー表示になります。(
|
|
85
86
|
|
86
87
|
このように、エラー発生箇所周辺だけではなく、did_you_mean がサジェストしてくれた変数の使用行も同時に表示してくれるので、ミスをしたのが実は1行目であることに気付きやすくなるのではないでしょうか。
|
87
88
|
|
88
|
-
###
|
89
|
+
### 例3:ArgumentError
|
89
90
|
|
90
91
|
```ruby
|
91
92
|
def foo(a, b)
|
@@ -102,7 +103,7 @@ Traceback (most recent call last):
|
|
102
103
|
example3.rb:1:in `foo': wrong number of arguments (given 1, expected 2) (ArgumentError)
|
103
104
|
```
|
104
105
|
|
105
|
-
このように、ArgumentError のエラー発生行は、メソッド定義行(この場合1行目)になってしまいます。しかし実際に ArgumentError
|
106
|
+
このように、ArgumentError のエラー発生行は、メソッド定義行(この場合1行目)になってしまいます。しかし実際に ArgumentError が発生するときの原因は、メソッド定義部分ではなく、呼び出し部分であることがほとんどではないでしょうか?
|
106
107
|
|
107
108
|
この例の場合 Traceback に「from example3.rb:4」と表示されてはいますが、初心者にはやはりわかりにくいのではないかと思われます。
|
108
109
|
|
data/lib/eturem/base.rb
CHANGED
@@ -7,7 +7,7 @@ module Eturem
|
|
7
7
|
# @return [nil] if exception did not raise
|
8
8
|
def self.load(file)
|
9
9
|
begin
|
10
|
-
Kernel.load
|
10
|
+
Kernel.load(File.expand_path(file))
|
11
11
|
rescue Exception => exception
|
12
12
|
return @eturem_class.new(exception) unless exception.is_a? SystemExit
|
13
13
|
end
|
@@ -81,7 +81,7 @@ module Eturem
|
|
81
81
|
@exception_s = exception.to_s
|
82
82
|
|
83
83
|
eturem_path = File.dirname(File.absolute_path(__FILE__))
|
84
|
-
@backtrace_locations = @exception.backtrace_locations.reject do |location|
|
84
|
+
@backtrace_locations = (@exception.backtrace_locations || []).reject do |location|
|
85
85
|
path = File.absolute_path(location.path)
|
86
86
|
path.start_with?(eturem_path) || path.end_with?("/rubygems/core_ext/kernel_require.rb")
|
87
87
|
end
|
@@ -93,7 +93,7 @@ module Eturem
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
if @exception.is_a?(SyntaxError) && @exception_s.match(/\A(?<path
|
96
|
+
if @exception.is_a?(SyntaxError) && @exception_s.match(/\A(?<path>.+?)\:(?<lineno>\d+)/)
|
97
97
|
@path = Regexp.last_match(:path)
|
98
98
|
@lineno = Regexp.last_match(:lineno).to_i
|
99
99
|
else
|
@@ -129,11 +129,10 @@ module Eturem
|
|
129
129
|
def exception_inspect
|
130
130
|
inspect_methods = self.class.inspect_methods
|
131
131
|
inspect_methods.keys.reverse_each do |key|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
return public_send(inspect_methods[key]) if @exception.class.to_s == key
|
132
|
+
if (key.is_a?(Class) && @exception.is_a?(key)) ||
|
133
|
+
(key.is_a?(String) && @exception.class.to_s == key)
|
134
|
+
method = inspect_methods[key]
|
135
|
+
return method ? public_send(method) : nil
|
137
136
|
end
|
138
137
|
end
|
139
138
|
return nil
|
@@ -181,9 +180,12 @@ module Eturem
|
|
181
180
|
|
182
181
|
def prepare_syntax_error
|
183
182
|
@unexpected = @exception_s.match(/unexpected (?<unexpected>(?:','|[^,])+)/) ?
|
184
|
-
Regexp.last_match(:unexpected) :
|
183
|
+
Regexp.last_match(:unexpected) : nil
|
185
184
|
@expected = @exception_s.match(/[,\s]expecting (?<expected>\S+)/) ?
|
186
|
-
Regexp.last_match(:expected) :
|
185
|
+
Regexp.last_match(:expected) : nil
|
186
|
+
if !@expected && @exception_s.match(/(?<invalid>(?:break|next|retry|redo|yield))/)
|
187
|
+
@invalid = Regexp.last_match(:invalid)
|
188
|
+
end
|
187
189
|
end
|
188
190
|
|
189
191
|
def prepare_name_error
|
@@ -244,7 +246,7 @@ module Eturem
|
|
244
246
|
end
|
245
247
|
|
246
248
|
def load_script
|
247
|
-
@script
|
249
|
+
@script ||= ""
|
248
250
|
if @path && File.exist?(@path)
|
249
251
|
@script = File.binread(@path)
|
250
252
|
encoding = "utf-8"
|
data/lib/eturem/ja.rb
CHANGED
@@ -16,7 +16,7 @@ module Eturem
|
|
16
16
|
#Interrupt => :interrupt_inspect,
|
17
17
|
#StandardError => :standard_error_inspect,
|
18
18
|
ArgumentError => :argument_error_inspect,
|
19
|
-
|
19
|
+
UncaughtThrowError => nil,
|
20
20
|
#EncodingError => :encoding_error_inspect,
|
21
21
|
#Encoding::CompatibilityError => :encoding_compatibility_error_inspect,
|
22
22
|
#Encoding::ConverterNotFoundError => :encoding_converter_not_found_error_inspect,
|
@@ -214,7 +214,11 @@ module Eturem
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def exception_inspect
|
217
|
-
|
217
|
+
if @path == "(eval)"
|
218
|
+
return %[eval 中の #{@lineno}行目でエラーが発生しました。\n] + super.to_s
|
219
|
+
else
|
220
|
+
return %[ファイル"#{@path}" #{@lineno}行目でエラーが発生しました。\n] + super.to_s
|
221
|
+
end
|
218
222
|
end
|
219
223
|
|
220
224
|
def no_memory_error_inspect
|
@@ -227,6 +231,13 @@ module Eturem
|
|
227
231
|
end
|
228
232
|
|
229
233
|
def syntax_error_inspect
|
234
|
+
if @invalid
|
235
|
+
highlight!(@script_lines[@lineno], @invalid, "\e[1;31m\e[4m")
|
236
|
+
return "#{@invalid} が不適切な場所にあります。"
|
237
|
+
end
|
238
|
+
|
239
|
+
@unexpected ||= "end-of-input"
|
240
|
+
@expected ||= "end-of-input"
|
230
241
|
if @unexpected.match(/^'(.)'$/)
|
231
242
|
highlight!(@script_lines[@lineno], Regexp.last_match(1), "\e[1;31m\e[4m")
|
232
243
|
elsif @unexpected.match(/^(?:keyword|modifier)_/)
|
@@ -288,10 +299,14 @@ module Eturem
|
|
288
299
|
end
|
289
300
|
return ret
|
290
301
|
else
|
291
|
-
return "「#{@method}
|
302
|
+
return "「#{@method}」への引数が正しくありません。"
|
292
303
|
end
|
293
304
|
end
|
294
305
|
|
306
|
+
def uncaught_throw_error_inspect
|
307
|
+
return ""
|
308
|
+
end
|
309
|
+
|
295
310
|
def name_error_inspect
|
296
311
|
if @exception.name.to_s.encode("UTF-8").include?(" ")
|
297
312
|
load_script
|
data/lib/eturem/version.rb
CHANGED
data/lib/eturem.rb
CHANGED
@@ -16,7 +16,7 @@ if File.exist?(config_file)
|
|
16
16
|
output_backtrace = false if config.match(/^output_backtrace\s*\:\s*(?:false|off|0)/i)
|
17
17
|
output_original = false if config.match( /^output_original\s*\:\s*(?:false|off|0)/i)
|
18
18
|
output_script = false if config.match( /^output_script\s*\:\s*(?:false|off|0)/i)
|
19
|
-
use_coderay = true if config.match(
|
19
|
+
use_coderay = true if config.match( /^use_coderay\s*\:\s*(?:true|on|1)/i)
|
20
20
|
max_backtrace = Regexp.last_match(:num).to_i if config.match( /^max_backtrace\s*\:\s*(?<num>\d+)/i)
|
21
21
|
before_line_num = Regexp.last_match(:num).to_i if config.match(/^before_line_num\s*\:\s*(?<num>\d+)/i)
|
22
22
|
after_line_num = Regexp.last_match(:num).to_i if config.match( /^after_line_num\s*\:\s*(?<num>\d+)/i)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eturem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|