cloudstrap 0.47.2.pre → 0.47.7.pre

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
  SHA1:
3
- metadata.gz: 1d47fbc090ca2646eef3d3ee888781019e590a0f
4
- data.tar.gz: 5de7a4205f570048dbf87fe3eeba37ad0f772a32
3
+ metadata.gz: cf009d0dbf1e2326e11263d9cbd8f229f2d52d9d
4
+ data.tar.gz: '038d5a44ae753d97664336739ed46b21eff00186'
5
5
  SHA512:
6
- metadata.gz: 18d1f02d11172bfee7b3ce45a2013c60aa6271c82c01bcfe284a67a95a84ad153f38e697fd8720b8c94a437817cce4448746627ad2e34302e89a2fb97c6ae8ba
7
- data.tar.gz: 6df26b4464f08af812708d6ab6ebda4724672c8053f5fd80bff30e96f8b6b6edc5adb9ab52d41c3f6ebc7afc76bc8213d714642aaeb449a994dd2d376a3ce1b7
6
+ metadata.gz: b44ee520a577dfbbc578b1da701592b4e89496b095f062296990f415f40f5a53ab9cdb2460e4b5f36337b9b84f7332507634385417bac66ea3d307dc03ec5173
7
+ data.tar.gz: 501ba92fd0c75b9e2daf5ee47fa8ca0d383ff07ce74ce367441314ea72f7ea4a499a8d976d66019d845360ddd83f6d3e4a67ef5ce5dc4280637f28cb9858614d
@@ -503,6 +503,13 @@ module Cloudstrap
503
503
  @config ||= Config.new
504
504
  end
505
505
 
506
+ Contract RespondTo[:to_s] => Maybe[Any]
507
+ def environment(variable)
508
+ ENV.fetch("#{config.environment_namespace}_#{variable.to_s.upcase}") do
509
+ yield if block_given?
510
+ end
511
+ end
512
+
506
513
  Contract None => Moneta::Proxy
507
514
  def cache
508
515
  @cache ||= Moneta.new :File, dir: config.cache_path
@@ -423,8 +423,9 @@ module Cloudstrap
423
423
 
424
424
  Contract None => ArrayOf[Aws::EC2::Types::AvailabilityZone]
425
425
  def availability_zones!
426
- @availability_zones = call_api(:describe_availability_zones)
427
- .availability_zones.take(config.maximum_availability_zones)
426
+ @availability_zones = at_least(config.minimum_availability_zones)
427
+ .(call_api(:describe_availability_zones).availability_zones)
428
+ .take(config.maximum_availability_zones)
428
429
  end
429
430
 
430
431
  Contract None => ArrayOf[Aws::EC2::Types::AvailabilityZone]
@@ -439,6 +440,11 @@ module Cloudstrap
439
440
 
440
441
  private
441
442
 
443
+ Contract Maybe[Pos] => Func[Enumerable => Enumerable]
444
+ def at_least(minimum = 0)
445
+ ->(list) { list.size >= minimum ? list : list.cycle }
446
+ end
447
+
442
448
  def client
443
449
  Aws::EC2::Client
444
450
  end
@@ -247,6 +247,16 @@ module Cloudstrap
247
247
  lookup(:maximum_availability_zones) { '3' }.to_i
248
248
  end
249
249
 
250
+ Contract None => Pos
251
+ def minimum_availability_zones
252
+ lookup(:minimum_availability_zones) { '1' }.to_i
253
+ end
254
+
255
+ Contract None => String
256
+ def environment_namespace
257
+ lookup(:environment_namespace) { 'CLOUDSTRAP' }.upcase
258
+ end
259
+
250
260
  private
251
261
 
252
262
  Contract None => ::Pastel::Delegator
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.2.pre
4
+ version: 0.47.7.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Olstrom