salestation 4.4.2 → 4.5.0
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 +22 -0
- data/README.md +1 -1
- data/lib/salestation/web/extractors.rb +74 -0
- data/salestation.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50948c2e3f36bfe0779cb2458cf42cc6d7dd8e9b38b77a00e7bf0e975f7f2140
|
4
|
+
data.tar.gz: 490a6207820bdc32b745e1d3d6c9cbbdb33e547783f557aa14ff89791b351173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d99f0b753951b98f0905d2084d432071d33d2a2370ae07726225db8d90f8dc8d5bdb6acc453ff2654a2bc81dc23ba27f125202eb1bbc8adceb09faca73638755
|
7
|
+
data.tar.gz: 2d41a2673bc8a59fb78e97ecff19b4c58ed11c01e66111a538ee3e8c1d5c18b9ad504437368a5a5538e7cfb879efe94b6ef19678c8977348c5dbecc62b8b9489
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
with:
|
14
|
+
fetch-depth: 2
|
15
|
+
|
16
|
+
|
17
|
+
- name: Release Gem
|
18
|
+
uses: discourse/publish-rubygems-action@b55d7b91b55e61752dc6cbc2972f8e16fe6c1a02
|
19
|
+
env:
|
20
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
21
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
22
|
+
RELEASE_COMMAND: rake release
|
data/README.md
CHANGED
@@ -210,7 +210,7 @@ See lib/salestation/rspec.rb for more examples.
|
|
210
210
|
|
211
211
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
212
212
|
|
213
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
213
|
+
To install this gem onto your local machine, run `bundle exec rake install`. A new version is created when a change is merged into the master branch that changes the version number in `salestation.gemspec`. A Github Action will create a tag for the version and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
214
214
|
|
215
215
|
## Contributing
|
216
216
|
|
@@ -21,6 +21,10 @@ module Salestation
|
|
21
21
|
def coerce(rules)
|
22
22
|
InputCoercer.new(self, rules)
|
23
23
|
end
|
24
|
+
|
25
|
+
def rename(rules)
|
26
|
+
InputRenamer.new(self, rules)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
class CombinedInputExtractor
|
@@ -88,6 +92,76 @@ module Salestation
|
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
95
|
+
# Handles renaming input keys
|
96
|
+
#
|
97
|
+
# When renaming we want to ensure that the new key provided for the rename does not already
|
98
|
+
# exist in the input. When it does and it has a not nil value, then rename will not happen,
|
99
|
+
# unless `override: true` is also applied. When the new key exists with nil value,
|
100
|
+
# rename will happen.
|
101
|
+
# By default override is set to false: when input already has value set for the new key,
|
102
|
+
# the old key will be discarded instead of overwriting the value.
|
103
|
+
# For deprecating (renaming for deprecation purposes), one should extract both new and old key
|
104
|
+
# from the input before calling the rename function, to get expected result, as only then the
|
105
|
+
# values can be compared in rename.
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# original_input = {
|
109
|
+
# x: 'a',
|
110
|
+
# y: 'b'
|
111
|
+
# }
|
112
|
+
#
|
113
|
+
# extractor = BodyParamExtractor[:x, :y]
|
114
|
+
# .rename(x: :z)
|
115
|
+
# input = {
|
116
|
+
# z: 'a',
|
117
|
+
# y: 'b'
|
118
|
+
# }
|
119
|
+
#
|
120
|
+
# extractor = BodyParamExtractor[:x, :y]
|
121
|
+
# .rename(x: :y)
|
122
|
+
# input = {
|
123
|
+
# y: 'b'
|
124
|
+
# }
|
125
|
+
# extractor = BodyParamExtractor[:x, :y]
|
126
|
+
# .rename(x: {new_key: :y, override: true})
|
127
|
+
# input = {
|
128
|
+
# y: 'a'
|
129
|
+
# }
|
130
|
+
class InputRenamer
|
131
|
+
def initialize(extractor, rules)
|
132
|
+
@extractor = extractor
|
133
|
+
@rules = map_rules(rules)
|
134
|
+
end
|
135
|
+
|
136
|
+
def call(rack_request)
|
137
|
+
@extractor
|
138
|
+
.call(rack_request)
|
139
|
+
.map(&method(:rename))
|
140
|
+
end
|
141
|
+
|
142
|
+
def rename(input)
|
143
|
+
@rules.each do |old_key, rule|
|
144
|
+
new_key = rule[:new_key]
|
145
|
+
override = rule[:override]
|
146
|
+
|
147
|
+
if input[new_key].nil? || override
|
148
|
+
input[new_key] = input[old_key]
|
149
|
+
end
|
150
|
+
|
151
|
+
input.delete(old_key)
|
152
|
+
end
|
153
|
+
Deterministic::Result::Success(input)
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def map_rules(rules)
|
159
|
+
rules.map do |field, rule|
|
160
|
+
[field, rule.is_a?(Hash) ? rule : {new_key: rule, override: false}]
|
161
|
+
end.to_h
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
91
165
|
class HeadersExtractor
|
92
166
|
include Deterministic
|
93
167
|
|
data/salestation.gemspec
CHANGED
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: 4.
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,6 +157,7 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
+
- ".github/workflows/publish.yml"
|
160
161
|
- ".github/workflows/ruby.yml"
|
161
162
|
- ".gitignore"
|
162
163
|
- ".rspec"
|
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
204
|
- !ruby/object:Gem::Version
|
204
205
|
version: '0'
|
205
206
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
207
|
+
rubygems_version: 3.0.6
|
207
208
|
signing_key:
|
208
209
|
specification_version: 4
|
209
210
|
summary: ''
|