pavlov 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pavlov.rb +0 -2
- data/lib/pavlov/alpha_compatibility.rb +39 -0
- data/lib/pavlov/command.rb +2 -2
- data/lib/pavlov/concern.rb +54 -0
- data/lib/pavlov/interactor.rb +2 -3
- data/lib/pavlov/operation.rb +2 -4
- data/lib/pavlov/query.rb +2 -2
- data/lib/pavlov/version.rb +1 -1
- metadata +5 -33
- data/lib/pavlov/validation_error.rb +0 -4
- data/lib/pavlov/validations.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13bc3cf5812e5e607d68b9609120e074dad275a4
|
4
|
+
data.tar.gz: ff07d489d86b0dba8a4bc8b4f694d0d771b14f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56aef16927ef152a86585bb4acdfcf2a03b1463694d36d88a687216a30200e75037c3890730933cca0b4df2353ce1e75ba34016d8d5b67860b25b64dd8b3f79b
|
7
|
+
data.tar.gz: 72deaa24033f719ff780a7b2e2017b59d5618bae0f01a3be24ebd4ea8297ce2b86f5b0ea49a5bc36a9882610d5031292052444254bf927a1ef8d2c6e6574df71
|
data/lib/pavlov.rb
CHANGED
@@ -31,8 +31,6 @@ end
|
|
31
31
|
require_relative 'pavlov/engine' if defined?(Rails)
|
32
32
|
require_relative 'pavlov/helpers'
|
33
33
|
require_relative 'pavlov/access_denied'
|
34
|
-
require_relative 'pavlov/validation_error'
|
35
|
-
require_relative 'pavlov/validations'
|
36
34
|
require_relative 'pavlov/operation'
|
37
35
|
require_relative 'pavlov/command'
|
38
36
|
require_relative 'pavlov/query'
|
@@ -62,7 +62,46 @@ module Pavlov
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
class ValidationError < StandardError
|
66
|
+
end
|
67
|
+
|
68
|
+
module Validations
|
69
|
+
def validate_hexadecimal_string param_name, param
|
70
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should be an hexadecimal string." unless param.is_a? String and /\A[\da-fA-F]+\Z/.match param
|
71
|
+
end
|
72
|
+
|
73
|
+
def validate_regex param_name, param, regex, message
|
74
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} #{message}" unless regex.match param
|
75
|
+
end
|
76
|
+
|
77
|
+
def validate_integer param_name, param, opts = {}
|
78
|
+
return if opts[:allow_blank] && param.blank?
|
79
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should be an integer." unless param.is_a? Integer
|
80
|
+
end
|
81
|
+
|
82
|
+
def validate_in_set param_name, param, set
|
83
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should be on of these values: #{set.inspect}." unless set.include? param
|
84
|
+
end
|
85
|
+
|
86
|
+
def validate_string param_name, param
|
87
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should be a string." unless param.is_a? String
|
88
|
+
end
|
89
|
+
|
90
|
+
def validate_nonempty_string param_name, param
|
91
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should be a nonempty string." unless param.is_a?(String) && not(param.nil?) && not(param.empty?)
|
92
|
+
end
|
93
|
+
|
94
|
+
def validate_integer_string param_name, param
|
95
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should be an integer string." unless param.is_a? String and /\A\d+\Z/.match param
|
96
|
+
end
|
97
|
+
|
98
|
+
def validate_not_nil param_name, param
|
99
|
+
raise Pavlov::ValidationError, "#{param_name.to_s} should not be nil." if param.nil?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
65
103
|
module Operation
|
104
|
+
include Pavlov::Validations
|
66
105
|
module ClassMethods
|
67
106
|
def arguments(*args)
|
68
107
|
# Add generic attribute for each argument
|
data/lib/pavlov/command.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (c) 2005-2011 David Heinemeier Hansson
|
2
|
+
# (c) 2013 Factlink, Inc
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# fork from active_support 3.2.14 : ActiveSuport::Concern
|
23
|
+
# Removed deprecation warning, and don't include InstanceMethods
|
24
|
+
#
|
25
|
+
# Including InstanceMethods conflicts with Virtus (which also uses InstanceMethods)
|
26
|
+
|
27
|
+
module Pavlov
|
28
|
+
module Concern
|
29
|
+
def self.extended(base)
|
30
|
+
base.instance_variable_set("@_dependencies", [])
|
31
|
+
end
|
32
|
+
|
33
|
+
def append_features(base)
|
34
|
+
if base.instance_variable_defined?("@_dependencies")
|
35
|
+
base.instance_variable_get("@_dependencies") << self
|
36
|
+
return false
|
37
|
+
else
|
38
|
+
return false if base < self
|
39
|
+
@_dependencies.each { |dep| base.send(:include, dep) }
|
40
|
+
super
|
41
|
+
base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
|
42
|
+
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def included(base = nil, &block)
|
47
|
+
if base.nil?
|
48
|
+
@_included_block = block
|
49
|
+
else
|
50
|
+
super
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/pavlov/interactor.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'active_support/inflector'
|
1
|
+
require_relative 'concern'
|
3
2
|
require 'pavlov/operation'
|
4
3
|
|
5
4
|
module Pavlov
|
6
5
|
module Interactor
|
7
|
-
extend
|
6
|
+
extend Pavlov::Concern
|
8
7
|
include Pavlov::Operation
|
9
8
|
|
10
9
|
module ClassMethods
|
data/lib/pavlov/operation.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
|
2
|
-
require 'pavlov/validations'
|
1
|
+
require_relative 'concern'
|
3
2
|
require 'pavlov/helpers'
|
4
3
|
require 'virtus'
|
5
4
|
require_relative 'access_denied'
|
6
5
|
|
7
6
|
module Pavlov
|
8
7
|
module Operation
|
9
|
-
extend
|
8
|
+
extend Pavlov::Concern
|
10
9
|
include Pavlov::Helpers
|
11
|
-
include Pavlov::Validations
|
12
10
|
include Virtus
|
13
11
|
|
14
12
|
def validate
|
data/lib/pavlov/query.rb
CHANGED
data/lib/pavlov/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pavlov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marten@veldthuis.com
|
@@ -13,36 +13,8 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-08-
|
16
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
|
-
- !ruby/object:Gem::Dependency
|
19
|
-
name: activesupport
|
20
|
-
requirement: !ruby/object:Gem::Requirement
|
21
|
-
requirements:
|
22
|
-
- - '>='
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 3.2.7
|
25
|
-
type: :runtime
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
requirements:
|
29
|
-
- - '>='
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: 3.2.7
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: activemodel
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - '>='
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: 3.2.7
|
39
|
-
type: :runtime
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
- - '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 3.2.7
|
46
18
|
- !ruby/object:Gem::Dependency
|
47
19
|
name: virtus
|
48
20
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,16 +171,16 @@ files:
|
|
199
171
|
- lib/pavlov/access_denied.rb
|
200
172
|
- lib/pavlov/alpha_compatibility.rb
|
201
173
|
- lib/pavlov/command.rb
|
174
|
+
- lib/pavlov/concern.rb
|
202
175
|
- lib/pavlov/engine.rb
|
203
176
|
- lib/pavlov/helpers.rb
|
204
177
|
- lib/pavlov/interactor.rb
|
205
178
|
- lib/pavlov/operation.rb
|
206
179
|
- lib/pavlov/query.rb
|
207
|
-
- lib/pavlov/validation_error.rb
|
208
|
-
- lib/pavlov/validations.rb
|
209
180
|
- lib/pavlov/version.rb
|
210
181
|
homepage: https://github.com/Factlink/pavlov/
|
211
|
-
licenses:
|
182
|
+
licenses:
|
183
|
+
- MIT
|
212
184
|
metadata: {}
|
213
185
|
post_install_message:
|
214
186
|
rdoc_options: []
|
data/lib/pavlov/validations.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'pavlov/validation_error'
|
2
|
-
|
3
|
-
module Pavlov
|
4
|
-
module Validations
|
5
|
-
def validate_hexadecimal_string param_name, param
|
6
|
-
#warn "[DEPRECATION] `validate_hexadecimal_string` is deprecated. Please use the ActiveModel validation instead."
|
7
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should be an hexadecimal string." unless param.is_a? String and /\A[\da-fA-F]+\Z/.match param
|
8
|
-
end
|
9
|
-
|
10
|
-
def validate_regex param_name, param, regex, message
|
11
|
-
#warn "[DEPRECATION] `validate_integer` is deprecated. Please use the default format_of ActiveModel validator instead."
|
12
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} #{message}" unless regex.match param
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate_integer param_name, param, opts = {}
|
16
|
-
#warn "[DEPRECATION] `validate_integer` is deprecated. Please use the default numericality ActiveModel validator with the :only_integer option instead."
|
17
|
-
return if opts[:allow_blank] && param.blank?
|
18
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should be an integer." unless param.is_a? Integer
|
19
|
-
end
|
20
|
-
|
21
|
-
def validate_in_set param_name, param, set
|
22
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should be on of these values: #{set.inspect}." unless set.include? param
|
23
|
-
end
|
24
|
-
|
25
|
-
def validate_string param_name, param
|
26
|
-
#warn "[DEPRECATION] `validate_string` is deprecated. Please use the ActiveModel validation instead."
|
27
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should be a string." unless param.is_a? String
|
28
|
-
end
|
29
|
-
|
30
|
-
def validate_nonempty_string param_name, param
|
31
|
-
#warn "[DEPRECATION] `validate_string` is deprecated. Please use the ActiveModel validation with the :non_empty option instead."
|
32
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should be a nonempty string." unless param.is_a?(String) && not(param.nil?) && not(param.empty?)
|
33
|
-
end
|
34
|
-
|
35
|
-
def validate_integer_string param_name, param
|
36
|
-
#warn "[DEPRECATION] `validate_integer_string` is deprecated. Please use the ActiveModel validation instead."
|
37
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should be an integer string." unless param.is_a? String and /\A\d+\Z/.match param
|
38
|
-
end
|
39
|
-
|
40
|
-
def validate_not_nil param_name, param
|
41
|
-
#warn "[DEPRECATION] `validate_not_nil` is deprecated. Please use the default presence ActiveModel validator instead."
|
42
|
-
raise Pavlov::ValidationError, "#{param_name.to_s} should not be nil." if param.nil?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|