barsoom_utils 0.1.1.19 → 0.1.1.22

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: 0d87fa41a41879b2e8fe4e437f11541c51a1bdb9db592c29f11d9c38ef06eb08
4
- data.tar.gz: d5a75888165a7c505f68bb399d9963b6103cda7c30805d2efec96f85c4c3896a
3
+ metadata.gz: ac777967c42be2ec828febf467411c658f65a87502d643dec04264dbca7c537c
4
+ data.tar.gz: e08ceedc6255c027f2aac6a674d965a141f2bd8aec8efa0fd205e90e26d2cb8d
5
5
  SHA512:
6
- metadata.gz: 9e6ac527a5f00ce98dadd235e269c41421148667ac555bf8adff7a9258a453d68689f8b9ada51a2e772bdaaa148e0defcde1608a84e44344448b37fa3bdc0caa
7
- data.tar.gz: b0289e365dd949ea5b3f8a1c0c9a8335cbb3cd8de44032c6d394d7d226955d8ef2dc51f9b1adce71ecabf5ffebb723e9a2f1d129fc2bdba1def89c0a6ee5b080
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.19
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
data/shared_rubocop.yml CHANGED
@@ -10,6 +10,8 @@ AllCops:
10
10
  - node_modules/**/*
11
11
  - tmp/**/*
12
12
  - deploy/tmp/**/*
13
+ # Will only enable new cops for the subset of cops that are enabled. https://docs.rubocop.org/rubocop/versioning.html#pending-cops
14
+ NewCops: enable
13
15
 
14
16
  # Enable all Security cops
15
17
  Security:
@@ -252,12 +254,6 @@ Style/HashSyntax:
252
254
  Enabled: true
253
255
  EnforcedStyle: ruby19
254
256
 
255
- Security/IoMethods: # new in 1.22
256
- Enabled: true
257
-
258
- Security/CompoundHash: # new in 1.28
259
- Enabled: true
260
-
261
257
  # https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecduplicatedassignment
262
258
  Gemspec/DuplicatedAssignment:
263
259
  Enabled: true
@@ -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.19
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-02 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