eturem 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ module Eturem
2
+ module SystemStackErrorExt
3
+ include ExceptionExt
4
+
5
+ def eturem_message()
6
+ @eturem_message_ja = "システムスタックがあふれました。意図しない無限ループが生じている可能性があります。"
7
+ super
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module Eturem
2
+ module TypeErrorExt
3
+ include ExceptionExt
4
+
5
+ def eturem_message()
6
+ @eturem_message_ja = "「#{@eturem_label}」への引数の型(種類)が正しくありません。"
7
+ if @eturem_message.match(/no implicit conversion of (\S+) into (\S+)/)
8
+ @eturem_message_ja += "\n本来 #{$2} 型などが来るべきところに #{$1} 型が来ています。"
9
+ end
10
+ super
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module UncaughtThrowErrorExt
5
+ include ExceptionExt
6
+
7
+ def eturem_message()
8
+ super
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module Base
5
+ def self.warning_message(path, lineno, warning)
6
+ str = "\e[1;33m【警告】\e[0m" +
7
+ (path == "(eval)" ? "eval 中の" : %<ファイル"#{path}" #{lineno}行目:>) +
8
+ (@@eturem_output_original ? "#{warning}\n" : "\n")
9
+ script_lines = Eturem::Base.read_script(path)
10
+ linenos = [lineno]
11
+ case warning
12
+ when "found `= literal' in conditional, should be =="
13
+ Eturem::Base.highlight(script_lines[lineno], "=", "\e[4;33m")
14
+ str += "条件式部分で「 = 」が使われています。「 == 」の間違いではありませんか?"
15
+ when /^assigned but unused variable - (\S+)/
16
+ var_name = $1
17
+ Eturem::Base.highlight(script_lines[lineno], var_name, "\e[4;33m")
18
+ str += "変数「#{var_name}」が割り当てられていますが、その後一度も使用されていません。"
19
+ when /mismatched indentations at '([^']+)' with '([^']+)' at (\d+)/
20
+ keyword1, keyword2, lineno2 = $1, $2, $3.to_i
21
+ linenos.push(lineno2)
22
+ Eturem::Base.highlight(script_lines[lineno ], keyword1, "\e[4;33m")
23
+ Eturem::Base.highlight(script_lines[lineno2], keyword2, "\e[4;33m")
24
+ str += "この行の「#{keyword1}」と、それに対応した #{lineno2}行目の「#{keyword2}」のインデントが揃っていません。"
25
+ when /already initialized constant (\S+)/
26
+ const = $1
27
+ Eturem::Base.highlight(script_lines[lineno], const, "\e[4;33m")
28
+ str += "定数「#{const}」は既に定義されています。"
29
+ when /previous definition of (\S+) was here/
30
+ const = $1
31
+ Eturem::Base.highlight(script_lines[lineno], const, "\e[4;33m")
32
+ str = (path == "(eval)" ? "eval 中の" : %<ファイル"#{path}" #{lineno}行目:>)
33
+ str += (@@eturem_output_original ? "#{warning}\n" : "\n")
34
+ str += "(ここで「#{const}」の定義がされています。)"
35
+ else
36
+ return nil
37
+ end
38
+ script = @@eturem_output_script ? Eturem::Base.script(script_lines, linenos, lineno) : ""
39
+ "#{str}\n#{script}\n"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ module Eturem
2
+ module ZeroDivisionErrorExt
3
+ include ExceptionExt
4
+
5
+ def eturem_message()
6
+ @eturem_message_ja = "割る数が 0 での割り算はできません。"
7
+ super
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Eturem
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,13 @@
1
+ module Warning
2
+ def self.warn(*message)
3
+ new_message = message.map do |mes|
4
+ if mes.force_encoding("utf-8").match(/^(.+?):(\d+):\s*warning:\s*/)
5
+ path, lineno, warning = $1, $2.to_i, $'.strip
6
+ path = Eturem.program_name if path == File.expand_path(Eturem.program_name)
7
+ str = Eturem::Base.warning_message(path, lineno, warning)
8
+ end
9
+ str || mes
10
+ end
11
+ super(*new_message)
12
+ end
13
+ end
metadata CHANGED
@@ -1,61 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eturem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nodai2hITC
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-20 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '5.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '5.0'
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: Easy To Understand Ruby Error Message.
56
14
  email:
57
15
  - nodai2h.itc@gmail.com
58
- executables: []
16
+ executables:
17
+ - eturem
59
18
  extensions: []
60
19
  extra_rdoc_files: []
61
20
  files:
@@ -69,15 +28,35 @@ files:
69
28
  - bin/console
70
29
  - bin/setup
71
30
  - eturem.gemspec
31
+ - exe/eturem
72
32
  - lib/eturem.rb
73
33
  - lib/eturem/base.rb
74
34
  - lib/eturem/en.rb
35
+ - lib/eturem/en/main.rb
36
+ - lib/eturem/en/warning.rb
75
37
  - lib/eturem/ja.rb
38
+ - lib/eturem/ja/argument_error.rb
39
+ - lib/eturem/ja/dxruby_error.rb
40
+ - lib/eturem/ja/error_enoent.rb
41
+ - lib/eturem/ja/interrupt.rb
42
+ - lib/eturem/ja/load_error.rb
43
+ - lib/eturem/ja/main.rb
44
+ - lib/eturem/ja/name_error.rb
45
+ - lib/eturem/ja/no_memory_error.rb
46
+ - lib/eturem/ja/syntax_error.rb
47
+ - lib/eturem/ja/system_stack_error.rb
48
+ - lib/eturem/ja/type_error.rb
49
+ - lib/eturem/ja/uncaught_throw_error.rb
50
+ - lib/eturem/ja/warning.rb
51
+ - lib/eturem/ja/zero_division_error.rb
76
52
  - lib/eturem/version.rb
53
+ - lib/eturem/warning.rb
77
54
  homepage: https://github.com/nodai2hITC/eturem
78
55
  licenses:
79
56
  - MIT
80
- metadata: {}
57
+ metadata:
58
+ homepage_uri: https://github.com/nodai2hITC/eturem
59
+ source_code_uri: https://github.com/nodai2hITC/eturem
81
60
  post_install_message:
82
61
  rdoc_options: []
83
62
  require_paths:
@@ -86,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
65
  requirements:
87
66
  - - ">="
88
67
  - !ruby/object:Gem::Version
89
- version: '0'
68
+ version: 2.4.0
90
69
  required_rubygems_version: !ruby/object:Gem::Requirement
91
70
  requirements:
92
71
  - - ">="
93
72
  - !ruby/object:Gem::Version
94
73
  version: '0'
95
74
  requirements: []
96
- rubygems_version: 3.0.1
75
+ rubygems_version: 3.1.2
97
76
  signing_key:
98
77
  specification_version: 4
99
78
  summary: Easy To Understand Ruby Error Message.