umbrellio-utils 0.7.3 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +0 -3
- data/Gemfile +0 -1
- data/Gemfile.lock +6 -14
- data/lib/umbrellio_utils/request_wrapper.rb +4 -3
- data/lib/umbrellio_utils/rounding.rb +4 -2
- data/lib/umbrellio_utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c059f42f8e519125db1cf5fe6e33c6aab0d58dd4a6089e95029b6c1df612cd7
|
4
|
+
data.tar.gz: bc8c7022274fe2e591c3124cf848ea1ed904b130e6158805bcd44b684589723f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d84410033f5c3dc353f3e65736185663a798c8d1dcd0dcd5430365f3396117e5e4766d1e1cde91bfa782f798d1f14ee3e7dc07f4e0d93eaf676a9221353c05
|
7
|
+
data.tar.gz: 2266a02f0ac7f6c4525187d3aaa2162e201582e2eff1e93cf1ea2c3862e0475e2e47ff79e1891840b2efaa8f77f31c979b571deab8e9634f34d544c416da6f2f
|
data/.github/workflows/test.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
umbrellio-utils (0.7.
|
4
|
+
umbrellio-utils (0.7.5)
|
5
5
|
memery (~> 1)
|
6
6
|
|
7
7
|
GEM
|
@@ -79,9 +79,6 @@ GEM
|
|
79
79
|
ast (2.4.2)
|
80
80
|
bigdecimal (3.1.4)
|
81
81
|
builder (3.2.4)
|
82
|
-
bundler-audit (0.9.1)
|
83
|
-
bundler (>= 1.2.0, < 3)
|
84
|
-
thor (~> 1.0)
|
85
82
|
bunny (2.22.0)
|
86
83
|
amq-protocol (~> 2.3, >= 2.3.1)
|
87
84
|
sorted_set (~> 1, >= 1.0.2)
|
@@ -135,7 +132,6 @@ GEM
|
|
135
132
|
ruby2_keywords (~> 0.0.2)
|
136
133
|
method_source (1.0.0)
|
137
134
|
mini_mime (1.1.5)
|
138
|
-
mini_portile2 (2.8.4)
|
139
135
|
minitest (5.20.0)
|
140
136
|
net-imap (0.3.7)
|
141
137
|
date
|
@@ -147,14 +143,11 @@ GEM
|
|
147
143
|
net-smtp (0.3.3)
|
148
144
|
net-protocol
|
149
145
|
nio4r (2.5.9)
|
150
|
-
nokogiri (1.
|
151
|
-
mini_portile2 (~> 2.8.2)
|
152
|
-
racc (~> 1.4)
|
153
|
-
nokogiri (1.15.4-arm64-darwin)
|
146
|
+
nokogiri (1.16.2-arm64-darwin)
|
154
147
|
racc (~> 1.4)
|
155
|
-
nokogiri (1.
|
148
|
+
nokogiri (1.16.2-x86_64-darwin)
|
156
149
|
racc (~> 1.4)
|
157
|
-
nokogiri (1.
|
150
|
+
nokogiri (1.16.2-x86_64-linux)
|
158
151
|
racc (~> 1.4)
|
159
152
|
nori (2.6.0)
|
160
153
|
parallel (1.23.0)
|
@@ -172,7 +165,7 @@ GEM
|
|
172
165
|
rails (>= 5.2)
|
173
166
|
sneakers (~> 2.0)
|
174
167
|
tainbox
|
175
|
-
racc (1.7.
|
168
|
+
racc (1.7.3)
|
176
169
|
rack (2.2.8)
|
177
170
|
rack-test (2.1.0)
|
178
171
|
rack (>= 1.3)
|
@@ -318,14 +311,13 @@ GEM
|
|
318
311
|
PLATFORMS
|
319
312
|
arm64-darwin-20
|
320
313
|
arm64-darwin-21
|
321
|
-
|
314
|
+
arm64-darwin-23
|
322
315
|
x86_64-darwin-20
|
323
316
|
x86_64-linux
|
324
317
|
|
325
318
|
DEPENDENCIES
|
326
319
|
activesupport
|
327
320
|
bundler
|
328
|
-
bundler-audit
|
329
321
|
ci-helper
|
330
322
|
http
|
331
323
|
nokogiri
|
@@ -4,8 +4,9 @@ module UmbrellioUtils
|
|
4
4
|
class RequestWrapper
|
5
5
|
include Memery
|
6
6
|
|
7
|
-
def initialize(request)
|
7
|
+
def initialize(request, remove_xml_attributes: true)
|
8
8
|
self.request = request
|
9
|
+
self.remove_xml_attributes = remove_xml_attributes
|
9
10
|
end
|
10
11
|
|
11
12
|
memoize def params
|
@@ -50,14 +51,14 @@ module UmbrellioUtils
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
53
|
-
attr_accessor :request
|
54
|
+
attr_accessor :request, :remove_xml_attributes
|
54
55
|
|
55
56
|
def parse_params
|
56
57
|
case request.media_type
|
57
58
|
when "application/json", /\+json\z/
|
58
59
|
Parsing.safely_parse_json(body)
|
59
60
|
when "application/xml"
|
60
|
-
Parsing.parse_xml(body)
|
61
|
+
Parsing.parse_xml(body, remove_attributes: remove_xml_attributes)
|
61
62
|
else
|
62
63
|
request.get? ? request.GET : request.POST
|
63
64
|
end
|
@@ -4,6 +4,8 @@ module UmbrellioUtils
|
|
4
4
|
module Rounding
|
5
5
|
extend self
|
6
6
|
|
7
|
+
SUPER_ROUND_DEFAULT_TARGETS = [1.0, 1.5, 2.5, 5.0, 10.0].freeze
|
8
|
+
|
7
9
|
def fancy_round(number, rounding_method: :round, ugliness_level: 1)
|
8
10
|
return 0 unless number.positive?
|
9
11
|
log = Math.log(number, 10).floor
|
@@ -11,7 +13,7 @@ module UmbrellioUtils
|
|
11
13
|
(number * coef).public_send(rounding_method, -log) / coef.to_f
|
12
14
|
end
|
13
15
|
|
14
|
-
def super_round(number, rounding_method: :round)
|
16
|
+
def super_round(number, rounding_method: :round, targets: SUPER_ROUND_DEFAULT_TARGETS)
|
15
17
|
return 0 unless number.positive?
|
16
18
|
|
17
19
|
coef = 10**Math.log(number, 10).floor
|
@@ -19,7 +21,7 @@ module UmbrellioUtils
|
|
19
21
|
|
20
22
|
best_diff = best_target = nil
|
21
23
|
|
22
|
-
|
24
|
+
targets.each do |target|
|
23
25
|
diff = target - num
|
24
26
|
|
25
27
|
next if rounding_method == :ceil && diff.negative?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umbrellio-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JustAnotherDude
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: memery
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.5.6
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: A set of utilities that speed up development
|