skull_island 2.0.0 → 2.0.1

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: 00a7b4f233be82c0837c704cc2db5e07ede909632c2e54e413962f4343908974
4
- data.tar.gz: 28589bf89713ddc2a039b861d7a1290677b6c69b5bdfe2f5a7ea62bce05fa52e
3
+ metadata.gz: 5a5d7af669323fdbe1216566cf8baeba91724c2292de92a283d39cd3bd1aac4e
4
+ data.tar.gz: 55cf31d7419e2cb52f132bf906a02de85d5f79c97bbb2c63f3b8d25889c92af1
5
5
  SHA512:
6
- metadata.gz: b2530b37d2f914b1f6c6c419fa9b0c8dfb39dd9c760c51f0135bc9267eea4aab94ea3e8ae1c6058731356125a63ca1aafe5a6e97ac74ad5feb440849a28bb45b
7
- data.tar.gz: c5231a55b789eb6cd602f34c7643585a8142adb81f722e96a805b0b91509d16f05df7708f811d61cfa6b76ce67dfbb0c898506b014c7395634a40c4f95808968
6
+ metadata.gz: 335c95cdfbb85ba6979b1d2460ea317fb5aff1207edcd24ebda4fb1974b9e0204bed1e52fd99ad703a809fbaef65517095c1521341e857c5e09be50223393553
7
+ data.tar.gz: 002752d03a6dfd2ce7caae75389765608f24dcbfdef00bf7ed85a3fa5c18b82e58de35f9466bce9e7d7f77976af8d17d17d73e6407b41783e6f7d29565c87c27
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- skull_island (2.0.0)
4
+ skull_island (2.0.1)
5
5
  deepsort (~> 0.4)
6
6
  erubi (~> 1.8)
7
7
  json (~> 2.1)
data/README.md CHANGED
@@ -282,7 +282,7 @@ While technically _any_ Ruby is valid, the following are pretty helpful for temp
282
282
 
283
283
  * `ENV.fetch('VARIABLE_NAME', 'default value')` - This allows looking up the environment variable `VARIABLE_NAME` and using its value, or, if it isn't defined, it uses `default value` as the value. With this we could change `host: api.example.com` to `host: <%= ENV.fetch('API_HOST', 'api.example.com') %>`. With this, if `API_HOST` is provided, it'll use that, otherwise it will default to `api.example.com`. This is especially helpful for sensitive information; you can version control the configuration but pass in things like credentials via environment variables at runtime.
284
284
 
285
- Note also that 1.4.x and beyond of Skull Island support two phases of embedded ruby: first, a simple phase that treats the **entire file** as just text, allowing you to use the full power of ruby for things like loops, conditional logic, and more; the second phase is applied for individual attributes within the rendered YAML document. This is where the `lookup()` function above is used.
285
+ Note also that 1.4.x and beyond of Skull Island support two phases of embedded ruby: first, a simple phase that treats the **entire file** as just text, allowing you to use the full power of ruby for things like loops, conditional logic, and more; the second phase is applied for individual attributes within the rendered YAML document. This is where the `lookup()` function above is used.
286
286
 
287
287
  ## SDK Usage
288
288
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CoreExtensions
4
+ module Hash
5
+ # Monkey-patches for Hash to add some recursive pruning options
6
+ module Pruning
7
+ # Recursively strips empty and nil elements from a Hash
8
+ # @return [Hash]
9
+ def prune
10
+ newhash = {}
11
+
12
+ each do |k, v|
13
+ if v.is_a?(Hash)
14
+ newvalue = v.prune
15
+ newhash[k] = newvalue unless newvalue.empty?
16
+ elsif v.respond_to?(:empty?)
17
+ newhash[k] = v unless v.empty?
18
+ else
19
+ newhash[k] = v unless v.nil?
20
+ end
21
+ end
22
+
23
+ newhash
24
+ end
25
+ end
26
+ end
27
+ end
@@ -117,7 +117,7 @@ module SkullIsland
117
117
  end
118
118
 
119
119
  def postprocess_config(value)
120
- value.deep_sort.compact
120
+ value.deep_sort.prune.compact
121
121
  end
122
122
 
123
123
  def postprocess_consumer(value)
@@ -18,7 +18,7 @@ module SkullIsland
18
18
  property :hash_fallback_header, validate: true
19
19
  property :hash_on_cookie, validate: true
20
20
  property :hash_on_cookie_path, validate: true
21
- property :healthchecks, validate: true
21
+ property :healthchecks, validate: true, postprocess: true
22
22
  property :host_header, validate: true
23
23
  property :created_at, read_only: true, postprocess: true
24
24
  property :tags, validate: true, preprocess: true, postprocess: true
@@ -160,6 +160,11 @@ module SkullIsland
160
160
 
161
161
  private
162
162
 
163
+ # Prunes empty values from the healthchecks Hash
164
+ def postprocess_healthchecks(value)
165
+ value.is_a?(Hash) ? value.prune : value
166
+ end
167
+
163
168
  # Validates the upstream balancing {#algorithm}
164
169
  def validate_algorithm(value)
165
170
  %w[round-robin consistent-hashing least-connections].include?(value)
@@ -4,6 +4,6 @@ module SkullIsland
4
4
  VERSION = [
5
5
  2, # Major
6
6
  0, # Minor
7
- 0 # Patch
7
+ 1 # Patch
8
8
  ].join('.')
9
9
  end
data/lib/skull_island.rb CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  # Core Extensions
4
4
  require 'core_extensions/string/transformations'
5
+ require 'core_extensions/hash/pruning'
5
6
  String.include CoreExtensions::String::Transformations
7
+ Hash.include CoreExtensions::Hash::Pruning
6
8
 
7
9
  # Standard Library Requirements
8
10
  require 'date'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skull_island
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
@@ -241,6 +241,7 @@ files:
241
241
  - bin/console
242
242
  - bin/setup
243
243
  - exe/skull_island
244
+ - lib/core_extensions/hash/pruning.rb
244
245
  - lib/core_extensions/string/transformations.rb
245
246
  - lib/skull_island.rb
246
247
  - lib/skull_island/api_client.rb