barsoom_utils 0.1.1.25 → 0.1.1.28
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f86d1635cdbe751df9c279346441343ab4aab8d8d3227e5105446b7844b3a30c
|
4
|
+
data.tar.gz: fd9070dfc84003acb37915d1373e60d8bdbe4a83b39a7ef89fc0338b78ddb527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a99dadb402b3cc8270fff828a8a9546f9275b604bf94f94f348e6c1b461b8209f5d94a842a6ba6ac6309600d9b04389c8825dc61bc6b5f9ee4d05d94e9acaaea
|
7
|
+
data.tar.gz: 43e85540441149b0a6b93cab5ad09e9c1fcf62f83f5408b8f12f200d72ac9b7bb5b80fd6328be5e1b26ef5c5c63707fa3041dd8eba400b8215b30caaba8002b1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.1.
|
1
|
+
0.1.1.28
|
data/shared_rubocop.yml
CHANGED
@@ -30,6 +30,11 @@ Security:
|
|
30
30
|
Layout/DotPosition:
|
31
31
|
EnforcedStyle: leading
|
32
32
|
|
33
|
+
# Allow: def foo(...) = bar(...)
|
34
|
+
# Disallow: def foo(*args, &) = bar(*args, &)
|
35
|
+
Style/ArgumentsForwarding:
|
36
|
+
Enabled: true
|
37
|
+
|
33
38
|
# Allow: "foo"
|
34
39
|
# Disallow: 'foo'
|
35
40
|
Style/StringLiterals:
|
@@ -265,3 +270,7 @@ Gemspec/OrderedDependencies:
|
|
265
270
|
# https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecrequiremfa
|
266
271
|
Gemspec/RequireMFA:
|
267
272
|
Enabled: true
|
273
|
+
|
274
|
+
# https://docs.rubocop.org/rubocop/cops_naming.html#namingblockforwarding
|
275
|
+
Naming/BlockForwarding:
|
276
|
+
Enabled: true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barsoom_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Skogberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -30,14 +30,12 @@ files:
|
|
30
30
|
- lib/barsoom_utils.rb
|
31
31
|
- lib/barsoom_utils/exception_notifier.rb
|
32
32
|
- lib/barsoom_utils/feature_toggle.rb
|
33
|
-
- lib/barsoom_utils/parse_space_separated_token_values.rb
|
34
33
|
- lib/barsoom_utils/ping_health_check.rb
|
35
34
|
- lib/barsoom_utils/spec/debug_helpers.rb
|
36
35
|
- lib/barsoom_utils/version.rb
|
37
36
|
- script/test
|
38
37
|
- shared_rubocop.yml
|
39
38
|
- shared_rubocop_rails.yml
|
40
|
-
- spec/barsoom_utils/parse_space_separated_token_values_spec.rb
|
41
39
|
- spec/exception_notifier_spec.rb
|
42
40
|
- spec/feature_toggle_spec.rb
|
43
41
|
- spec/ping_health_check_spec.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "attr_extras"
|
2
|
-
|
3
|
-
module BarsoomUtils
|
4
|
-
class ParseSpaceSeparatedTokenValues
|
5
|
-
attr_private :minimum_key_size, :value, :token_name
|
6
|
-
|
7
|
-
# @param token_name [String] name of ENV key to look up
|
8
|
-
# @param minimum_key_size [Integer] required size of each element
|
9
|
-
# @param data [Hash] defaults to ENV
|
10
|
-
def initialize(token_name, minimum_key_size:, data:)
|
11
|
-
@value = data[token_name].to_s
|
12
|
-
@token_name = token_name
|
13
|
-
@minimum_key_size = minimum_key_size
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.call(token_name, minimum_key_size:, data: ENV)
|
17
|
-
new(token_name, minimum_key_size: minimum_key_size, data: data).call
|
18
|
-
end
|
19
|
-
|
20
|
-
def call
|
21
|
-
keys = value.split
|
22
|
-
|
23
|
-
raise "Missing #{token_name}. Quitting." if keys.empty?
|
24
|
-
|
25
|
-
raise "Invalid #{token_name}: a too-short element found. Did a key contain a space? Quitting!" if keys.any? { |api_key| api_key.size < minimum_key_size }
|
26
|
-
|
27
|
-
keys.freeze
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "barsoom_utils/parse_space_separated_token_values"
|
2
|
-
|
3
|
-
RSpec.describe BarsoomUtils::ParseSpaceSeparatedTokenValues do
|
4
|
-
let(:minimum_key_size) { 4 }
|
5
|
-
let(:long_enough_api_key) { "xyza" }
|
6
|
-
let(:token_name) { "API_TOKENS" }
|
7
|
-
|
8
|
-
subject(:parsed_value) {
|
9
|
-
described_class.call(token_name, minimum_key_size: minimum_key_size, data: { "API_TOKENS" => api_tokens_value })
|
10
|
-
}
|
11
|
-
|
12
|
-
context "with a valid set of tokens" do
|
13
|
-
let(:api_tokens_value) { "#{long_enough_api_key} b#{long_enough_api_key}" }
|
14
|
-
|
15
|
-
it "returns a frozen array" do
|
16
|
-
expect(parsed_value).to(
|
17
|
-
be_an(Array)
|
18
|
-
.and(have_attributes(size: 2))
|
19
|
-
.and(be_frozen)
|
20
|
-
)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "with one too-short token" do
|
25
|
-
let(:api_tokens_value) { "x #{long_enough_api_key}" }
|
26
|
-
|
27
|
-
it "raises an error" do
|
28
|
-
expect { parsed_value }.to raise_error(/Invalid API_TOKENS/)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with a blank value" do
|
33
|
-
let(:api_tokens_value) { " " }
|
34
|
-
|
35
|
-
it "raises an error" do
|
36
|
-
expect { parsed_value }.to raise_error(/Missing API_TOKENS/)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|