lev 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -334,13 +334,13 @@ The first argument to `paramify` is the key in params which points to a hash of
334
334
  For example, when the incoming params includes :search => {:type, :terms, :num_results}, the `paramify` block might look like:
335
335
 
336
336
  paramify :search do
337
- attribute :search_type, type: String
338
- validates :search_type, presence: true,
339
- inclusion: { in: %w(Name Username Any),
340
- message: "is not valid" }
337
+ attribute :type, type: String
338
+ validates :type, presence: true,
339
+ inclusion: { in: %w(Name Username Any),
340
+ message: "is not valid" }
341
341
 
342
- attribute :search_terms, type: String
343
- validates :search_terms, presence: true
342
+ attribute :terms, type: String
343
+ validates :terms, presence: true
344
344
 
345
345
  attribute :num_results, type: Integer
346
346
  validates :num_results, numericality: { only_integer: true,
@@ -355,17 +355,17 @@ The following is a more complete example using the `paramify` block above:
355
355
  lev_handler
356
356
 
357
357
  paramify :search do
358
- attribute :search_type, type: String
359
- validates :search_type, presence: true,
360
- inclusion: { in: %w(Name Username Any),
361
- message: "is not valid" }
358
+ attribute :type, type: String
359
+ validates :type, presence: true,
360
+ inclusion: { in: %w(Name Username Any),
361
+ message: "is not valid" }
362
362
 
363
- attribute :search_terms, type: String
364
- validates :search_terms, presence: true
363
+ attribute :terms, type: String
364
+ validates :terms, presence: true
365
365
 
366
366
  attribute :num_results, type: Integer
367
367
  validates :num_results, numericality: { only_integer: true,
368
- greater_than_or_equal_to: 0 }
368
+ greater_than_or_equal_to: 0 }
369
369
  end
370
370
 
371
371
  def handle
data/lib/lev/error.rb CHANGED
@@ -23,6 +23,11 @@ module Lev
23
23
  def translate
24
24
  ErrorTranslator.translate(self)
25
25
  end
26
+
27
+ def to_s
28
+ inspect
29
+ end
30
+
26
31
  end
27
32
 
28
33
  end
data/lib/lev/errors.rb CHANGED
@@ -31,17 +31,6 @@ module Lev
31
31
  self.any? {|error| [error.offending_inputs].flatten.include? input}
32
32
  end
33
33
 
34
- def raise_exception_if_any!(exception_type = StandardError)
35
- raise exception_type, collect{|error| error.message}.join('; ') if any?
36
- end
37
-
38
- def reraise_exception!
39
- exception_error = select{|error| error.kind == :exception}.first
40
- return if exception_error.nil?
41
- raise exception_error.data
42
- end
43
-
44
-
45
34
  protected
46
35
 
47
36
  def ignored_error_procs
data/lib/lev/routine.rb CHANGED
@@ -237,13 +237,8 @@ module Lev
237
237
 
238
238
  in_transaction do
239
239
  catch :fatal_errors_encountered do
240
- begin
240
+ begin
241
241
  exec(*args, &block)
242
- rescue StandardError => standard_error
243
- fatal_error(kind: :exception,
244
- code: standard_error.class.name,
245
- message: standard_error.message,
246
- data: standard_error)
247
242
  end
248
243
  end
249
244
  end
data/lib/lev/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lev
2
- VERSION = "3.0.0"
2
+ VERSION = "4.0.0"
3
3
  end
data/spec/errors_spec.rb CHANGED
@@ -2,26 +2,4 @@ require 'spec_helper'
2
2
 
3
3
  describe Lev::Errors do
4
4
 
5
- let(:errors) { Lev::Errors.new }
6
-
7
- it "should raise an exception if requested and there are errors" do
8
- errors.add(false, kind: :lev, code: 'a code', message: 'a message')
9
- expect{errors.raise_exception_if_any!}.to raise_error(StandardError, 'a message')
10
- end
11
-
12
- it "should not raise an exception if requested and there aren't any errors" do
13
- expect{errors.raise_exception_if_any!}.not_to raise_error
14
- end
15
-
16
- it "should reraise an exception if requested and present" do
17
- exception = StandardError.new("a message")
18
- errors.add(false, kind: :exception, code: 'code', data: exception)
19
- expect{errors.reraise_exception!}.to raise_error(StandardError, "a message")
20
- end
21
-
22
- it "should not reraise an exception if requested and not present" do
23
- errors.add(false, kind: :lev, code: 'a code')
24
- expect{errors.reraise_exception!}.not_to raise_error
25
- end
26
-
27
5
  end
data/spec/routine_spec.rb CHANGED
@@ -3,25 +3,33 @@ require 'spec_helper'
3
3
  describe Lev::Routine do
4
4
 
5
5
  before do
6
- stub_const 'RaiseArgumentError', Class.new
7
- RaiseArgumentError.class_eval {
6
+ stub_const 'RaiseError', Class.new
7
+ RaiseError.class_eval {
8
8
  lev_routine
9
9
  def exec
10
- raise ArgumentError, 'a message'
10
+ raise 'error message'
11
+ end
12
+ }
13
+
14
+ stub_const 'RaiseStandardError', Class.new
15
+ RaiseStandardError.class_eval {
16
+ lev_routine
17
+ def exec
18
+ unknown_method_call
11
19
  end
12
20
  }
13
21
  end
14
-
15
- it "should convert exceptions to fatal errors" do
16
- outcome = RaiseArgumentError.call
17
- expect(outcome.errors.count).to eq 1
18
- expect(outcome.errors.first.kind).to eq :exception
22
+
23
+ it "raised errors should propagate" do
24
+ expect{
25
+ RaiseArgumentError.call
26
+ }.to raise_error
19
27
  end
20
28
 
21
- it "should be able to reraise an exception" do
22
- outcome = RaiseArgumentError.call
23
- expect(outcome.errors.count).to eq 1
24
- expect{outcome.errors.reraise_exception!}.to raise_error(ArgumentError, 'a message')
29
+ it "raised StandardErrors should propagate" do
30
+ expect {
31
+ RaiseStandardError.call
32
+ }.to raise_error(NameError)
25
33
  end
26
34
 
27
35
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lev
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - JP Slavinsky
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
12
+ date: 2015-03-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activemodel
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: activerecord
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: actionpack
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: transaction_isolation
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: transaction_retry
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ! '>='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ! '>='
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: active_attr
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ! '>='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ! '>='
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: hashie
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: bundler
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ! '>='
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ! '>='
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: rake
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ! '>='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ! '>='
137
156
  - !ruby/object:Gem::Version
@@ -139,6 +158,7 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: rspec
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - ! '>='
144
164
  - !ruby/object:Gem::Version
@@ -146,6 +166,7 @@ dependencies:
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
171
  - - ! '>='
151
172
  - !ruby/object:Gem::Version
@@ -153,6 +174,7 @@ dependencies:
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: sqlite3
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - ! '>='
158
180
  - !ruby/object:Gem::Version
@@ -160,6 +182,7 @@ dependencies:
160
182
  type: :development
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - ! '>='
165
188
  - !ruby/object:Gem::Version
@@ -167,6 +190,7 @@ dependencies:
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: debugger
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
195
  - - ! '>='
172
196
  - !ruby/object:Gem::Version
@@ -174,6 +198,23 @@ dependencies:
174
198
  type: :development
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: rails
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
177
218
  requirements:
178
219
  - - ! '>='
179
220
  - !ruby/object:Gem::Version
@@ -185,10 +226,6 @@ executables: []
185
226
  extensions: []
186
227
  extra_rdoc_files: []
187
228
  files:
188
- - LICENSE.txt
189
- - README.md
190
- - Rakefile
191
- - lib/lev.rb
192
229
  - lib/lev/better_active_model_errors.rb
193
230
  - lib/lev/delegate_to_routine.rb
194
231
  - lib/lev/error.rb
@@ -207,6 +244,10 @@ files:
207
244
  - lib/lev/transaction_isolation.rb
208
245
  - lib/lev/utilities.rb
209
246
  - lib/lev/version.rb
247
+ - lib/lev.rb
248
+ - LICENSE.txt
249
+ - Rakefile
250
+ - README.md
210
251
  - spec/create_sprocket_spec.rb
211
252
  - spec/deep_merge_spec.rb
212
253
  - spec/errors_spec.rb
@@ -224,26 +265,33 @@ files:
224
265
  homepage: http://github.com/lml/lev
225
266
  licenses:
226
267
  - MIT
227
- metadata: {}
228
268
  post_install_message:
229
269
  rdoc_options: []
230
270
  require_paths:
231
271
  - lib
232
272
  required_ruby_version: !ruby/object:Gem::Requirement
273
+ none: false
233
274
  requirements:
234
275
  - - ! '>='
235
276
  - !ruby/object:Gem::Version
236
277
  version: '0'
278
+ segments:
279
+ - 0
280
+ hash: 2525822979360039563
237
281
  required_rubygems_version: !ruby/object:Gem::Requirement
282
+ none: false
238
283
  requirements:
239
284
  - - ! '>='
240
285
  - !ruby/object:Gem::Version
241
286
  version: '0'
287
+ segments:
288
+ - 0
289
+ hash: 2525822979360039563
242
290
  requirements: []
243
291
  rubyforge_project:
244
- rubygems_version: 2.2.2
292
+ rubygems_version: 1.8.23.2
245
293
  signing_key:
246
- specification_version: 4
294
+ specification_version: 3
247
295
  summary: Ride the rails but don't touch them.
248
296
  test_files:
249
297
  - spec/create_sprocket_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MzU0MTQ0ODBlZTkwMjQwNGNmNzJkZDRlMmJkYjA1OThkNjM2ODA4ZQ==
5
- data.tar.gz: !binary |-
6
- ZmQzOTBhZTczOGQzZDZlNzc4NTNiNWNkZDJiYTc0ZjU4ZWFmNmE5ZA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- YzBlMDMzMzBiMDIyMDliY2ZhMDM0MDc0MzI2NGQ2NGM3NzAwNmU4N2NkNzhm
10
- MGM2YjdmMTQwYzE5MjAyY2E3MDIzM2Y0ODIzYTQwMmRmMDlmOTVjYjY3Zjg3
11
- ZmRhMGFkNTVlYjRjODI3MDVjMGE2ZjI5MGU5OGJhMDIzMjhmMzg=
12
- data.tar.gz: !binary |-
13
- NDE5MjFmNjliMTRjZTUxYzdhZWFmN2FmN2UwNzc5NDE5MmYzYWQ5MzEwZjI2
14
- NWY3NDE0ODA5Y2ViOWE4OGI2YzcwOWFiY2NjZjIzZTYwYWYwOWNkNDgzN2Iy
15
- NmE0NWIzOTM1ODg1YzNiOGNjMTY4MDhjZTUzMzE0N2UwNDJjMmU=