humidifier 0.6.1 → 0.7.0

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
  SHA1:
3
- metadata.gz: 478eb0814ff5b1f23e2ccc3f8e1adcb9e055b28d
4
- data.tar.gz: bd5d51e4187f5a0f62334b203efaa0c3b2b296bf
3
+ metadata.gz: ed17317e4e90ba482a45ad606fe918e99cd5361d
4
+ data.tar.gz: 3d7c79b5e6c4fd441480f8ce7b3f6a2a0d882875
5
5
  SHA512:
6
- metadata.gz: 71c00602a3b655e5896a9778342bc0f57d857f4703470e269fed6e35986d9b2698ee17cbd38076642317918b56a6f68e2171dfe9fabc34ef8a97214cff20b30a
7
- data.tar.gz: babce6c19b6c6cbca100f28d9988a72e83a9d27e6d2359972e7bfedfecb23c80a7d1f4f952b612b6f5cd9006b25a50bced4d40a0c1a7e1f6ce0f092d09b7988e
6
+ metadata.gz: b41b275e02e29db2c24fdf0962a156b4f4c4c0865591bb90331d44707f8c6fa4cc912e122560997e993e22d7afe1ecc948baf1b6da46b0a3d160177400f0ba92
7
+ data.tar.gz: ed3bdbeef33547d65878241963a6489830d7c8b1eb4abbc69a92ef687ef1e850183dd950f8b797bfc66004d976a82b3e91a2d9d18e3affb8011830ef798c8da2
data/README.md CHANGED
@@ -43,6 +43,14 @@ Once stacks have the appropriate resources, you can query AWS to handle all stac
43
43
 
44
44
  Humidifier assumes you have an `aws-sdk` gem installed when you call these operations. It detects the version of the gem you have installed and uses the appropriate API depending on what is available. If Humidifier cannot find any way to use the AWS SDK, it will warn you on every API call and simply return false.
45
45
 
46
+ You can also manually specify the version of the SDK that you want to use, in the case that you have both gems in your load path. In that case, you would specify it on the Humidifier configuration object:
47
+
48
+ ```ruby
49
+ Humidifier.configure do |config|
50
+ config.sdk_version = 1
51
+ end
52
+ ```
53
+
46
54
  #### CloudFormation functions
47
55
 
48
56
  You can use CFN intrinsic functions and references using `Humidifier.fn.[name]` and `Humidifier.ref`. Those will build appropriate structures that know how to be dumped to CFN syntax appropriately.
@@ -61,7 +69,7 @@ Resources have an `aws_name` method to see how AWS references them. They also co
61
69
 
62
70
  ### Large templates
63
71
 
64
- When templates are especially large (larger than 51,200 bytes), they cannot be uploaded directly through the AWS SDK. You can configure Humidifier to seemlessly upload the templates to S3 and reference them using an S3 URL instead by:
72
+ When templates are especially large (larger than 51,200 bytes), they cannot be uploaded directly through the AWS SDK. You can configure Humidifier to seamlessly upload the templates to S3 and reference them using an S3 URL instead by:
65
73
 
66
74
  ```ruby
67
75
  Humidifier.configure do |config|
@@ -20,18 +20,17 @@ module Humidifier
20
20
 
21
21
  attr_accessor :shim
22
22
 
23
- # Attempt to require both aws-sdk-v1 and aws-sdk, then set the shim based on what successfully loaded
23
+ # Either set the SDK based on the configured option or guess the SDK
24
+ # version by attempting to require both aws-sdk-v1 and aws-sdk, then setting
25
+ # the shim based on what successfully loaded
24
26
  def initialize
25
- try_require_sdk('aws-sdk-v1')
26
- try_require_sdk('aws-sdk')
27
-
28
27
  self.shim =
29
- if Object.const_defined?(:AWS)
28
+ if Humidifier.config.sdk_version_1?
30
29
  AwsAdapters::SDKV1.new
31
- elsif Object.const_defined?(:Aws)
30
+ elsif Humidifier.config.sdk_version_2?
32
31
  AwsAdapters::SDKV2.new
33
32
  else
34
- AwsAdapters::Noop.new
33
+ guess_sdk
35
34
  end
36
35
  end
37
36
 
@@ -52,6 +51,19 @@ module Humidifier
52
51
 
53
52
  private
54
53
 
54
+ def guess_sdk
55
+ try_require_sdk('aws-sdk-v1')
56
+ try_require_sdk('aws-sdk')
57
+
58
+ if Object.const_defined?(:Aws)
59
+ AwsAdapters::SDKV2.new
60
+ elsif Object.const_defined?(:AWS)
61
+ AwsAdapters::SDKV1.new
62
+ else
63
+ AwsAdapters::Noop.new
64
+ end
65
+ end
66
+
55
67
  def try_require_sdk(name)
56
68
  require name
57
69
  rescue LoadError # rubocop:disable Lint/HandleExceptions
@@ -14,16 +14,27 @@ on the top-level Humidifier object like so:
14
14
  end
15
15
  MSG
16
16
 
17
- attr_accessor :s3_bucket, :s3_prefix
17
+ attr_accessor :s3_bucket, :s3_prefix, :sdk_version
18
18
 
19
19
  def initialize(opts = {})
20
- self.s3_bucket = opts[:s3_bucket]
21
- self.s3_prefix = opts[:s3_prefix]
20
+ self.s3_bucket = opts[:s3_bucket]
21
+ self.s3_prefix = opts[:s3_prefix]
22
+ self.sdk_version = opts[:sdk_version]
22
23
  end
23
24
 
24
25
  # raise an error unless the s3_bucket field is set
25
26
  def ensure_upload_configured!(payload)
26
27
  raise UPLOAD_MESSAGE.gsub('%{identifier}', payload.identifier) if s3_bucket.nil?
27
28
  end
29
+
30
+ # true if the sdk_version option is set to 1 or '1'
31
+ def sdk_version_1?
32
+ sdk_version.to_s == '1'
33
+ end
34
+
35
+ # true if the sdk_version option is set to 2 or '2'
36
+ def sdk_version_2?
37
+ sdk_version.to_s == '2'
38
+ end
28
39
  end
29
40
  end
@@ -1,4 +1,4 @@
1
1
  module Humidifier
2
2
  # Gem version
3
- VERSION = '0.6.1'.freeze
3
+ VERSION = '0.7.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humidifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Localytics
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-19 00:00:00.000000000 Z
11
+ date: 2016-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler