params_ready 0.0.2 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/params_ready/builder.rb +21 -0
- data/lib/params_ready/extensions/delegation.rb +1 -0
- data/lib/params_ready/extensions/freezer.rb +2 -0
- data/lib/params_ready/extensions/undefined.rb +8 -0
- data/lib/params_ready/format.rb +4 -2
- data/lib/params_ready/helpers/arel_builder.rb +96 -35
- data/lib/params_ready/helpers/callable.rb +14 -0
- data/lib/params_ready/helpers/interface_definer.rb +48 -0
- data/lib/params_ready/helpers/memo.rb +0 -1
- data/lib/params_ready/helpers/options.rb +77 -9
- data/lib/params_ready/helpers/parameter_storage_class_methods.rb +27 -0
- data/lib/params_ready/helpers/parameter_user_class_methods.rb +18 -14
- data/lib/params_ready/helpers/rule.rb +30 -11
- data/lib/params_ready/helpers/usage_rule.rb +21 -3
- data/lib/params_ready/marshaller/array_marshallers.rb +4 -3
- data/lib/params_ready/marshaller/{hash_set_marshallers.rb → enum_set_marshallers.rb} +5 -5
- data/lib/params_ready/marshaller/polymorph_marshallers.rb +2 -2
- data/lib/params_ready/marshaller/{hash_marshallers.rb → struct_marshallers.rb} +5 -5
- data/lib/params_ready/marshaller/tuple_marshallers.rb +2 -2
- data/lib/params_ready/ordering/column.rb +1 -1
- data/lib/params_ready/output_parameters.rb +13 -2
- data/lib/params_ready/pagination/keyset_pagination.rb +5 -5
- data/lib/params_ready/parameter/{abstract_hash_parameter.rb → abstract_struct_parameter.rb} +6 -6
- data/lib/params_ready/parameter/array_parameter.rb +2 -2
- data/lib/params_ready/parameter/definition.rb +48 -40
- data/lib/params_ready/parameter/{hash_set_parameter.rb → enum_set_parameter.rb} +11 -10
- data/lib/params_ready/parameter/parameter.rb +48 -29
- data/lib/params_ready/parameter/state.rb +4 -4
- data/lib/params_ready/parameter/{hash_parameter.rb → struct_parameter.rb} +11 -10
- data/lib/params_ready/parameter/tuple_parameter.rb +1 -1
- data/lib/params_ready/parameter/value_parameter.rb +14 -10
- data/lib/params_ready/parameter_user.rb +7 -15
- data/lib/params_ready/query/array_grouping.rb +4 -4
- data/lib/params_ready/query/exists_predicate.rb +3 -3
- data/lib/params_ready/query/grouping.rb +8 -2
- data/lib/params_ready/query/join_clause.rb +91 -28
- data/lib/params_ready/query/predicate.rb +3 -3
- data/lib/params_ready/query/relation.rb +29 -14
- data/lib/params_ready/query/structured_grouping.rb +4 -4
- data/lib/params_ready/query/variable_operator_predicate.rb +12 -12
- data/lib/params_ready/value/coder.rb +36 -8
- data/lib/params_ready/version.rb +7 -0
- data/lib/params_ready.rb +3 -11
- metadata +56 -10
@@ -18,9 +18,8 @@ module ParamsReady
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
class
|
21
|
+
class AbstractCoder
|
22
22
|
extend Extensions::ClassReaderWriter
|
23
|
-
extend Coercion
|
24
23
|
|
25
24
|
def self.value_class_name
|
26
25
|
last = self.name.split("::").last
|
@@ -31,10 +30,41 @@ module ParamsReady
|
|
31
30
|
type_identifier :value
|
32
31
|
end
|
33
32
|
|
33
|
+
class Coder < AbstractCoder
|
34
|
+
extend Coercion
|
35
|
+
|
36
|
+
def self.instance(**opts)
|
37
|
+
raise ParamsReadyError, "No options expected, got: #{opts}" unless opts.empty?
|
38
|
+
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
class Instantiable < AbstractCoder
|
43
|
+
include Coercion
|
44
|
+
|
45
|
+
def self.instance(**opts)
|
46
|
+
new **opts
|
47
|
+
end
|
48
|
+
|
49
|
+
def type_identifier
|
50
|
+
self.class.type_identifier
|
51
|
+
end
|
52
|
+
|
53
|
+
def strict_default?
|
54
|
+
self.class.strict_default?
|
55
|
+
end
|
56
|
+
|
57
|
+
def value_class_name
|
58
|
+
self.class.value_class_name
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
34
63
|
class GenericCoder
|
35
64
|
extend Extensions::LateInit
|
36
65
|
extend Extensions::Finalizer
|
37
66
|
include Extensions::Finalizer::InstanceMethods
|
67
|
+
include Coercion
|
38
68
|
|
39
69
|
def initialize(name)
|
40
70
|
@name = name
|
@@ -43,8 +73,6 @@ module ParamsReady
|
|
43
73
|
@type_identifier = nil
|
44
74
|
end
|
45
75
|
|
46
|
-
def strict_default?; true; end
|
47
|
-
|
48
76
|
late_init(:coerce, getter: false)
|
49
77
|
late_init(:format, getter: false)
|
50
78
|
late_init(:type_identifier, obligatory: false)
|
@@ -53,10 +81,8 @@ module ParamsReady
|
|
53
81
|
@name
|
54
82
|
end
|
55
83
|
|
56
|
-
def
|
84
|
+
def coerce(input, context)
|
57
85
|
@coerce[input, context]
|
58
|
-
rescue => _error
|
59
|
-
raise CoercionError.new(input, @name)
|
60
86
|
end
|
61
87
|
|
62
88
|
def format(value, format)
|
@@ -74,7 +100,9 @@ module ParamsReady
|
|
74
100
|
|
75
101
|
def self.coerce(input, _)
|
76
102
|
return nil if input.nil? || input == ''
|
77
|
-
|
103
|
+
|
104
|
+
base = 10 if input.is_a? String
|
105
|
+
Integer(input, base)
|
78
106
|
end
|
79
107
|
|
80
108
|
def self.format(value, format)
|
data/lib/params_ready.rb
CHANGED
@@ -2,8 +2,8 @@ require 'ruby2_keywords'
|
|
2
2
|
require 'arel'
|
3
3
|
|
4
4
|
require_relative 'params_ready/parameter/array_parameter'
|
5
|
-
require_relative 'params_ready/parameter/
|
6
|
-
require_relative 'params_ready/parameter/
|
5
|
+
require_relative 'params_ready/parameter/struct_parameter'
|
6
|
+
require_relative 'params_ready/parameter/enum_set_parameter'
|
7
7
|
require_relative 'params_ready/parameter/polymorph_parameter'
|
8
8
|
require_relative 'params_ready/parameter/tuple_parameter'
|
9
9
|
require_relative 'params_ready/parameter/value_parameter'
|
@@ -25,12 +25,4 @@ require_relative 'params_ready/query/nullness_predicate'
|
|
25
25
|
require_relative 'params_ready/query/polymorph_predicate'
|
26
26
|
require_relative 'params_ready/query/relation'
|
27
27
|
require_relative 'params_ready/query/variable_operator_predicate'
|
28
|
-
|
29
|
-
|
30
|
-
module ParamsReady
|
31
|
-
VERSION = '0.0.2'.freeze
|
32
|
-
|
33
|
-
def self.gem_version
|
34
|
-
::Gem::Version.new(VERSION)
|
35
|
-
end
|
36
|
-
end
|
28
|
+
require_relative 'params_ready/version'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: params_ready
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Milsimer
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '6'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -66,9 +66,52 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.9'
|
69
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-rg
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.20'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.20'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1'
|
111
|
+
description: "Create well defined controller interfaces. Sanitize, coerce and constrain
|
70
112
|
\nincoming parameters to safely populate data models, hold session state in URI
|
71
|
-
variables \nacross different locations, build SQL queries
|
113
|
+
variables \nacross different locations, build SQL queries, apply ordering and offset/keyset
|
114
|
+
pagination.\n"
|
72
115
|
email: tomas.milsimer@protonmail.com
|
73
116
|
executables: []
|
74
117
|
extensions: []
|
@@ -89,8 +132,10 @@ files:
|
|
89
132
|
- lib/params_ready/extensions/undefined.rb
|
90
133
|
- lib/params_ready/format.rb
|
91
134
|
- lib/params_ready/helpers/arel_builder.rb
|
135
|
+
- lib/params_ready/helpers/callable.rb
|
92
136
|
- lib/params_ready/helpers/conditional_block.rb
|
93
137
|
- lib/params_ready/helpers/find_in_hash.rb
|
138
|
+
- lib/params_ready/helpers/interface_definer.rb
|
94
139
|
- lib/params_ready/helpers/key_map.rb
|
95
140
|
- lib/params_ready/helpers/memo.rb
|
96
141
|
- lib/params_ready/helpers/options.rb
|
@@ -107,10 +152,10 @@ files:
|
|
107
152
|
- lib/params_ready/marshaller/builder_module.rb
|
108
153
|
- lib/params_ready/marshaller/collection.rb
|
109
154
|
- lib/params_ready/marshaller/definition_module.rb
|
110
|
-
- lib/params_ready/marshaller/
|
111
|
-
- lib/params_ready/marshaller/hash_set_marshallers.rb
|
155
|
+
- lib/params_ready/marshaller/enum_set_marshallers.rb
|
112
156
|
- lib/params_ready/marshaller/parameter_module.rb
|
113
157
|
- lib/params_ready/marshaller/polymorph_marshallers.rb
|
158
|
+
- lib/params_ready/marshaller/struct_marshallers.rb
|
114
159
|
- lib/params_ready/marshaller/tuple_marshallers.rb
|
115
160
|
- lib/params_ready/ordering/column.rb
|
116
161
|
- lib/params_ready/ordering/ordering.rb
|
@@ -123,14 +168,14 @@ files:
|
|
123
168
|
- lib/params_ready/pagination/nulls.rb
|
124
169
|
- lib/params_ready/pagination/offset_pagination.rb
|
125
170
|
- lib/params_ready/pagination/tendency.rb
|
126
|
-
- lib/params_ready/parameter/
|
171
|
+
- lib/params_ready/parameter/abstract_struct_parameter.rb
|
127
172
|
- lib/params_ready/parameter/array_parameter.rb
|
128
173
|
- lib/params_ready/parameter/definition.rb
|
129
|
-
- lib/params_ready/parameter/
|
130
|
-
- lib/params_ready/parameter/hash_set_parameter.rb
|
174
|
+
- lib/params_ready/parameter/enum_set_parameter.rb
|
131
175
|
- lib/params_ready/parameter/parameter.rb
|
132
176
|
- lib/params_ready/parameter/polymorph_parameter.rb
|
133
177
|
- lib/params_ready/parameter/state.rb
|
178
|
+
- lib/params_ready/parameter/struct_parameter.rb
|
134
179
|
- lib/params_ready/parameter/tuple_parameter.rb
|
135
180
|
- lib/params_ready/parameter/value_parameter.rb
|
136
181
|
- lib/params_ready/parameter_definer.rb
|
@@ -155,6 +200,7 @@ files:
|
|
155
200
|
- lib/params_ready/value/constraint.rb
|
156
201
|
- lib/params_ready/value/custom.rb
|
157
202
|
- lib/params_ready/value/validator.rb
|
203
|
+
- lib/params_ready/version.rb
|
158
204
|
homepage: https://github.com/lame-impala/params_ready
|
159
205
|
licenses:
|
160
206
|
- MIT
|
@@ -174,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
220
|
- !ruby/object:Gem::Version
|
175
221
|
version: '0'
|
176
222
|
requirements: []
|
177
|
-
rubygems_version: 3.1.
|
223
|
+
rubygems_version: 3.1.4
|
178
224
|
signing_key:
|
179
225
|
specification_version: 4
|
180
226
|
summary: Define controller interfaces in Rails
|