unifig-env 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9faeed8441b6f3300f41b2be7c25892be0d73090b326050071a6074ff97a6d1a
4
+ data.tar.gz: 59f2b0fd7ab2017d004d7ed42e1ea0aa3556c5289e141205163326993d80f87d
5
+ SHA512:
6
+ metadata.gz: 6ec302bbe6cad0828dae3e959a355bb15db7b14582950d49a6cd2d544e100bc03033b86bbbe0e74f0496c5eaca6837f59983fe0418718ef216611605928354cc
7
+ data.tar.gz: df5be543d4480f335c20c1f37e3f0dc514dfd8e2725ca22983c3fe7250608db02a5cdc82ae7c1f5b83f0473c551e13288acf3cadeee2c48bb76dbff871699356
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # [0.1.0][] (2022-07-24)
2
+
3
+ Initial release.
4
+
5
+ [0.1.0]: https://github.com/AaronLasseigne/unifig-env/compare/v0.0.0...v0.1.0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,19 @@
1
+ # Contributing
2
+
3
+ For features please open a [discussion][] and we can make sure the feature fits with the gem before working on it.
4
+
5
+ ## Steps
6
+
7
+ 1. [Fork][] the repo.
8
+ 2. Add a breaking test for your change.
9
+ 3. Make the tests pass.
10
+ 4. Push your fork.
11
+ 5. Submit a pull request against the `next` branch.
12
+
13
+ ## Code Style
14
+
15
+ Running the tests using `rake` (with no args) will also check for style issues in the code.
16
+ If you have a failure you cannot figure out push the PR and ask for help.
17
+
18
+ [fork]: https://github.com/AaronLasseigne/unifig-env/fork
19
+ [discussion]: https://github.com/AaronLasseigne/unifig-env/discussions/categories/ideas
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Aaron Lasseigne
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # [Unifig::Env][]
2
+
3
+ Adds a provider to support loading environment variables to [Unifig][].
4
+
5
+ [![Version](https://img.shields.io/gem/v/unifig-env.svg?style=flat-square)](https://rubygems.org/gems/unifig-env)
6
+ [![Test](https://img.shields.io/github/workflow/status/AaronLasseigne/unifig-env/Test?label=Test&style=flat-square)](https://github.com/AaronLasseigne/unifig-env/actions?query=workflow%3ATest)
7
+
8
+ ## Installation
9
+
10
+ Add it to your Gemfile:
11
+
12
+ ``` rb
13
+ gem 'unifig-env', '~> 0.1.0'
14
+ ```
15
+
16
+ Or install it manually:
17
+
18
+ ``` sh
19
+ $ gem install unifig-env --version '~> 0.1.0'
20
+ ```
21
+
22
+ This project uses [Semantic Versioning][].
23
+ Check out [GitHub releases][] for a detailed list of changes.
24
+
25
+ ## Usage
26
+
27
+ Use `env` as your provider or add it to your list of providers:
28
+
29
+ ``` yml
30
+ config:
31
+ providers: env
32
+
33
+ HOST:
34
+ ```
35
+
36
+ This will pull `"HOST"` from `ENV` and add it to Unifig.
37
+
38
+ ## Contributing
39
+
40
+ If you want to contribute to Unifig:Env, please read [our contribution guidelines][].
41
+ A [complete list of contributors][] is available on GitHub.
42
+
43
+ ## License
44
+
45
+ Unifig is licensed under [the MIT License][].
46
+
47
+ [Unifig::Env]: https://github.com/AaronLasseigne/unifig-env
48
+ [Unifig]: https://github.com/AaronLasseigne/unifig
49
+ [Semantic Versioning]: http://semver.org/spec/v2.0.0.html
50
+ [GitHub releases]: https://github.com/AaronLasseigne/unifig-env/releases
51
+ [our contribution guidelines]: CONTRIBUTING.md
52
+ [complete list of contributors]: https://github.com/AaronLasseigne/unifig-env/graphs/contributors
53
+ [the MIT License]: LICENSE.txt
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unifig
4
+ module Env
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
data/lib/unifig/env.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'env/version'
4
+ require_relative 'providers/env'
5
+
6
+ module Unifig
7
+ # @private
8
+ module Env
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unifig
4
+ module Providers
5
+ # @private
6
+ module Env
7
+ def self.name
8
+ :env
9
+ end
10
+
11
+ def self.retrieve(var_names)
12
+ env_values = var_names.to_h do |name|
13
+ [name, ::ENV[name.to_s]]
14
+ end
15
+ env_values.compact!
16
+ env_values
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ require 'unifig/env'
2
+
3
+ RSpec.configure do |config|
4
+ config.expect_with :rspec do |expectations|
5
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
+ expectations.on_potential_false_positives = :nothing
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.shared_context_metadata_behavior = :apply_to_host_groups
14
+
15
+ config.filter_run_when_matching :focus
16
+
17
+ config.example_status_persistence_file_path = 'spec/examples.txt'
18
+
19
+ config.disable_monkey_patching!
20
+
21
+ config.warnings = true
22
+
23
+ config.default_formatter = 'doc' if config.files_to_run.one?
24
+
25
+ config.order = :random
26
+ Kernel.srand config.seed
27
+
28
+ # clear Unifg methods
29
+ config.before do
30
+ Unifig.methods(false).each do |name|
31
+ Unifig.singleton_class.remove_method(name)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ RSpec.describe Unifig::Providers::Env do
2
+ describe '.name' do
3
+ it 'returns the provider name' do
4
+ expect(described_class.name).to be :env
5
+ end
6
+ end
7
+
8
+ describe '.retrieve' do
9
+ before do
10
+ allow(ENV).to receive(:[]).and_return(nil)
11
+ allow(ENV).to receive(:[]).with('FOO').and_return('foo')
12
+ allow(ENV).to receive(:[]).with('BAR').and_return('bar')
13
+ end
14
+
15
+ it 'returns a hash of only the available vars' do
16
+ result = described_class.retrieve(%i[FOO BAR BAZ])
17
+
18
+ expect(result).to be_an_instance_of(Hash)
19
+ expect(result.keys.size).to be 2
20
+ expect(result[:FOO]).to eql 'foo'
21
+ expect(result[:BAR]).to eql 'bar'
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unifig-env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Lasseigne
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unifig
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ description: Adds a provider to support loading environment variables to Unifig.
28
+ email:
29
+ - aaron.lasseigne@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - CONTRIBUTING.md
36
+ - LICENSE.txt
37
+ - README.md
38
+ - lib/unifig/env.rb
39
+ - lib/unifig/env/version.rb
40
+ - lib/unifig/providers/env.rb
41
+ - spec/spec_helper.rb
42
+ - spec/unifig/providers/env_spec.rb
43
+ homepage: https://github.com/AaronLasseigne/unifig-env
44
+ licenses:
45
+ - MIT
46
+ metadata:
47
+ homepage_uri: https://github.com/AaronLasseigne/unifig-env
48
+ source_code_uri: https://github.com/AaronLasseigne/unifig-env
49
+ changelog_uri: https://github.com/AaronLasseigne/unifig-env/blob/main/CHANGELOG.md
50
+ rubygems_mfa_required: 'true'
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.7.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.3.7
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Adds a provider to support loading environment variables to Unifig.
70
+ test_files:
71
+ - spec/spec_helper.rb
72
+ - spec/unifig/providers/env_spec.rb