kinetic_cafe_error 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +132 -0
- data/History.rdoc +22 -0
- data/Manifest.txt +2 -0
- data/Rakefile +5 -9
- data/app/controllers/concerns/kinetic_cafe/error_handler.rb +14 -11
- data/lib/kinetic_cafe/error.rb +6 -3
- data/lib/kinetic_cafe/error/minitest.rb +3 -8
- data/lib/kinetic_cafe/error_dsl.rb +3 -3
- data/lib/kinetic_cafe/error_module.rb +15 -14
- data/lib/kinetic_cafe/error_rspec.rb +1 -1
- data/lib/kinetic_cafe/error_tasks.rake +1 -59
- data/lib/kinetic_cafe/error_tasks.rb +84 -0
- data/lib/kinetic_cafe_error.rb +0 -1
- data/test/test_kinetic_cafe_error.rb +7 -7
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbf744127b8dfc1346ed5a2ab19932686592cae4
|
4
|
+
data.tar.gz: 76f1f73098ef8b68b27fcd8833d187af82a547bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d91d16627c9cbccf0da1baafef925a2b5dab8ecf30b4ff83e4ac9f670e49e249ee2be60b7e15508182016053729eae20f6b4b16cc426b5115946bdcfc14abbbe
|
7
|
+
data.tar.gz: be7371032f0f7eef3f4e2ea7006ba382b402f7f3a56f4a2b0f9b400d0b216d2bae5062bff5eaaded6117d1ff3fea5bee62e71175a29b93a8c4cd2bcf30f6e274
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
---
|
2
|
+
# inherit_from: .rubocop_todo.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
Include:
|
6
|
+
- '**/Rakefile'
|
7
|
+
- '**/config.rb'
|
8
|
+
Exclude:
|
9
|
+
- 'bin/**/*'
|
10
|
+
- 'db/**/*'
|
11
|
+
- 'config/**/*'
|
12
|
+
- 'script/**/*'
|
13
|
+
- 'tmp/**/*'
|
14
|
+
RunRailsCops: true
|
15
|
+
DisplayCopNames: true
|
16
|
+
|
17
|
+
Style/AlignHash:
|
18
|
+
EnforcedHashRocketStyle: key
|
19
|
+
EnforcedColonStyle: key
|
20
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
21
|
+
|
22
|
+
Style/AlignParameters:
|
23
|
+
EnforcedStyle: with_first_parameter
|
24
|
+
|
25
|
+
Style/AndOr:
|
26
|
+
EnforcedStyle: conditionals
|
27
|
+
|
28
|
+
Style/BarePercentLiterals:
|
29
|
+
EnforcedStyle: percent_q
|
30
|
+
|
31
|
+
Style/BracesAroundHashParameters:
|
32
|
+
EnforcedStyle: context_dependent
|
33
|
+
|
34
|
+
Style/Documentation:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/Lambda:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/TrailingComma:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/ClassAndModuleChildren:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Style/MultilineOperationIndentation:
|
47
|
+
EnforcedStyle: indented
|
48
|
+
|
49
|
+
Style/DotPosition:
|
50
|
+
EnforcedStyle: trailing
|
51
|
+
|
52
|
+
Style/AlignParameters:
|
53
|
+
EnforcedStyle: with_fixed_indentation
|
54
|
+
|
55
|
+
# Style/BlockDelimiters in semantic mode is the only correct choice, but it is
|
56
|
+
# too finicky to use reliably.
|
57
|
+
Style/BlockDelimiters:
|
58
|
+
Enabled: false
|
59
|
+
EnforcedStyle: semantic
|
60
|
+
|
61
|
+
Style/FormatString:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Style/NumericLiterals:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/SpaceInsideBrackets:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Style/CommentAnnotation:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/AsciiComments:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/ClassCheck:
|
77
|
+
EnforcedStyle: kind_of?
|
78
|
+
|
79
|
+
Style/RegexpLiteral:
|
80
|
+
EnforcedStyle: mixed
|
81
|
+
|
82
|
+
Style/CommandLiteral:
|
83
|
+
EnforcedStyle: percent_x
|
84
|
+
|
85
|
+
Style/UnneededPercentQ:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Metrics/AbcSize:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Metrics/CyclomaticComplexity:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Metrics/MethodLength:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
Metrics/ModuleLength:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
Metrics/ClassLength:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
Metrics/PerceivedComplexity:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Metrics/LineLength:
|
107
|
+
Max: 80
|
108
|
+
Exclude:
|
109
|
+
- test/**/*
|
110
|
+
|
111
|
+
Style/MethodDefParentheses:
|
112
|
+
Exclude:
|
113
|
+
- test/**/*
|
114
|
+
|
115
|
+
Style/DoubleNegation:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Style/MethodDefParentheses:
|
119
|
+
Exclude:
|
120
|
+
- lib/kinetic_cafe/error/minitest.rb
|
121
|
+
|
122
|
+
Style/PerlBackrefs:
|
123
|
+
Exclude:
|
124
|
+
- lib/kinetic_cafe/error_dsl.rb
|
125
|
+
|
126
|
+
Rails/Output:
|
127
|
+
Exclude:
|
128
|
+
- lib/**/*
|
129
|
+
|
130
|
+
Style/LambdaCall:
|
131
|
+
Exclude:
|
132
|
+
- lib/kinetic_cafe/error_tasks.rb
|
data/History.rdoc
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
=== 1.4 / 2015-07-07
|
2
|
+
|
3
|
+
* 2 minor enhancements
|
4
|
+
|
5
|
+
* Changed how kcerror:translations generates the translation YAML for
|
6
|
+
consistent comparison (it no longer uses the YAML library to do this). The
|
7
|
+
file generated will always be for language +kc+ so that this can be used
|
8
|
+
with i18n-tasks.
|
9
|
+
|
10
|
+
* 4 bug fixes
|
11
|
+
|
12
|
+
* Task kcerror:defined would error out if there were no defined descendants.
|
13
|
+
* Task kcerror:translations would error out if there were no defined
|
14
|
+
descendants.
|
15
|
+
* Made task loading more reliable and automatic.
|
16
|
+
* Removed some defaulted, unused parameters for assert_response_kc_error_html
|
17
|
+
(Minitest) and bc_kc_error_html (RSpec).
|
18
|
+
|
19
|
+
* Notes:
|
20
|
+
|
21
|
+
* Applied Rubocop to enforce the KineticCafe house style.
|
22
|
+
|
1
23
|
=== 1.3 / 2015-06-18
|
2
24
|
|
3
25
|
* 3 minor enhancements
|
data/Manifest.txt
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
.autotest
|
2
2
|
.gemtest
|
3
|
+
.rubocop.yml
|
3
4
|
.travis.yml
|
4
5
|
Contributing.rdoc
|
5
6
|
Gemfile
|
@@ -29,6 +30,7 @@ lib/kinetic_cafe/error_engine.rb
|
|
29
30
|
lib/kinetic_cafe/error_module.rb
|
30
31
|
lib/kinetic_cafe/error_rspec.rb
|
31
32
|
lib/kinetic_cafe/error_tasks.rake
|
33
|
+
lib/kinetic_cafe/error_tasks.rb
|
32
34
|
lib/kinetic_cafe_error.rb
|
33
35
|
test/test_helper.rb
|
34
36
|
test/test_kinetic_cafe_error.rb
|
data/Rakefile
CHANGED
@@ -9,21 +9,18 @@ Hoe.plugin :gemspec2
|
|
9
9
|
Hoe.plugin :git
|
10
10
|
Hoe.plugin :minitest
|
11
11
|
Hoe.plugin :travis
|
12
|
-
Hoe.plugin :email unless ENV['CI']
|
12
|
+
Hoe.plugin :email unless ENV['CI'] || ENV['TRAVIS']
|
13
13
|
|
14
|
-
spec = Hoe.spec
|
15
|
-
# HEY! If you fill these out in ~/.hoe_template/minitest-travis/Rakefile.erb,
|
16
|
-
# you'll never have to touch them again!
|
17
|
-
# (delete this comment too, of course)
|
14
|
+
spec = Hoe.spec 'kinetic_cafe_error' do
|
18
15
|
developer('Austin Ziegler', 'aziegler@kineticcafe.com')
|
19
16
|
|
20
17
|
require_ruby_version '>= 1.9.2'
|
21
18
|
|
22
19
|
self.history_file = 'History.rdoc'
|
23
20
|
self.readme_file = 'README.rdoc'
|
24
|
-
self.extra_rdoc_files = FileList[
|
21
|
+
self.extra_rdoc_files = FileList['*.rdoc'].to_a
|
25
22
|
|
26
|
-
license
|
23
|
+
license 'MIT'
|
27
24
|
|
28
25
|
extra_dev_deps << ['hoe-doofus', '~> 1.0']
|
29
26
|
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
@@ -38,6 +35,7 @@ spec = Hoe.spec "kinetic_cafe_error" do
|
|
38
35
|
extra_dev_deps << ['minitest-stub-const', '~> 0.4']
|
39
36
|
extra_dev_deps << ['rack-test', '~> 0.6']
|
40
37
|
extra_dev_deps << ['rake', '~> 10.0']
|
38
|
+
extra_dev_deps << ['rubocop', '~> 0.32']
|
41
39
|
extra_dev_deps << ['simplecov', '~> 0.7']
|
42
40
|
extra_dev_deps << ['coveralls', '~> 0.8']
|
43
41
|
end
|
@@ -65,6 +63,4 @@ namespace :test do
|
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
68
|
-
load 'lib/kinetic_cafe/error_tasks.rake'
|
69
|
-
|
70
66
|
# vim: syntax=ruby
|
@@ -8,6 +8,8 @@ module KineticCafe::ErrorHandler
|
|
8
8
|
|
9
9
|
included do
|
10
10
|
kinetic_cafe_error_handler_for KineticCafe::Error
|
11
|
+
|
12
|
+
class_attribute :__kinetic_cafe_error_handler_log_locale # :nodoc:
|
11
13
|
end
|
12
14
|
|
13
15
|
module ClassMethods
|
@@ -24,9 +26,9 @@ module KineticCafe::ErrorHandler
|
|
24
26
|
# common logging locale for KineticCafe::Error handling without changing
|
25
27
|
# I18n.default_locale.
|
26
28
|
def kinetic_cafe_error_handler_log_locale(locale = nil)
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
self.__kinetic_cafe_error_handler_log_locale = locale if locale
|
30
|
+
self.__kinetic_cafe_error_handler_log_locale ||= I18n.default_locale
|
31
|
+
self.__kinetic_cafe_error_handler_log_locale
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -84,14 +86,15 @@ module KineticCafe::ErrorHandler
|
|
84
86
|
def kinetic_cafe_error_log_error(error)
|
85
87
|
locale = self.class.kinetic_cafe_error_handler_log_locale
|
86
88
|
Rails.logger.error(error.message(locale))
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
|
90
|
+
return unless error.cause
|
91
|
+
|
92
|
+
Rails.logger.error(
|
93
|
+
t(
|
94
|
+
'kinetic_cafe_error.cause',
|
95
|
+
message: error.cause.message,
|
96
|
+
locale: locale
|
94
97
|
)
|
95
|
-
|
98
|
+
)
|
96
99
|
end
|
97
100
|
end
|
data/lib/kinetic_cafe/error.rb
CHANGED
@@ -25,7 +25,7 @@ module KineticCafe # :nodoc:
|
|
25
25
|
# rescue clause and handled there, as is shown in the included
|
26
26
|
# KineticCafe::ErrorHandler controller concern for Rails.
|
27
27
|
class Error < ::StandardError
|
28
|
-
VERSION = '1.
|
28
|
+
VERSION = '1.4' # :nodoc:
|
29
29
|
|
30
30
|
# Get the KineticCafe::Error functionality.
|
31
31
|
include KineticCafe::ErrorModule
|
@@ -146,9 +146,10 @@ module KineticCafe # :nodoc:
|
|
146
146
|
base.send(:include, KineticCafe::ErrorModule)
|
147
147
|
end
|
148
148
|
|
149
|
-
unless rs_defined = base.respond_to?(:__rack_status)
|
149
|
+
unless (rs_defined = base.respond_to?(:__rack_status))
|
150
|
+
rack_status_default = { errors: true, methods: true }
|
150
151
|
base.send :define_singleton_method, :__rack_status do
|
151
|
-
options.fetch(:rack_status,
|
152
|
+
options.fetch(:rack_status, rack_status_default)
|
152
153
|
end
|
153
154
|
end
|
154
155
|
|
@@ -217,3 +218,5 @@ module KineticCafe # :nodoc:
|
|
217
218
|
end
|
218
219
|
|
219
220
|
require_relative 'error_dsl'
|
221
|
+
require_relative 'error_engine' if defined?(::Rails)
|
222
|
+
require_relative 'error_tasks' if defined?(::Rake)
|
@@ -38,10 +38,7 @@ module Minitest #:nodoc:
|
|
38
38
|
|
39
39
|
# Assert that a reponse body (<tt>@response.body</tt>, useful from
|
40
40
|
# ActionController::TestCase) is HTML for the expected error.
|
41
|
-
|
42
|
-
def assert_response_kc_error_html expected, params = {}, msg = nil
|
43
|
-
msg, params = params, {} if msg.nil? && params.kind_of?(String)
|
44
|
-
|
41
|
+
def assert_response_kc_error_html expected, msg = nil
|
45
42
|
msg ||= "Expected #{actual} to be HTML for #{expected}, but it was not."
|
46
43
|
|
47
44
|
assert_template 'kinetic_cafe_error/page', msg
|
@@ -57,13 +54,11 @@ module Minitest #:nodoc:
|
|
57
54
|
# #assert_kc_error_html, depending on whether or not the response is HTML
|
58
55
|
# or not.
|
59
56
|
def assert_response_kc_error expected, params = {}, msg = nil
|
60
|
-
if msg.nil? && params.kind_of?(String)
|
61
|
-
msg, params = params, {}
|
62
|
-
end
|
57
|
+
msg, params = params, {} if msg.nil? && params.kind_of?(String)
|
63
58
|
msg ||= "Expected response to be #{expected}, but was not."
|
64
59
|
|
65
60
|
if @request.format.html?
|
66
|
-
assert_response_kc_error_html expected,
|
61
|
+
assert_response_kc_error_html expected, msg
|
67
62
|
else
|
68
63
|
assert_kc_error_json expected, @response.body, params, msg
|
69
64
|
end
|
@@ -87,10 +87,10 @@ module KineticCafe
|
|
87
87
|
fail ArgumentError, ":key conflicts with class:#{klass}"
|
88
88
|
end
|
89
89
|
|
90
|
-
key = if status.kind_of?(Symbol)
|
90
|
+
key = if status.kind_of?(Symbol) || status.kind_of?(String)
|
91
91
|
"#{klass}_#{KineticCafe::ErrorDSL.namify(status)}"
|
92
92
|
else
|
93
|
-
"#{klass}_#{KineticCafe::ErrorDSL.namify(
|
93
|
+
"#{klass}_#{KineticCafe::ErrorDSL.namify(name)}"
|
94
94
|
end
|
95
95
|
else
|
96
96
|
key = options.fetch(:key) {
|
@@ -168,7 +168,7 @@ module KineticCafe
|
|
168
168
|
end
|
169
169
|
|
170
170
|
if defined?(Rack::Utils) && rack_status
|
171
|
-
Rack::Utils::SYMBOL_TO_STATUS_CODE.
|
171
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE.each_key do |name|
|
172
172
|
if rack_status.fetch(:methods, true)
|
173
173
|
base.singleton_class.send :define_method, name do |options = {}|
|
174
174
|
define_error(options.merge(status: name))
|
@@ -181,26 +181,27 @@ module KineticCafe # :nodoc:
|
|
181
181
|
|
182
182
|
##
|
183
183
|
def included(mod)
|
184
|
-
|
185
|
-
|
186
|
-
'kcerrors'.freeze
|
187
|
-
end
|
184
|
+
default_singleton_method mod, :i18n_key_base do
|
185
|
+
'kcerrors'.freeze
|
188
186
|
end
|
189
187
|
|
190
|
-
|
191
|
-
|
192
|
-
[].freeze
|
193
|
-
end
|
188
|
+
default_singleton_method mod, :i18n_params do
|
189
|
+
[].freeze
|
194
190
|
end
|
195
191
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
].join('.').freeze
|
201
|
-
end
|
192
|
+
default_singleton_method mod, :i18n_key do
|
193
|
+
@i18n_key ||= [
|
194
|
+
i18n_key_base, KineticCafe::ErrorDSL.namify(name)
|
195
|
+
].join('.').freeze
|
202
196
|
end
|
203
197
|
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
def default_singleton_method(mod, name, &block)
|
202
|
+
return if mod.respond_to? name
|
203
|
+
mod.send :define_singleton_method, name, &block
|
204
|
+
end
|
204
205
|
end
|
205
206
|
end
|
206
207
|
end
|
@@ -55,7 +55,7 @@ module KineticCafe
|
|
55
55
|
diffable
|
56
56
|
end
|
57
57
|
|
58
|
-
matcher :be_kc_error_html do |expected
|
58
|
+
matcher :be_kc_error_html do |expected|
|
59
59
|
match do |actual|
|
60
60
|
expect(actual).to render_template('kinetic_cafe_error/page')
|
61
61
|
expect(actual).to render_template('kinetic_cafe_error/_table')
|
@@ -1,59 +1 @@
|
|
1
|
-
|
2
|
-
desc 'Show defined errors.'
|
3
|
-
task defined: 'kcerror:find' do
|
4
|
-
display = ->(root, prefix = '') {
|
5
|
-
puts "#{prefix}- #{root}"
|
6
|
-
|
7
|
-
if @descendants[root]
|
8
|
-
sorted = @descendants[root].sort_by(&:to_s)
|
9
|
-
sorted.each do |child|
|
10
|
-
s = (child == sorted.last) ? '`' : '|'
|
11
|
-
display.(child, "#{prefix.tr('|`', ' ')} #{s}")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
}
|
15
|
-
|
16
|
-
@descendants[StandardError].sort_by(&:to_s).each { |d| display.(d) }
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Generate a sample translation key file.'
|
20
|
-
task :translations, [ :output ] => 'kcerror:find' do |_, args|
|
21
|
-
translations = {}
|
22
|
-
traverse = ->(root) {
|
23
|
-
translation = (translations[root.i18n_key_base] ||= {})
|
24
|
-
name = KineticCafe::ErrorDSL.namify(root)
|
25
|
-
|
26
|
-
params = root.i18n_params.map { |param| "%{#{param}}" }.join(' ')
|
27
|
-
|
28
|
-
if params.empty?
|
29
|
-
translation[name] = %Q(Translation for #{name} with no params.)
|
30
|
-
else
|
31
|
-
translation[name] = %Q(Translation for #{name} with #{params}.)
|
32
|
-
end
|
33
|
-
|
34
|
-
if @descendants[root]
|
35
|
-
@descendants[root].sort_by(&:to_s).each { |child| traverse.(child) }
|
36
|
-
end
|
37
|
-
}
|
38
|
-
|
39
|
-
@descendants[StandardError].sort_by(&:to_s).each { |d| traverse.(d) }
|
40
|
-
|
41
|
-
require 'yaml'
|
42
|
-
translations = YAML.dump({ 'en' => translations })
|
43
|
-
|
44
|
-
if args.output
|
45
|
-
File.open(args.output, 'w') { |f| f.write translations }
|
46
|
-
else
|
47
|
-
puts translations
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
task :find do
|
52
|
-
@descendants = {}
|
53
|
-
ObjectSpace.each_object(Class) do |k|
|
54
|
-
next unless k.singleton_class < KineticCafe::ErrorDSL
|
55
|
-
|
56
|
-
(@descendants[k.superclass] ||= []) << k
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require 'kinetic_cafe/error_tasks'
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module KineticCafe
|
2
|
+
module ErrorTasks
|
3
|
+
extend Rake::DSL
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module KineticCafe::ErrorTasks
|
8
|
+
require 'kinetic_cafe_error'
|
9
|
+
|
10
|
+
namespace :kcerror do
|
11
|
+
desc 'Show defined errors.'
|
12
|
+
task defined: 'kcerror:find' do
|
13
|
+
display = ->(root, prefix = '') {
|
14
|
+
puts "#{prefix}- #{root}"
|
15
|
+
|
16
|
+
if @descendants[root]
|
17
|
+
sorted = @descendants[root].sort_by(&:to_s)
|
18
|
+
sorted.each do |child|
|
19
|
+
s = (child == sorted.last) ? '`' : '|'
|
20
|
+
display.(child, "#{prefix.tr('|`', ' ')} #{s}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
if @descendants[StandardError]
|
26
|
+
@descendants[StandardError].sort_by(&:to_s).each { |d| display.(d) }
|
27
|
+
else
|
28
|
+
puts 'No defined errors.'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Generate a sample translation key file.'
|
33
|
+
task :translations, [ :output ] => 'kcerror:find' do |_, args|
|
34
|
+
translations = {}
|
35
|
+
traverse = ->(root) {
|
36
|
+
translation = (translations[root.i18n_key_base] ||= {})
|
37
|
+
name = KineticCafe::ErrorDSL.namify(root)
|
38
|
+
|
39
|
+
params = root.i18n_params.map { |param| "%{#{param}}" }.join(' ')
|
40
|
+
|
41
|
+
if params.empty?
|
42
|
+
translation[name] = %Q(Translation for #{name} with no params.)
|
43
|
+
else
|
44
|
+
translation[name] = %Q(Translation for #{name} with #{params}.)
|
45
|
+
end
|
46
|
+
|
47
|
+
if @descendants[root]
|
48
|
+
@descendants[root].sort_by(&:to_s).each { |child| traverse.(child) }
|
49
|
+
end
|
50
|
+
}
|
51
|
+
|
52
|
+
if @descendants[StandardError]
|
53
|
+
@descendants[StandardError].sort_by(&:to_s).each { |d| traverse.(d) }
|
54
|
+
|
55
|
+
# Normal YAML dump does not match the pattern that we want to compare
|
56
|
+
# against. Therefore, we are going to write this file manually.
|
57
|
+
text = 'kc:'
|
58
|
+
|
59
|
+
translations.keys.sort.each { |group|
|
60
|
+
text << "\n #{group}:"
|
61
|
+
|
62
|
+
translations[group].keys.sort.each { |k|
|
63
|
+
text << "\n #{k}: >-\n #{translations[group][k]}"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
if args.output
|
68
|
+
File.open(args.output, 'w') { |f| f.puts text }
|
69
|
+
else
|
70
|
+
puts text
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
task :find do
|
76
|
+
@descendants = {}
|
77
|
+
ObjectSpace.each_object(Class) do |k|
|
78
|
+
next unless k.singleton_class < KineticCafe::ErrorDSL
|
79
|
+
|
80
|
+
(@descendants[k.superclass] ||= []) << k
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/kinetic_cafe_error.rb
CHANGED
@@ -33,7 +33,7 @@ describe KineticCafe::Error do
|
|
33
33
|
assert_equal(
|
34
34
|
[
|
35
35
|
'kcerrors.error',
|
36
|
-
{ query:
|
36
|
+
{ query: 'a: 1; b[]: x, b[]: y, b[]: z; c[][d]: 1; c[][e]: 2; f[]: []' }
|
37
37
|
],
|
38
38
|
exception.i18n_message
|
39
39
|
)
|
@@ -91,9 +91,9 @@ describe KineticCafe::Error do
|
|
91
91
|
assert_equal(
|
92
92
|
{
|
93
93
|
status: :bad_request,
|
94
|
-
name:
|
94
|
+
name: 'error',
|
95
95
|
internal: false,
|
96
|
-
i18n_key:
|
96
|
+
i18n_key: 'kcerrors.error'
|
97
97
|
},
|
98
98
|
exception.api_error
|
99
99
|
)
|
@@ -104,9 +104,9 @@ describe KineticCafe::Error do
|
|
104
104
|
{
|
105
105
|
error: {
|
106
106
|
status: :bad_request,
|
107
|
-
name:
|
107
|
+
name: 'error',
|
108
108
|
internal: false,
|
109
|
-
i18n_key:
|
109
|
+
i18n_key: 'kcerrors.error'
|
110
110
|
},
|
111
111
|
message: nil
|
112
112
|
},
|
@@ -121,9 +121,9 @@ describe KineticCafe::Error do
|
|
121
121
|
json: {
|
122
122
|
error: {
|
123
123
|
status: :bad_request,
|
124
|
-
name:
|
124
|
+
name: 'error',
|
125
125
|
internal: false,
|
126
|
-
i18n_key:
|
126
|
+
i18n_key: 'kcerrors.error'
|
127
127
|
},
|
128
128
|
message: nil
|
129
129
|
},
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinetic_cafe_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '10.0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rubocop
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0.32'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0.32'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: simplecov
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,6 +285,7 @@ extra_rdoc_files:
|
|
271
285
|
files:
|
272
286
|
- ".autotest"
|
273
287
|
- ".gemtest"
|
288
|
+
- ".rubocop.yml"
|
274
289
|
- ".travis.yml"
|
275
290
|
- Contributing.rdoc
|
276
291
|
- Gemfile
|
@@ -300,6 +315,7 @@ files:
|
|
300
315
|
- lib/kinetic_cafe/error_module.rb
|
301
316
|
- lib/kinetic_cafe/error_rspec.rb
|
302
317
|
- lib/kinetic_cafe/error_tasks.rake
|
318
|
+
- lib/kinetic_cafe/error_tasks.rb
|
303
319
|
- lib/kinetic_cafe_error.rb
|
304
320
|
- test/test_helper.rb
|
305
321
|
- test/test_kinetic_cafe_error.rb
|