pangea-component 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a794f44797b9c581be369cc39a726bd1d2e122f72451c8d740d204abe74a1460
4
+ data.tar.gz: 868218acdf928d2d3a400a9d5587c4350e26ebe1af4906b5abaf1a7ce6877320
5
+ SHA512:
6
+ metadata.gz: 027f0e9a6629ba28f480cde1c4091c6b72d1732f4c2ae161ab972ca5c96b760f73f21cf22b9e137be244f34314cba6970b299dbc9c39d8df636a04cc83f66571
7
+ data.tar.gz: 304596e3eb11cf9d83b6cc77c2cffbf1d88988bafe27815808f8c857aa6ce01fb25d5dd0a76752dadc0fdbb72ab9139208280f3c365e5d471e2f8426ce034311
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/.rubocop.yml ADDED
@@ -0,0 +1,50 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Style/FrozenStringLiteralComment:
5
+ Enabled: false
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/GlobalVars:
11
+ Enabled: false
12
+
13
+ Style/GuardClause:
14
+ Enabled: false
15
+
16
+ Style/StringConcatenation:
17
+ Enabled: false
18
+
19
+ Metrics/MethodLength:
20
+ Enabled: false
21
+
22
+ Metrics/AbcSize:
23
+ Enabled: false
24
+
25
+ Metrics/PerceivedComplexity:
26
+ Enabled: false
27
+
28
+ Metrics/ParameterLists:
29
+ Enabled: false
30
+
31
+ Metrics/ModuleLength:
32
+ Enabled: false
33
+
34
+ Style/MissingRespondToMissing:
35
+ Enabled: false
36
+
37
+ Lint/MissingSuper:
38
+ Enabled: false
39
+
40
+ Metrics/CyclomaticComplexity:
41
+ Enabled: false
42
+
43
+ Metrics/ClassLength:
44
+ Enabled: false
45
+
46
+ Metrics/BlockLength:
47
+ Enabled: false
48
+
49
+ Lint/EmptyClass:
50
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ pangea-component
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.0
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source %(https://rubygems.org)
2
+
3
+ group :development do
4
+ %w[
5
+ rubocop-rspec
6
+ rubocop-rake
7
+ keycutter
8
+ rspec
9
+ rake
10
+ yard
11
+ ].each do |this_gem|
12
+ gem this_gem
13
+ end
14
+ end
15
+
16
+ group :production do
17
+ %w[
18
+ terraform-synthesizer
19
+ abstract-synthesizer
20
+ ].each do |this_gem|
21
+ gem this_gem
22
+ end
23
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ abstract-synthesizer (0.0.2)
5
+ ast (2.4.2)
6
+ base64 (0.1.1)
7
+ diff-lcs (1.5.0)
8
+ json (2.6.3)
9
+ keycutter (1.0.2)
10
+ language_server-protocol (3.17.0.3)
11
+ parallel (1.23.0)
12
+ parser (3.2.2.3)
13
+ ast (~> 2.4.1)
14
+ racc
15
+ racc (1.7.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.8.1)
19
+ rexml (3.2.6)
20
+ rspec (3.12.0)
21
+ rspec-core (~> 3.12.0)
22
+ rspec-expectations (~> 3.12.0)
23
+ rspec-mocks (~> 3.12.0)
24
+ rspec-core (3.12.2)
25
+ rspec-support (~> 3.12.0)
26
+ rspec-expectations (3.12.3)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-mocks (3.12.6)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-support (3.12.1)
33
+ rubocop (1.56.1)
34
+ base64 (~> 0.1.1)
35
+ json (~> 2.3)
36
+ language_server-protocol (>= 3.17.0)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.2.2.3)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml (>= 3.2.5, < 4.0)
42
+ rubocop-ast (>= 1.28.1, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 2.4.0, < 3.0)
45
+ rubocop-ast (1.29.0)
46
+ parser (>= 3.2.1.0)
47
+ rubocop-capybara (2.18.0)
48
+ rubocop (~> 1.41)
49
+ rubocop-factory_bot (2.23.1)
50
+ rubocop (~> 1.33)
51
+ rubocop-rake (0.6.0)
52
+ rubocop (~> 1.0)
53
+ rubocop-rspec (2.23.2)
54
+ rubocop (~> 1.33)
55
+ rubocop-capybara (~> 2.17)
56
+ rubocop-factory_bot (~> 2.22)
57
+ ruby-progressbar (1.13.0)
58
+ terraform-synthesizer (0.0.2)
59
+ unicode-display_width (2.4.2)
60
+ yard (0.9.34)
61
+
62
+ PLATFORMS
63
+ x86_64-darwin-22
64
+
65
+ DEPENDENCIES
66
+ abstract-synthesizer
67
+ keycutter
68
+ rake
69
+ rspec
70
+ rubocop-rake
71
+ rubocop-rspec
72
+ terraform-synthesizer
73
+ yard
74
+
75
+ BUNDLED WITH
76
+ 2.3.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 drzln
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # pangea-component
2
+ Control resource creation response with components
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require %(bundler/gem_tasks)
4
+ require %(rubocop/rake_task)
5
+ require %(rspec/core/rake_task)
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new(:rubocop) do |t|
9
+ t.options = [%(--display-cop-names)]
10
+ end
11
+
12
+ task :bundix do
13
+ sh %(bundle lock --update)
14
+ sh %(bundix)
15
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative %(./src/lib/pangea_component/version)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = %(pangea-component)
7
+ spec.version = PangeaComponent::VERSION
8
+ spec.authors = [%(drzthslnt@gmail.com)]
9
+ spec.email = [%(drzthslnt@gmail.com)]
10
+ spec.description = %(componentize declarative resources)
11
+ spec.summary = %(componentize declarative resources)
12
+ spec.homepage = %(https://github.com/drzln/#{spec.name})
13
+ spec.license = %(MIT)
14
+ spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
15
+ spec.require_paths = [%(src)]
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.required_ruby_version = %(>= #{`cat .ruby-version`})
18
+
19
+ %i[
20
+ rubocop-rspec
21
+ rubocop-rake
22
+ keycutter
23
+ rubocop
24
+ rspec
25
+ rake
26
+ yard
27
+ ].each do |gem|
28
+ spec.add_development_dependency(gem)
29
+ end
30
+
31
+ %i[
32
+ terraform-synthesizer
33
+ abstract-synthesizer
34
+ ].each do |gem|
35
+ spec.add_runtime_dependency(gem)
36
+ end
37
+
38
+ spec.metadata[%(rubygems_mfa_required)] = %(true)
39
+ end
@@ -0,0 +1,40 @@
1
+ require %(terraform-synthesizer)
2
+
3
+ describe %(aws components) do
4
+ let(:tf) do
5
+ TerraformSynthesizer.new
6
+ end
7
+
8
+ before do
9
+ tf.synthesize do
10
+ require_relative %(../src/lib/components/aws/vpc)
11
+
12
+ results = vpc(
13
+ name: %(test_vpc),
14
+ properties: {
15
+ cidr_block: %(10.0.0.0/16)
16
+ }
17
+ )
18
+
19
+ # inputs are always mirrored back
20
+ results[:inputs].each_key do |k|
21
+ output k do
22
+ value results[:inputs][k]
23
+ description %(The input #{k})
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ it %(returns a Hash) do
30
+ expect(tf.synthesis).to be_kind_of(Hash)
31
+ end
32
+
33
+ it %(contains correct outputs) do
34
+ outputs = tf.synthesis[:output]
35
+ expected = %i[resource name properties]
36
+ outputs.each_key do |k|
37
+ expect(expected.include?(k)).to be(true)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,41 @@
1
+ require_relative %(../src/lib/pangea_component/pangea_component)
2
+ require %(terraform-synthesizer)
3
+
4
+ describe %(component interface) do
5
+ let(:tf) do
6
+ TerraformSynthesizer.new
7
+ end
8
+
9
+ before do
10
+ tf.synthesize do
11
+ results = component(
12
+ resource: :aws_vpc,
13
+ name: %(test_vpc),
14
+ properties: {
15
+ cidr_block: %(10.0.0.0/16),
16
+ tags: { Name: %(test_vpc) }
17
+ }
18
+ )
19
+
20
+ # inputs are always mirrored back
21
+ results[:inputs].each_key do |k|
22
+ output k do
23
+ value results[:inputs][k]
24
+ description %(The input #{k})
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ it %(returns a Hash) do
31
+ expect(tf.synthesis).to be_kind_of(Hash)
32
+ end
33
+
34
+ it %(contains correct outputs) do
35
+ outputs = tf.synthesis[:output]
36
+ expected = %i[resource name properties]
37
+ outputs.each_key do |k|
38
+ expect(expected.include?(k)).to be(true)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ require_relative %(../src/lib/pangea_component/pangea_component)
2
+ require %(terraform-synthesizer)
3
+
4
+ describe %(component interface) do
5
+ let(:tf) do
6
+ TerraformSynthesizer.new
7
+ end
8
+
9
+ before do
10
+ tf.synthesize do
11
+ component(
12
+ resource: :aws_vpc,
13
+ name: %(test_vpc),
14
+ properties: {
15
+ cidr_block: %(10.0.0.0/16),
16
+ tags: { Name: %(test_vpc) }
17
+ }
18
+ )
19
+ end
20
+ end
21
+
22
+ it %(returns a Hash) do
23
+ expect(tf.synthesis).to be_kind_of(Hash)
24
+ end
25
+
26
+ it %(has correct property values) do
27
+ expected = {
28
+ cidr_block: %(10.0.0.0/16),
29
+ tags: { Name: %(test_vpc) }
30
+ }
31
+ tf.synthesis[:resource].each_key do |resource_name|
32
+ resource = tf.synthesis[:resource][resource_name]
33
+ resource.each_key do |property_name|
34
+ property_name = property_name.to_sym
35
+ property_value = resource[property_name]
36
+ expect(property_value).to eq(expected[property_name.to_sym])
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ require %(terraform-synthesizer)
@@ -0,0 +1,5 @@
1
+ require_relative %(../../pangea_component/pangea_component)
2
+
3
+ def vpc(**kwargs)
4
+ component(resource: %(aws_vpc), **kwargs)
5
+ end
@@ -0,0 +1,13 @@
1
+ require_relative %(../pangea_component/pangea_component)
2
+
3
+ def local_vpc(**kwargs)
4
+ component(resource: :aws_vpc, **kwargs)
5
+ end
6
+
7
+ module Aws
8
+ class << self
9
+ def vpc(**kwargs)
10
+ local_vpc(**kwargs)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ require %(json)
2
+
3
+ def symbolize(hash)
4
+ JSON[JSON[hash], symbolize_names: true]
5
+ end
6
+
7
+ def deep_open_struct(hash)
8
+ Struct.new(
9
+ hash.map do |key, value|
10
+ [key, value.is_a?(Hash) ? deep_open_struct(value) : value]
11
+ end
12
+ ).tap.call(&:freeze)
13
+ end
14
+
15
+ def component(**kwargs)
16
+ kwargs = symbolize(kwargs) unless kwargs.nil?
17
+ resource_name = kwargs.fetch(:resource, nil)
18
+ virtual_name = kwargs.fetch(:name, nil)
19
+ properties = kwargs.fetch(:properties, {})
20
+
21
+ resource(resource_name, virtual_name) do
22
+ properties.each_key do |method|
23
+ args = kwargs.dig(:properties, method)
24
+ send(method, args)
25
+ end
26
+ end
27
+
28
+ outputs = {}
29
+ outputs[:inputs] = kwargs
30
+
31
+ # future handle for extracted properties
32
+ # from derived components
33
+ nil if kwargs[:extracted_properties]
34
+
35
+ outputs
36
+ end
@@ -0,0 +1,3 @@
1
+ module PangeaComponent
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pangea-component
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - drzthslnt@gmail.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop-rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: keycutter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: terraform-synthesizer
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: abstract-synthesizer
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: componentize declarative resources
140
+ email:
141
+ - drzthslnt@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rubocop.yml"
148
+ - ".ruby-gemset"
149
+ - ".ruby-version"
150
+ - Gemfile
151
+ - Gemfile.lock
152
+ - LICENSE
153
+ - README.md
154
+ - Rakefile
155
+ - pangea-component.gemspec
156
+ - spec/aws_components_spec.rb
157
+ - spec/component_results_spec.rb
158
+ - spec/component_spec.rb
159
+ - spec/spec_helper.rb
160
+ - src/lib/components/aws.rb
161
+ - src/lib/components/aws/vpc.rb
162
+ - src/lib/pangea_component/pangea_component.rb
163
+ - src/lib/pangea_component/version.rb
164
+ homepage: https://github.com/drzln/pangea-component
165
+ licenses:
166
+ - MIT
167
+ metadata:
168
+ rubygems_mfa_required: 'true'
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - src
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 3.1.0
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.3.3
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: componentize declarative resources
188
+ test_files: []