barsoom_utils 0.1.1.21 → 0.1.1.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b4e3e88b7f43882526bdf70974e6f1f55b5b9420f5429c259e5b9c9c57182f8
4
- data.tar.gz: 8099aed4d0efd543fbc413cde18c1d71fdffdce9fa1e2f5bfb6323d42aad7ab3
3
+ metadata.gz: ac777967c42be2ec828febf467411c658f65a87502d643dec04264dbca7c537c
4
+ data.tar.gz: e08ceedc6255c027f2aac6a674d965a141f2bd8aec8efa0fd205e90e26d2cb8d
5
5
  SHA512:
6
- metadata.gz: 37e5b2773010797aab42f939de6613474944b027ac30a71388a7bf386e8aed0e373df459af64910b3ec4fc264817316df7add6ca470888d1c83245762c087406
7
- data.tar.gz: 2d46f4fbb2dd9d86719eb96b425e10910ce6f0f0aea65eb6761428794d9833d7dbcd99166b84017815bf4940c8f19dd361c74eb8038d5f463ebd50080498933c
6
+ metadata.gz: bf015bf6c8e15abf9c8549514be6e21f3911e6b7e5ada16cc065dd3518f19bc3e7e5acafa9d300f1fcb59a46a452bdb89c89d9a2f369eb8b5bd133c0394bd652
7
+ data.tar.gz: 7178c57d7098897c8e3c6b871c7e1530cd8b6cf51a900bda7c65fbbe583ea04c39042fec411cfdc9dfe3ba58832044ed925c5c25ca2a8ee5d77e6b19e8aea08c
data/.exrc ADDED
@@ -0,0 +1,7 @@
1
+ " To enable per-directory .exrc-files, add the following lines to your ~/.vimrc
2
+ "
3
+ " set exrc " enable per-directory .exrc files
4
+ " set secure " disable unsafe commands in local .exrc files
5
+
6
+ let g:turbux_command_rspec = 'script/test'
7
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1.21
1
+ 0.1.1.22
@@ -0,0 +1,17 @@
1
+ require "attr_extras"
2
+
3
+ module BarsoomUtils
4
+ class ParseSpaceSeparatedTokenValues
5
+ method_object :value, [ :minimum_key_size!, :token_name! ]
6
+
7
+ def call
8
+ keys = value.split
9
+
10
+ raise "Missing #{token_name}. Quitting." if keys.empty?
11
+
12
+ 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 }
13
+
14
+ keys.freeze
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
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(api_tokens_value, minimum_key_size: minimum_key_size, token_name: token_name)
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
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.21
4
+ version: 0.1.1.22
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-05-20 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".exrc"
20
21
  - ".github/workflows/ci.yml"
21
22
  - ".gitignore"
22
23
  - ".rspec"
@@ -29,12 +30,14 @@ files:
29
30
  - lib/barsoom_utils.rb
30
31
  - lib/barsoom_utils/exception_notifier.rb
31
32
  - lib/barsoom_utils/feature_toggle.rb
33
+ - lib/barsoom_utils/parse_space_separated_token_values.rb
32
34
  - lib/barsoom_utils/ping_health_check.rb
33
35
  - lib/barsoom_utils/spec/debug_helpers.rb
34
36
  - lib/barsoom_utils/version.rb
35
37
  - script/test
36
38
  - shared_rubocop.yml
37
39
  - shared_rubocop_rails.yml
40
+ - spec/barsoom_utils/parse_space_separated_token_values_spec.rb
38
41
  - spec/exception_notifier_spec.rb
39
42
  - spec/feature_toggle_spec.rb
40
43
  - spec/ping_health_check_spec.rb