humidifier 1.6.0 → 1.6.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 +4 -4
- data/CloudFormationResourceSpecification.json +1158 -1107
- data/README.md +0 -4
- data/lib/humidifier/parameter.rb +1 -1
- data/lib/humidifier/stack.rb +2 -2
- data/lib/humidifier/utils.rb +7 -0
- data/lib/humidifier/version.rb +1 -1
- data/lib/humidifier.rb +0 -2
- metadata +4 -37
- data/ext/humidifier/extconf.rb +0 -2
- data/ext/humidifier/humidifier.c +0 -81
- data/ext/humidifier/humidifier.h +0 -9
- data/lib/humidifier/humidifier.bundle +0 -0
data/README.md
CHANGED
@@ -94,10 +94,6 @@ The default rake task runs the tests. Coverage is reported on the command line,
|
|
94
94
|
|
95
95
|
The specs pulled from the CFN docs is saved to `CloudFormationResourceSpecification.json`. You can update it by running `bundle exec rake specs`. This script will pull down the latest [resource specification](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) to be used with Humidifier.
|
96
96
|
|
97
|
-
### Extension
|
98
|
-
|
99
|
-
The `underscore` string utility method does a lot of the heavy lifting of changing AWS property names over to ruby method names. As such, it's been extracted to a native extension to increase speed and efficiency. To compile it locally run `rake compile`.
|
100
|
-
|
101
97
|
### Contributing
|
102
98
|
|
103
99
|
Bug reports and pull requests are welcome on GitHub at https://github.com/localytics/humidifier.
|
data/lib/humidifier/parameter.rb
CHANGED
@@ -8,7 +8,7 @@ module Humidifier
|
|
8
8
|
attr_accessor :type, *PROPERTIES.values
|
9
9
|
|
10
10
|
def initialize(opts = {})
|
11
|
-
PROPERTIES.
|
11
|
+
PROPERTIES.each_value { |prop| send(:"#{prop}=", opts[prop]) }
|
12
12
|
self.type = opts.fetch(:type, 'String')
|
13
13
|
end
|
14
14
|
|
data/lib/humidifier/stack.rb
CHANGED
@@ -14,8 +14,8 @@ module Humidifier
|
|
14
14
|
self.id = opts[:id]
|
15
15
|
self.default_identifier = self.class.next_default_identifier
|
16
16
|
|
17
|
-
ENUMERABLE_RESOURCES.
|
18
|
-
STATIC_RESOURCES.
|
17
|
+
ENUMERABLE_RESOURCES.each_value { |prop| send(:"#{prop}=", opts.fetch(prop, {})) }
|
18
|
+
STATIC_RESOURCES.each_value { |prop| send(:"#{prop}=", opts[prop]) }
|
19
19
|
end
|
20
20
|
|
21
21
|
# Add a resource to the stack and optionally set its attributes
|
data/lib/humidifier/utils.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module Humidifier
|
2
2
|
# Dumps an object to CFN syntax
|
3
3
|
module Utils
|
4
|
+
# convert from UpperCamelCase to lower_snake_case
|
5
|
+
def self.underscore(name)
|
6
|
+
return nil unless name
|
7
|
+
name.gsub(/([A-Z]+)([0-9]|[A-Z]|\z)/) { "#{$1.capitalize}#{$2}" }
|
8
|
+
.gsub(/(.)([A-Z])/, '\1_\2').downcase
|
9
|
+
end
|
10
|
+
|
4
11
|
# a frozen hash of the given names mapped to their underscored version
|
5
12
|
def self.underscored(names)
|
6
13
|
names.map { |name| [name, underscore(name).to_sym] }.to_h.freeze
|
data/lib/humidifier/version.rb
CHANGED
data/lib/humidifier.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humidifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Localytics
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: benchmark-ips
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.7'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.7'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +80,6 @@ dependencies:
|
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '12.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rake-compiler
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.0'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: rubocop
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,16 +113,12 @@ description: Programmatically generate and manage AWS CloudFormation templates,
|
|
141
113
|
email:
|
142
114
|
- oss@localytics.com
|
143
115
|
executables: []
|
144
|
-
extensions:
|
145
|
-
- ext/humidifier/extconf.rb
|
116
|
+
extensions: []
|
146
117
|
extra_rdoc_files: []
|
147
118
|
files:
|
148
119
|
- CloudFormationResourceSpecification.json
|
149
120
|
- LICENSE
|
150
121
|
- README.md
|
151
|
-
- ext/humidifier/extconf.rb
|
152
|
-
- ext/humidifier/humidifier.c
|
153
|
-
- ext/humidifier/humidifier.h
|
154
122
|
- lib/humidifier.rb
|
155
123
|
- lib/humidifier/aws_adapters/base.rb
|
156
124
|
- lib/humidifier/aws_adapters/noop.rb
|
@@ -160,7 +128,6 @@ files:
|
|
160
128
|
- lib/humidifier/condition.rb
|
161
129
|
- lib/humidifier/configuration.rb
|
162
130
|
- lib/humidifier/fn.rb
|
163
|
-
- lib/humidifier/humidifier.bundle
|
164
131
|
- lib/humidifier/loader.rb
|
165
132
|
- lib/humidifier/mapping.rb
|
166
133
|
- lib/humidifier/output.rb
|
@@ -204,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
171
|
version: '0'
|
205
172
|
requirements: []
|
206
173
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.6.
|
174
|
+
rubygems_version: 2.6.13
|
208
175
|
signing_key:
|
209
176
|
specification_version: 4
|
210
177
|
summary: CloudFormation made easy
|
data/ext/humidifier/extconf.rb
DELETED
data/ext/humidifier/humidifier.c
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
#include "humidifier.h"
|
2
|
-
|
3
|
-
// takes a substring from underscore_preprocess like EC2T or AWST and converts
|
4
|
-
// it to Ec2T or AwsT
|
5
|
-
static void format_substring(char* substr, const int substr_idx, const int capitalize)
|
6
|
-
{
|
7
|
-
int idx;
|
8
|
-
|
9
|
-
for (idx = 0; idx < substr_idx; idx++) {
|
10
|
-
if (idx == 0) {
|
11
|
-
substr[idx] = toupper(substr[idx]);
|
12
|
-
}
|
13
|
-
else if ((idx != substr_idx - 1) || capitalize == 0) {
|
14
|
-
substr[idx] = tolower(substr[idx]);
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
// finds occurences of EC2Thing or AWSThing and makes them into Ec2Thing and
|
20
|
-
// AwsThing so that underscore can be simpler and just look for capitals
|
21
|
-
static void preprocess(char* str)
|
22
|
-
{
|
23
|
-
char substr[strlen(str)];
|
24
|
-
int idx, substr_idx;
|
25
|
-
|
26
|
-
for (idx = 0, substr_idx = 0; str[idx] != '\0'; idx++) {
|
27
|
-
if (isupper(str[idx])) {
|
28
|
-
substr[substr_idx++] = str[idx];
|
29
|
-
|
30
|
-
if (str[idx + 1] == '\0') {
|
31
|
-
format_substring(substr, substr_idx, 0);
|
32
|
-
memcpy(str + (idx - substr_idx) + 1, substr, substr_idx);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
else if (isdigit(str[idx]) || (substr_idx != 0)) {
|
36
|
-
if (substr_idx != 1) {
|
37
|
-
format_substring(substr, substr_idx, islower(str[idx]));
|
38
|
-
memcpy(str + (idx - substr_idx), substr, substr_idx);
|
39
|
-
}
|
40
|
-
substr_idx = 0;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
// takes a string and returns a downcased version where capitals are now
|
46
|
-
// separated by underscores
|
47
|
-
static VALUE underscore(VALUE self, VALUE str)
|
48
|
-
{
|
49
|
-
if (TYPE(str) == T_NIL) return Qnil;
|
50
|
-
|
51
|
-
char *str_value = rb_string_value_cstr(&str);
|
52
|
-
char orig_str[strlen(str_value) + 1];
|
53
|
-
|
54
|
-
strcpy(orig_str, str_value);
|
55
|
-
preprocess(orig_str);
|
56
|
-
|
57
|
-
// manually null-terminating the string because on Fedora for strings of
|
58
|
-
// length 16 this breaks otherwise
|
59
|
-
orig_str[strlen(str_value)] = '\0';
|
60
|
-
|
61
|
-
char new_str[strlen(orig_str) * 2];
|
62
|
-
char prev;
|
63
|
-
int orig_idx, new_idx;
|
64
|
-
|
65
|
-
for (orig_idx = 0, new_idx = 0; orig_str[orig_idx] != '\0'; orig_idx++) {
|
66
|
-
if (orig_idx != 0 && isupper(orig_str[orig_idx])) {
|
67
|
-
new_str[new_idx++] = '_';
|
68
|
-
}
|
69
|
-
new_str[new_idx++] = tolower(orig_str[orig_idx]);
|
70
|
-
prev = tolower(orig_str[orig_idx]);
|
71
|
-
}
|
72
|
-
|
73
|
-
return rb_str_new(new_str, new_idx);
|
74
|
-
}
|
75
|
-
|
76
|
-
void Init_humidifier()
|
77
|
-
{
|
78
|
-
VALUE Humidifier = rb_define_module("Humidifier");
|
79
|
-
VALUE Utils = rb_define_module_under(Humidifier, "Utils");
|
80
|
-
rb_define_singleton_method(Utils, "underscore", underscore, 1);
|
81
|
-
}
|
data/ext/humidifier/humidifier.h
DELETED
Binary file
|