deepenv 0.1.3

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: 5ee5b59ed782b1a726a3e9003e6714b2da8cc6eee055022f3f5b3835c41c6b5e
4
+ data.tar.gz: e39555f71189e65596d6f41e5f4f03a43d618a56ab8f55c7a5ae73195d7d62f6
5
+ SHA512:
6
+ metadata.gz: 803c07196975ff1722844841b6c2622b61a45d019d5b499916a4ffd0ff7927e4dde402e8487f0e5501bf2ee951397f26c2fdc9edb53daf0e54715065ae83d219
7
+ data.tar.gz: 7be0ae5a1c5f6bb0442f76ccbdb9476c980e7abe043bf4acdb5434f1e6a3422d809fadabe93df17d5bc03523da6a59965a5524695d581efe8c61fd5731a3afcf
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,2 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## [0.1.0] - 2021-12-24
2
+
3
+ - Initial release
4
+
5
+ ## [0.1.1] - 2022-01-08
6
+
7
+ - Uses the deep_enumerable gem instead of custom functions
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at renwooller@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in deepenv.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "standard", "~> 1.3"
13
+
14
+ gem "deep_enumerable", "~> 0.1.4"
15
+
16
+ group :development do
17
+ gem 'guard-rspec', require: false
18
+ gem 'solargraph'
19
+ gem 'ruby-debug-ide'
20
+ gem 'debase', "~> 0.2.5.beta2"
21
+ end
22
+
data/Gemfile.lock ADDED
@@ -0,0 +1,138 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ deepenv (0.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ backport (1.2.0)
11
+ benchmark (0.2.0)
12
+ coderay (1.1.3)
13
+ debase (0.2.5.beta2)
14
+ debase-ruby_core_source (>= 0.10.12)
15
+ debase-ruby_core_source (0.10.14)
16
+ deep_enumerable (0.1.4)
17
+ diff-lcs (1.5.0)
18
+ e2mmap (0.1.0)
19
+ ffi (1.15.4)
20
+ formatador (0.3.0)
21
+ guard (2.18.0)
22
+ formatador (>= 0.2.4)
23
+ listen (>= 2.7, < 4.0)
24
+ lumberjack (>= 1.0.12, < 2.0)
25
+ nenv (~> 0.1)
26
+ notiffany (~> 0.0)
27
+ pry (>= 0.13.0)
28
+ shellany (~> 0.0)
29
+ thor (>= 0.18.1)
30
+ guard-compat (1.2.1)
31
+ guard-rspec (4.7.3)
32
+ guard (~> 2.1)
33
+ guard-compat (~> 1.1)
34
+ rspec (>= 2.99.0, < 4.0)
35
+ jaro_winkler (1.5.4)
36
+ kramdown (2.3.1)
37
+ rexml
38
+ kramdown-parser-gfm (1.1.0)
39
+ kramdown (~> 2.0)
40
+ listen (3.7.0)
41
+ rb-fsevent (~> 0.10, >= 0.10.3)
42
+ rb-inotify (~> 0.9, >= 0.9.10)
43
+ lumberjack (1.2.8)
44
+ method_source (1.0.0)
45
+ nenv (0.3.0)
46
+ nokogiri (1.12.5-x86_64-darwin)
47
+ racc (~> 1.4)
48
+ notiffany (0.1.3)
49
+ nenv (~> 0.1)
50
+ shellany (~> 0.0)
51
+ parallel (1.21.0)
52
+ parser (3.1.0.0)
53
+ ast (~> 2.4.1)
54
+ pry (0.14.1)
55
+ coderay (~> 1.1)
56
+ method_source (~> 1.0)
57
+ racc (1.6.0)
58
+ rainbow (3.0.0)
59
+ rake (13.0.6)
60
+ rb-fsevent (0.11.0)
61
+ rb-inotify (0.10.1)
62
+ ffi (~> 1.0)
63
+ regexp_parser (2.2.0)
64
+ reverse_markdown (2.1.1)
65
+ nokogiri
66
+ rexml (3.2.5)
67
+ rspec (3.10.0)
68
+ rspec-core (~> 3.10.0)
69
+ rspec-expectations (~> 3.10.0)
70
+ rspec-mocks (~> 3.10.0)
71
+ rspec-core (3.10.1)
72
+ rspec-support (~> 3.10.0)
73
+ rspec-expectations (3.10.1)
74
+ diff-lcs (>= 1.2.0, < 2.0)
75
+ rspec-support (~> 3.10.0)
76
+ rspec-mocks (3.10.2)
77
+ diff-lcs (>= 1.2.0, < 2.0)
78
+ rspec-support (~> 3.10.0)
79
+ rspec-support (3.10.3)
80
+ rubocop (1.23.0)
81
+ parallel (~> 1.10)
82
+ parser (>= 3.0.0.0)
83
+ rainbow (>= 2.2.2, < 4.0)
84
+ regexp_parser (>= 1.8, < 3.0)
85
+ rexml
86
+ rubocop-ast (>= 1.12.0, < 2.0)
87
+ ruby-progressbar (~> 1.7)
88
+ unicode-display_width (>= 1.4.0, < 3.0)
89
+ rubocop-ast (1.15.1)
90
+ parser (>= 3.0.1.1)
91
+ rubocop-performance (1.12.0)
92
+ rubocop (>= 1.7.0, < 2.0)
93
+ rubocop-ast (>= 0.4.0)
94
+ ruby-debug-ide (0.7.3)
95
+ rake (>= 0.8.1)
96
+ ruby-progressbar (1.11.0)
97
+ shellany (0.0.1)
98
+ solargraph (0.44.2)
99
+ backport (~> 1.2)
100
+ benchmark
101
+ bundler (>= 1.17.2)
102
+ diff-lcs (~> 1.4)
103
+ e2mmap
104
+ jaro_winkler (~> 1.5)
105
+ kramdown (~> 2.3)
106
+ kramdown-parser-gfm (~> 1.1)
107
+ parser (~> 3.0)
108
+ reverse_markdown (>= 1.0.5, < 3)
109
+ rubocop (>= 0.52)
110
+ thor (~> 1.0)
111
+ tilt (~> 2.0)
112
+ yard (~> 0.9, >= 0.9.24)
113
+ standard (1.5.0)
114
+ rubocop (= 1.23.0)
115
+ rubocop-performance (= 1.12.0)
116
+ thor (1.1.0)
117
+ tilt (2.0.10)
118
+ unicode-display_width (2.1.0)
119
+ webrick (1.7.0)
120
+ yard (0.9.27)
121
+ webrick (~> 1.7.0)
122
+
123
+ PLATFORMS
124
+ x86_64-darwin-20
125
+
126
+ DEPENDENCIES
127
+ debase (~> 0.2.5.beta2)
128
+ deep_enumerable (~> 0.1.4)
129
+ deepenv!
130
+ guard-rspec
131
+ rake (~> 13.0)
132
+ rspec (~> 3.0)
133
+ ruby-debug-ide
134
+ solargraph
135
+ standard (~> 1.3)
136
+
137
+ BUNDLED WITH
138
+ 2.2.32
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Rene
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,68 @@
1
+ # Deepenv
2
+
3
+ [Best practice](https://12factor.net/config) demands that configuration that changes across environments should be contained in the environment rather than in code. This helps with security, managing environments, portability and open-source development.
4
+
5
+ Unfortunately environment variables are **flat** string key-value pairs, whereas most apps organise their configuration in **deeply nested** objects. Environment variable names cannot include symbols to indicate nesting.
6
+
7
+ This means backend developers have to take environment variables such as
8
+ ```bash
9
+ MYAPP_MYDATASTORE_CONNECTION_RETRY_INTERVAL=5s
10
+ ```
11
+
12
+ are manually wire them into the configuration object.
13
+
14
+ Deepenv makes this a lot simpler. EG including deepenv like so:
15
+
16
+ ```Ruby
17
+ require "deepenv"
18
+
19
+ module MyApp
20
+ # ...
21
+ class Application < Rails::Application
22
+ # ...
23
+ config.deepenv = Deepenv.to_config()
24
+ print config.deepenv
25
+ end
26
+ end
27
+ ```
28
+
29
+ And executing with some double underscore environment variables EG:
30
+
31
+ ```bash
32
+ DEEPENV_A__B__C=20 DEEPENV_A__X__Y=ardvark bin/rails server
33
+ ```
34
+
35
+ Shows the deep configuration automatically generated from the environment:
36
+
37
+ ```Ruby
38
+ {:a=>{:b=>{:c=>20}, :x=>{:y=>"ardvark"}}}
39
+ ```
40
+
41
+ ## Installation
42
+
43
+ Add the deepenv gem:
44
+
45
+ $ bundle add deepenv
46
+
47
+ this adds deepenv to your Gemfile and runs bundle install
48
+ ## Usage
49
+
50
+
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/deepenv. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/deepenv/blob/master/CODE_OF_CONDUCT.md).
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
65
+
66
+ ## Code of Conduct
67
+
68
+ Everyone interacting in the Deepenv project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/deepenv/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "deepenv"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/deepenv.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/deepenv/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "deepenv"
7
+ spec.version = Deepenv::VERSION
8
+ spec.authors = ["Rene"]
9
+ spec.email = ["renwooller@gmail.com"]
10
+
11
+ spec.summary = "Generates a deeply nested configuration object suitable for backend apps, using environment variables."
12
+ #spec.description = ""
13
+ spec.homepage = "https://github.com/renewooller/deepenv-rb"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/renewooller/deepenv-rb"
21
+ spec.metadata["changelog_uri"] = "https://github.com/renewooller/deepenv-rb/blob/main/CHANGELOG.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+
37
+ # For more information and examples about making a new gem, checkout our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module Deepenv
3
+ VERSION = "0.1.3"
4
+ end
data/lib/deepenv.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ require 'deep_enumerable'
3
+ require_relative "deepenv/version"
4
+
5
+ module Deepenv
6
+ class Error < StandardError; end
7
+
8
+
9
+ class << self
10
+
11
+ def to_config (original={}, opts={})
12
+ @@prefix = opts.fetch(:prefix, "DEEPENV_")
13
+ @@nesting_delimiter = opts.fetch(:nesting_delimiter, '__').downcase
14
+
15
+ ENV.filter {|k| k.start_with? @@prefix}
16
+ .map {|k, v| [k, parse_env_value(v)]}
17
+ .each_with_object(
18
+ original.deep_dup()
19
+ ) do |kv,hash|
20
+ hash.deep_set(
21
+ kv[0].dup
22
+ .downcase!
23
+ .sub(/^#{Regexp.escape(@@prefix.downcase)}/, '')
24
+ .split(@@nesting_delimiter).map(&:to_sym),
25
+ kv[1]
26
+ )
27
+ end
28
+ end
29
+
30
+ def parse_env_value(val_in)
31
+ val = val_in.strip
32
+ if /^ +$/ =~ val_in then # if one ore more whitespaces only, assume it's on purpose
33
+ val_in
34
+ elsif val === '' then # blank goes to nil
35
+ nil
36
+ elsif val === 'null' then # return null as string so as not to be parsed by json later
37
+ val
38
+ elsif /^\d+\.\d+$/ =~ val
39
+ val.to_f
40
+ elsif /^\d+$/ =~ val
41
+ val.to_i
42
+ elsif /^true$/i =~ val
43
+ true
44
+ elsif /^false$/i =~ val
45
+ false
46
+ else
47
+ begin
48
+ JSON.parse(val)
49
+ rescue
50
+ val
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deepenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Rene
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - renwooller@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".standard.yml"
22
+ - CHANGELOG.md
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - Guardfile
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - bin/console
31
+ - bin/setup
32
+ - deepenv.gemspec
33
+ - lib/deepenv.rb
34
+ - lib/deepenv/version.rb
35
+ homepage: https://github.com/renewooller/deepenv-rb
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ homepage_uri: https://github.com/renewooller/deepenv-rb
40
+ source_code_uri: https://github.com/renewooller/deepenv-rb
41
+ changelog_uri: https://github.com/renewooller/deepenv-rb/blob/main/CHANGELOG.md
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.6.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.2.32
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Generates a deeply nested configuration object suitable for backend apps,
61
+ using environment variables.
62
+ test_files: []