salestation 5.3.1 → 5.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +3 -2
- data/.github/workflows/ruby.yml +1 -1
- data/.yardopts +1 -0
- data/Rakefile +10 -3
- data/lib/salestation/rspec/glia_input_validation_error_matcher.rb +55 -5
- data/lib/salestation/web/extractors.rb +19 -20
- data/salestation.gemspec +3 -2
- metadata +23 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f3204f1692dd5da39dba967c0bbad7e233cadbca2ad0290a079e2b109e9fd33
|
4
|
+
data.tar.gz: cf5aea80221f27504428b6f153dfd791e1e677c1816ca9fcdd602c863077b4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ca53279d7299ab5a29d3fe88bad408cab41ac2475acb9b5962bafc7b1623d6ac218372de87df0a394cc491c52507464eb13af544cb248b1400e03bb95d8f1b
|
7
|
+
data.tar.gz: 93d0075650b3e79f9b954e03d3846aacd82a6b330cb5e63fe6283c5d60d4a83217f5c293a858082359373d6c8db1faf243eeb372da0a2fe171c59b72348d20dd
|
@@ -15,8 +15,9 @@ jobs:
|
|
15
15
|
|
16
16
|
|
17
17
|
- name: Release Gem
|
18
|
-
uses: discourse/publish-rubygems-action@
|
18
|
+
uses: discourse/publish-rubygems-action@4bd305c65315cb691bad1e8de97a87aaf29a0a85
|
19
19
|
env:
|
20
|
-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
21
20
|
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
22
21
|
RELEASE_COMMAND: rake release
|
22
|
+
GIT_EMAIL: support@salemove.com
|
23
|
+
GIT_NAME: sm-deployer
|
data/.github/workflows/ruby.yml
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--plugin yard-doctest
|
data/Rakefile
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'yard/doctest/rake'
|
3
6
|
|
4
7
|
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
YARD::Doctest::RakeTask.new
|
5
9
|
|
6
|
-
task :default
|
10
|
+
task :default do
|
11
|
+
Rake::Task['spec'].invoke
|
12
|
+
Rake::Task['yard:doctest'].invoke
|
13
|
+
end
|
@@ -13,6 +13,7 @@ module Salestation
|
|
13
13
|
@fields = []
|
14
14
|
@field_error_types = {}
|
15
15
|
@field_error_messages = {}
|
16
|
+
@expect_exact_match = false
|
16
17
|
end
|
17
18
|
|
18
19
|
def on(*nested_fields)
|
@@ -20,6 +21,11 @@ module Salestation
|
|
20
21
|
self
|
21
22
|
end
|
22
23
|
|
24
|
+
def exactly
|
25
|
+
@expect_exact_match = true
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
23
29
|
def with_type(*types)
|
24
30
|
@field_error_types[field_to_key(@fields.last)] = types
|
25
31
|
self
|
@@ -31,15 +37,32 @@ module Salestation
|
|
31
37
|
end
|
32
38
|
|
33
39
|
def matches?(actual)
|
34
|
-
@fields
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
check_exact_match(actual, self.class.path_list_to_trie(@fields)) &&
|
41
|
+
@fields.all? do |field|
|
42
|
+
check_field_exists(actual, *field) &&
|
43
|
+
check_field_error_types(field, actual) &&
|
44
|
+
check_field_error_messages(field, actual)
|
45
|
+
end
|
39
46
|
end
|
40
47
|
|
41
48
|
private
|
42
49
|
|
50
|
+
def check_exact_match(actual, field_trie)
|
51
|
+
return true unless @expect_exact_match
|
52
|
+
|
53
|
+
actual[:error_details].keys.all? do |key|
|
54
|
+
field_trie.any? do |field, nested_field_trie|
|
55
|
+
if nested_field_trie.empty?
|
56
|
+
field == key
|
57
|
+
else
|
58
|
+
actual[:error_details][field].all? do |nested_actual|
|
59
|
+
check_exact_match(nested_actual, nested_field_trie)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
43
66
|
def check_field_exists(actual, field, *nested_fields)
|
44
67
|
actual[:error_details].key?(field) &&
|
45
68
|
(
|
@@ -80,6 +103,33 @@ module Salestation
|
|
80
103
|
def field_to_key(fields)
|
81
104
|
fields.join('->').to_sym
|
82
105
|
end
|
106
|
+
|
107
|
+
class << self
|
108
|
+
# @example
|
109
|
+
# path_list_to_trie([[:a, :b, :c], [:a, :b, :d], [:a, :e]])
|
110
|
+
# #=> {a: {b: {c: {}, d: {}}, e: {}}}
|
111
|
+
def path_list_to_trie(paths)
|
112
|
+
paths.reduce({}) do |acc, path|
|
113
|
+
deep_merge(acc, path_to_trie(*path))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
# @example
|
120
|
+
# path_to_trie(*[:a, :b, :c])
|
121
|
+
# #=> {a: {b: {c: {}}}}
|
122
|
+
def path_to_trie(element, *rest)
|
123
|
+
{element.to_sym => rest.empty? ? {} : path_to_trie(*rest)}
|
124
|
+
end
|
125
|
+
|
126
|
+
# @example
|
127
|
+
# deep_merge({a: {b: {c: {}}}}, {a: {b: {d: {}}, e: {}}})
|
128
|
+
# #=> {a: {b: {c: {}, d: {}}, e: {}}}
|
129
|
+
def deep_merge(a, b)
|
130
|
+
a.merge(b) { |_key, nested_a, nested_b| deep_merge(nested_a, nested_b) }
|
131
|
+
end
|
132
|
+
end
|
83
133
|
end
|
84
134
|
end
|
85
135
|
end
|
@@ -61,14 +61,15 @@ module Salestation
|
|
61
61
|
# Handles coercing input values
|
62
62
|
#
|
63
63
|
# @example
|
64
|
-
# extractor = BodyParamExtractor[:x, :y]
|
64
|
+
# extractor = Salestation::Web::Extractors::BodyParamExtractor[:x, :y]
|
65
65
|
# .coerce(x: ->(value) { "x_#{value}"})
|
66
66
|
# input = {
|
67
67
|
# 'x' => 'a',
|
68
68
|
# 'y' => 'b',
|
69
69
|
# }
|
70
70
|
# # rack_request is Rack::Request with 'rack.request.form_hash' set to input
|
71
|
-
# extractor.call(rack_request).value
|
71
|
+
# extractor.call(rack_request(input)).value
|
72
|
+
# #=> {x: 'x_a', y: 'b'}
|
72
73
|
class InputCoercer
|
73
74
|
def initialize(extractor, rules)
|
74
75
|
@extractor = extractor
|
@@ -106,28 +107,25 @@ module Salestation
|
|
106
107
|
# values can be compared in rename.
|
107
108
|
#
|
108
109
|
# @example
|
109
|
-
#
|
110
|
-
# x
|
111
|
-
# y
|
110
|
+
# input = {
|
111
|
+
# 'x' => 'a',
|
112
|
+
# 'y' => 'b'
|
112
113
|
# }
|
113
114
|
#
|
114
|
-
# extractor = BodyParamExtractor[:x, :y]
|
115
|
+
# extractor = Salestation::Web::Extractors::BodyParamExtractor[:x, :y]
|
115
116
|
# .rename(x: :z)
|
116
|
-
# input
|
117
|
-
#
|
118
|
-
# y: 'b'
|
119
|
-
# }
|
117
|
+
# extractor.call(rack_request(input)).value
|
118
|
+
# #=> {z: 'a', y: 'b'}
|
120
119
|
#
|
121
|
-
# extractor = BodyParamExtractor[:x, :y]
|
120
|
+
# extractor = Salestation::Web::Extractors::BodyParamExtractor[:x, :y]
|
122
121
|
# .rename(x: :y)
|
123
|
-
# input
|
124
|
-
#
|
125
|
-
#
|
126
|
-
# extractor = BodyParamExtractor[:x, :y]
|
122
|
+
# extractor.call(rack_request(input)).value
|
123
|
+
# #=> {y: 'b'}
|
124
|
+
#
|
125
|
+
# extractor = Salestation::Web::Extractors::BodyParamExtractor[:x, :y]
|
127
126
|
# .rename(x: {new_key: :y, override: true})
|
128
|
-
# input
|
129
|
-
#
|
130
|
-
# }
|
127
|
+
# extractor.call(rack_request(input)).value
|
128
|
+
# #=> {y: 'a'}
|
131
129
|
class InputRenamer
|
132
130
|
def initialize(extractor, rules)
|
133
131
|
@extractor = extractor
|
@@ -217,7 +215,7 @@ module Salestation
|
|
217
215
|
# Extracts and symbolizes params from request body
|
218
216
|
#
|
219
217
|
# @example
|
220
|
-
# extractor = BodyParamExtractor[:x, :y, {foo: [:bar, :baz]}, :aaa]
|
218
|
+
# extractor = Salestation::Web::Extractors::BodyParamExtractor[:x, :y, {foo: [:bar, :baz]}, :aaa]
|
221
219
|
# input = {
|
222
220
|
# 'x' => '1',
|
223
221
|
# 'y' => '2',
|
@@ -232,7 +230,8 @@ module Salestation
|
|
232
230
|
# ]
|
233
231
|
# }
|
234
232
|
# # rack_request is Rack::Request with 'rack.request.form_hash' set to input
|
235
|
-
# extractor.call(rack_request).value
|
233
|
+
# extractor.call(rack_request(input)).value
|
234
|
+
# #=> {x: '1', y: '2', foo: {bar: 'qq'}, aaa: [{bb: 'cc'}]}
|
236
235
|
#
|
237
236
|
class BodyParamExtractor
|
238
237
|
def self.[](*filters)
|
data/salestation.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "salestation"
|
7
|
-
spec.version = "5.3.
|
7
|
+
spec.version = "5.3.2"
|
8
8
|
spec.authors = ["Glia TechMovers"]
|
9
9
|
spec.email = ["techmovers@glia.com"]
|
10
10
|
|
@@ -22,9 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 2.0"
|
23
23
|
spec.add_development_dependency "rake", "~> 13.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
-
spec.add_development_dependency "pry", "~> 0.
|
25
|
+
spec.add_development_dependency "pry", "~> 0.14.2"
|
26
26
|
spec.add_development_dependency "glia-errors", "~> 0.11.4"
|
27
27
|
spec.add_development_dependency "dry-validation", "~> 1.7"
|
28
|
+
spec.add_development_dependency "yard-doctest", "~> 0.1.17"
|
28
29
|
|
29
30
|
spec.add_dependency 'deterministic'
|
30
31
|
spec.add_dependency 'dry-struct'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salestation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.3.
|
4
|
+
version: 5.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.14.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.14.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: glia-errors
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard-doctest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.1.17
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.17
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: deterministic
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +189,7 @@ files:
|
|
175
189
|
- ".github/workflows/ruby.yml"
|
176
190
|
- ".gitignore"
|
177
191
|
- ".rspec"
|
192
|
+
- ".yardopts"
|
178
193
|
- Gemfile
|
179
194
|
- LICENSE.txt
|
180
195
|
- README.md
|
@@ -204,7 +219,7 @@ homepage: ''
|
|
204
219
|
licenses:
|
205
220
|
- MIT
|
206
221
|
metadata: {}
|
207
|
-
post_install_message:
|
222
|
+
post_install_message:
|
208
223
|
rdoc_options: []
|
209
224
|
require_paths:
|
210
225
|
- lib
|
@@ -219,8 +234,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
234
|
- !ruby/object:Gem::Version
|
220
235
|
version: '0'
|
221
236
|
requirements: []
|
222
|
-
rubygems_version: 3.
|
223
|
-
signing_key:
|
237
|
+
rubygems_version: 3.4.10
|
238
|
+
signing_key:
|
224
239
|
specification_version: 4
|
225
240
|
summary: ''
|
226
241
|
test_files: []
|