c80_shared 0.1.62 → 0.1.63
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/app/serializers/boat_serializer.rb +5 -0
- data/lib/c80_shared/version.rb +1 -1
- data/lib/c80_shared.rb +1 -1
- data/scratch_105___02.txt +13 -0
- metadata +3 -44
- data/app/repositories/accounts/admin_account_repository.rb +0 -35
- data/app/repositories/accounts/central_agent_account_repository.rb +0 -46
- data/app/repositories/accounts/client_account_repository.rb +0 -43
- data/app/repositories/accounts/manager_account_repository.rb +0 -35
- data/app/repositories/accounts/manager_guest_account_repository.rb +0 -35
- data/app/repositories/accounts/moderator_account_repository.rb +0 -35
- data/app/schemas/base.rb +0 -69
- data/app/schemas/base_boat_schema.rb +0 -235
- data/app/schemas/central_agent/save_boat_schema.rb +0 -57
- data/app/services/abstract_prices_service.rb +0 -70
- data/app/services/boats/boat_prices_save_service.rb +0 -81
- data/app/services/boats/boat_sale_prices_save_service.rb +0 -60
- data/app/services/boats/dimension_service.rb +0 -44
- data/app/services/central_agent/save_boat_service.rb +0 -111
- data/app/services/lease/create_broadcast_inquiry_service.rb +0 -62
- data/app/services/lease/destroy_inquiry_service.rb +0 -5
- data/config/initializers/core_ext/active_record_log_subscriber.rb +0 -60
- data/config/initializers/core_ext/string.rb +0 -62
- data/lib/dry/errors.rb +0 -77
- data/lib/dry/rule.rb +0 -75
- data/lib/dry/rules/and.rb +0 -13
- data/lib/dry/rules/between.rb +0 -20
- data/lib/dry/rules/binary.rb +0 -18
- data/lib/dry/rules/collection.rb +0 -18
- data/lib/dry/rules/composite.rb +0 -21
- data/lib/dry/rules/equal.rb +0 -20
- data/lib/dry/rules/format.rb +0 -20
- data/lib/dry/rules/greater_than.rb +0 -20
- data/lib/dry/rules/greater_than_or_equal.rb +0 -20
- data/lib/dry/rules/included.rb +0 -20
- data/lib/dry/rules/length_between.rb +0 -20
- data/lib/dry/rules/length_equal.rb +0 -20
- data/lib/dry/rules/less_than.rb +0 -20
- data/lib/dry/rules/less_than_or_equal.rb +0 -20
- data/lib/dry/rules/max_length.rb +0 -20
- data/lib/dry/rules/min_length.rb +0 -20
- data/lib/dry/rules/not_equal.rb +0 -20
- data/lib/dry/rules/or.rb +0 -15
- data/lib/dry/rules/present.rb +0 -23
- data/lib/dry/rules/then.rb +0 -15
- data/lib/dry/rules_factory.rb +0 -134
- data/lib/dry/schema.rb +0 -148
data/lib/dry/rule.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require_relative 'errors'
|
2
|
-
require_relative 'rules/and'
|
3
|
-
require_relative 'rules/then'
|
4
|
-
require_relative 'rules/or'
|
5
|
-
require_relative 'rules/collection'
|
6
|
-
|
7
|
-
module Dry
|
8
|
-
class Rule
|
9
|
-
|
10
|
-
attr_reader :value, :errors, :args
|
11
|
-
|
12
|
-
def initialize(value, errors = Dry::Errors.new, **args)
|
13
|
-
@value = value
|
14
|
-
@errors = errors
|
15
|
-
@args = args.symbolize_keys
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
def name
|
20
|
-
args[:name]
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
def add_error
|
25
|
-
errors.add(key, messages[name.to_s] || 'invalid')
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
def clone
|
30
|
-
self.class.new(value, errors.clone, args)
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def and(right)
|
35
|
-
Dry::Rules::And.new(self, errors, args.merge(right: right))
|
36
|
-
end
|
37
|
-
alias :& :and
|
38
|
-
|
39
|
-
|
40
|
-
def then(right)
|
41
|
-
Dry::Rules::Then.new(self, errors, args.merge(right: right))
|
42
|
-
end
|
43
|
-
alias :> :then
|
44
|
-
|
45
|
-
|
46
|
-
def or(right)
|
47
|
-
Dry::Rules::Or.new(self, errors, args.merge(right: right))
|
48
|
-
end
|
49
|
-
alias :| :or
|
50
|
-
|
51
|
-
|
52
|
-
def +(right)
|
53
|
-
Dry::Rules::Collection.new(self, errors, args.merge(right: right))
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def valid?
|
58
|
-
raise NotImplementedError
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
|
65
|
-
def messages
|
66
|
-
@messages ||= (args[:messages] || {}).deep_stringify_keys
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
def key
|
71
|
-
@key ||= args[:key] || (raise 'Missing required param "key"')
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
data/lib/dry/rules/and.rb
DELETED
data/lib/dry/rules/between.rb
DELETED
data/lib/dry/rules/binary.rb
DELETED
data/lib/dry/rules/collection.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative 'binary'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Rules
|
5
|
-
class Collection < Dry::Rules::Binary
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
is_valid = true
|
9
|
-
[left, right].each do |rule|
|
10
|
-
res = rule.valid?
|
11
|
-
is_valid = res unless res
|
12
|
-
end
|
13
|
-
is_valid
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/dry/rules/composite.rb
DELETED
data/lib/dry/rules/equal.rb
DELETED
data/lib/dry/rules/format.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'binary'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Rules
|
5
|
-
class Format < Dry::Rules::Binary
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
return true if left.to_s.match(right).present?
|
9
|
-
add_error
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
def name
|
15
|
-
'format'
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/dry/rules/included.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'binary'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Rules
|
5
|
-
class LengthBetween < Dry::Rules::Binary
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
return true if right.include? left.size
|
9
|
-
add_error
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
def name
|
15
|
-
'length_between'
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'binary'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Rules
|
5
|
-
class LengthEqual < Dry::Rules::Binary
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
return true if left.size == right
|
9
|
-
add_error
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
def name
|
15
|
-
'length_equal'
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/dry/rules/less_than.rb
DELETED
data/lib/dry/rules/max_length.rb
DELETED
data/lib/dry/rules/min_length.rb
DELETED
data/lib/dry/rules/not_equal.rb
DELETED
data/lib/dry/rules/or.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative 'composite'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Rules
|
5
|
-
class Or < Dry::Rules::Composite
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
return true if lt.valid? || rt.valid?
|
9
|
-
[lt.errors, rt.errors].each { |e| errors.merge!(e) if e.any? }
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/dry/rules/present.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative '../rule'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Rules
|
5
|
-
class Present < Dry::Rule
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
return true if value.present?
|
9
|
-
add_error
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
|
17
|
-
def name
|
18
|
-
'present'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/dry/rules/then.rb
DELETED
data/lib/dry/rules_factory.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
require_relative 'errors'
|
2
|
-
require_relative 'rules/present'
|
3
|
-
require_relative 'rules/equal'
|
4
|
-
require_relative 'rules/not_equal'
|
5
|
-
require_relative 'rules/greater_than'
|
6
|
-
require_relative 'rules/greater_than_or_equal'
|
7
|
-
require_relative 'rules/less_than'
|
8
|
-
require_relative 'rules/less_than_or_equal'
|
9
|
-
require_relative 'rules/included'
|
10
|
-
require_relative 'rules/length_equal'
|
11
|
-
require_relative 'rules/min_length'
|
12
|
-
require_relative 'rules/max_length'
|
13
|
-
require_relative 'rules/between'
|
14
|
-
require_relative 'rules/length_between'
|
15
|
-
require_relative 'rules/format'
|
16
|
-
|
17
|
-
module Dry
|
18
|
-
class RulesFactory
|
19
|
-
|
20
|
-
attr_reader :value, :errors, :args
|
21
|
-
|
22
|
-
def initialize(value, errors = Dry::Errors.new, **args)
|
23
|
-
@value = value
|
24
|
-
@errors = errors
|
25
|
-
@args = args.symbolize_keys
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
def present?
|
30
|
-
Dry::Rules::Present.new(value, errors, args)
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def equal?(right)
|
35
|
-
Dry::Rules::Equal.new(value, errors, build_args(right))
|
36
|
-
end
|
37
|
-
alias :eq? :equal?
|
38
|
-
|
39
|
-
|
40
|
-
def not_equal?(right)
|
41
|
-
Dry::Rules::NotEqual.new(value, errors, build_args(right))
|
42
|
-
end
|
43
|
-
alias :not_eq? :not_equal?
|
44
|
-
|
45
|
-
|
46
|
-
def greater_than?(right)
|
47
|
-
Dry::Rules::GreaterThan.new(value, errors, build_args(right))
|
48
|
-
end
|
49
|
-
alias :gt? :greater_than?
|
50
|
-
|
51
|
-
|
52
|
-
def greater_than_or_equal?(right)
|
53
|
-
Dry::Rules::GreaterThanOrEqual.new(value, errors, build_args(right))
|
54
|
-
end
|
55
|
-
alias :gt_eq? :greater_than_or_equal?
|
56
|
-
|
57
|
-
|
58
|
-
def less_than?(right)
|
59
|
-
Dry::Rules::LessThan.new(value, errors, build_args(right))
|
60
|
-
end
|
61
|
-
alias :lt? :less_than?
|
62
|
-
|
63
|
-
|
64
|
-
def less_than_or_equal?(right)
|
65
|
-
Dry::Rules::LessThanOrEqual.new(value, errors, build_args(right))
|
66
|
-
end
|
67
|
-
alias :lt_eq? :less_than_or_equal?
|
68
|
-
|
69
|
-
|
70
|
-
def included?(right)
|
71
|
-
Dry::Rules::Included.new(value, errors, build_args(right))
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
def length_equal?(right)
|
76
|
-
Dry::Rules::LengthEqual.new(value, errors, build_args(right))
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
def min_length?(right)
|
81
|
-
Dry::Rules::MinLength.new(value, errors, build_args(right))
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
def max_length?(right)
|
86
|
-
Dry::Rules::MaxLength.new(value, errors, build_args(right))
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
def between?(right)
|
91
|
-
Dry::Rules::Between.new(value, errors, build_args(right))
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
def length_between?(right)
|
96
|
-
Dry::Rules::LengthBetween.new(value, errors, build_args(right))
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
def format?(right)
|
101
|
-
Dry::Rules::Format.new(value, errors, build_args(right))
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
def each(&block)
|
106
|
-
return if value.blank?
|
107
|
-
value.inject(nil) do |rule, e|
|
108
|
-
_rule = self.class.new(e, errors, args).instance_exec(&block)
|
109
|
-
rule = rule ? rule & _rule : _rule
|
110
|
-
rule
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
def each_value(&block)
|
116
|
-
return if value.blank?
|
117
|
-
value.inject(nil) do |rule, (k, v)|
|
118
|
-
_rule = self.class.new(v, errors, args).instance_exec(&block)
|
119
|
-
rule = rule ? rule & _rule : _rule
|
120
|
-
rule
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
|
128
|
-
def build_args(right)
|
129
|
-
rt = right.is_a?(self.class) ? right.value : right
|
130
|
-
args.merge(right: rt)
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|