suzanne 0.1.3
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 +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +93 -0
- data/.ruby_version +1 -0
- data/.travis.yml +26 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +100 -0
- data/Guardfile +46 -0
- data/LICENSE.txt +21 -0
- data/Makefile +8 -0
- data/README.md +68 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/suzanne.rb +12 -0
- data/lib/suzanne/env.rb +89 -0
- data/lib/suzanne/env_reader.rb +77 -0
- data/lib/suzanne/version.rb +5 -0
- data/suzanne.gemspec +49 -0
- metadata +236 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8ca6c52d923dc2fe06e62af272942693681a667d136ac67f0216e58cd5e42e5e
|
|
4
|
+
data.tar.gz: c17705dad732dea1576672b76b8da9096f48e3b4c48e7c5baa8565714bbab662
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6b1b342a371f66efc247d9a123fd92b293567de14100c49c3680fbaad3374b46dd9770a79e61cef5d632131bd086298410bf84ee65e1b8badc554bc39125e9c3
|
|
7
|
+
data.tar.gz: af6c606cb129efaa3702b933b0c34984e9670f274f3b8a88065f20218c56fca2c7c7ca8872f2e55e64a95899350f04d0314bacd875b3cfd43e1167c23be5076d
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 2.7
|
|
6
|
+
|
|
7
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
8
|
+
Enabled: true
|
|
9
|
+
|
|
10
|
+
Layout/HeredocIndentation:
|
|
11
|
+
Enabled: true
|
|
12
|
+
|
|
13
|
+
Layout/LineLength:
|
|
14
|
+
Max: 80
|
|
15
|
+
|
|
16
|
+
Layout/MultilineArrayLineBreaks:
|
|
17
|
+
Enabled: true
|
|
18
|
+
|
|
19
|
+
Layout/MultilineHashKeyLineBreaks:
|
|
20
|
+
Enabled: true
|
|
21
|
+
|
|
22
|
+
# Enabled means "no space" around call operators
|
|
23
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
24
|
+
Enabled: true
|
|
25
|
+
|
|
26
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
27
|
+
Enabled: true
|
|
28
|
+
|
|
29
|
+
Lint/MixedRegexpCaptureTypes:
|
|
30
|
+
Enabled: true
|
|
31
|
+
|
|
32
|
+
Lint/StructNewOverride:
|
|
33
|
+
Enabled: true
|
|
34
|
+
|
|
35
|
+
# Meaning you cannot: raise Exception
|
|
36
|
+
Lint/RaiseException:
|
|
37
|
+
Enabled: true
|
|
38
|
+
|
|
39
|
+
Metrics/ClassLength:
|
|
40
|
+
Max: 110
|
|
41
|
+
|
|
42
|
+
# Would give us false positives on all private(*delegate)
|
|
43
|
+
Style/AccessModifierDeclarations:
|
|
44
|
+
Enabled: false
|
|
45
|
+
|
|
46
|
+
Style/RegexpLiteral:
|
|
47
|
+
EnforcedStyle: percent_r
|
|
48
|
+
|
|
49
|
+
Style/ClassAndModuleChildren:
|
|
50
|
+
Enabled: false
|
|
51
|
+
|
|
52
|
+
Style/DateTime:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
Style/Documentation:
|
|
56
|
+
Enabled: false
|
|
57
|
+
|
|
58
|
+
Style/ExponentialNotation:
|
|
59
|
+
Enabled: true
|
|
60
|
+
|
|
61
|
+
# Currently gives false positive with e.g. generator.date.strftime '%Y%m%d'
|
|
62
|
+
# https://github.com/bbatsov/rubocop/issues/5398
|
|
63
|
+
#
|
|
64
|
+
Style/FormatStringToken:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
Style/HashEachMethods:
|
|
68
|
+
Enabled: true
|
|
69
|
+
|
|
70
|
+
Style/HashTransformKeys:
|
|
71
|
+
Enabled: true
|
|
72
|
+
|
|
73
|
+
Style/HashTransformValues:
|
|
74
|
+
Enabled: true
|
|
75
|
+
|
|
76
|
+
Style/NumericPredicate:
|
|
77
|
+
EnforcedStyle: comparison
|
|
78
|
+
|
|
79
|
+
Style/RedundantRegexpCharacterClass:
|
|
80
|
+
Enabled: true
|
|
81
|
+
|
|
82
|
+
Style/RedundantRegexpEscape:
|
|
83
|
+
Enabled: true
|
|
84
|
+
|
|
85
|
+
Style/SlicingWithRange:
|
|
86
|
+
Enabled: true
|
|
87
|
+
|
|
88
|
+
# Metrics/ClassLength:
|
|
89
|
+
# Max: 250
|
|
90
|
+
|
|
91
|
+
Metrics/BlockLength:
|
|
92
|
+
Exclude:
|
|
93
|
+
- 'assertable.gemspec'
|
data/.ruby_version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.1
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
sudo: false
|
|
3
|
+
dist: xenial
|
|
4
|
+
language: ruby
|
|
5
|
+
cache: bundler
|
|
6
|
+
rvm:
|
|
7
|
+
- 2.6.6
|
|
8
|
+
- 2.7.0
|
|
9
|
+
- 2.7.1
|
|
10
|
+
before_install:
|
|
11
|
+
- gem install bundler -v 2.1.4
|
|
12
|
+
- bundle update --bundler
|
|
13
|
+
- bundle --version
|
|
14
|
+
- bundle
|
|
15
|
+
env:
|
|
16
|
+
- build_type=ruby
|
|
17
|
+
script:
|
|
18
|
+
- cat Gemfile.lock
|
|
19
|
+
- bundle exec rubocop -V
|
|
20
|
+
- bundle exec rubocop -S
|
|
21
|
+
- bundle exec rubocop -d
|
|
22
|
+
- RAILS_ENV=test bundle exec rake test
|
|
23
|
+
|
|
24
|
+
after_script:
|
|
25
|
+
- ps -ejf --forest
|
|
26
|
+
- ssh-agent -k
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at cedric.degremont@facilecomm.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
suzanne (0.1.3)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ansi (1.5.0)
|
|
10
|
+
ast (2.4.0)
|
|
11
|
+
builder (3.2.4)
|
|
12
|
+
byebug (11.1.3)
|
|
13
|
+
coderay (1.1.3)
|
|
14
|
+
docile (1.3.2)
|
|
15
|
+
ffi (1.13.0)
|
|
16
|
+
formatador (0.2.5)
|
|
17
|
+
guard (2.16.2)
|
|
18
|
+
formatador (>= 0.2.4)
|
|
19
|
+
listen (>= 2.7, < 4.0)
|
|
20
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
21
|
+
nenv (~> 0.1)
|
|
22
|
+
notiffany (~> 0.0)
|
|
23
|
+
pry (>= 0.9.12)
|
|
24
|
+
shellany (~> 0.0)
|
|
25
|
+
thor (>= 0.18.1)
|
|
26
|
+
guard-compat (1.2.1)
|
|
27
|
+
guard-minitest (2.4.6)
|
|
28
|
+
guard-compat (~> 1.2)
|
|
29
|
+
minitest (>= 3.0)
|
|
30
|
+
listen (3.2.1)
|
|
31
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
32
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
33
|
+
lumberjack (1.2.5)
|
|
34
|
+
method_source (1.0.0)
|
|
35
|
+
minitest (5.14.1)
|
|
36
|
+
minitest-reporters (1.4.2)
|
|
37
|
+
ansi
|
|
38
|
+
builder
|
|
39
|
+
minitest (>= 5.0)
|
|
40
|
+
ruby-progressbar
|
|
41
|
+
mocha (1.11.2)
|
|
42
|
+
nenv (0.3.0)
|
|
43
|
+
notiffany (0.1.3)
|
|
44
|
+
nenv (~> 0.1)
|
|
45
|
+
shellany (~> 0.0)
|
|
46
|
+
parallel (1.19.1)
|
|
47
|
+
parser (2.7.1.3)
|
|
48
|
+
ast (~> 2.4.0)
|
|
49
|
+
pry (0.13.1)
|
|
50
|
+
coderay (~> 1.1)
|
|
51
|
+
method_source (~> 1.0)
|
|
52
|
+
rainbow (3.0.0)
|
|
53
|
+
rake (12.3.3)
|
|
54
|
+
rb-fsevent (0.10.4)
|
|
55
|
+
rb-inotify (0.10.1)
|
|
56
|
+
ffi (~> 1.0)
|
|
57
|
+
regexp_parser (1.7.1)
|
|
58
|
+
rexml (3.2.4)
|
|
59
|
+
rubocop (0.85.1)
|
|
60
|
+
parallel (~> 1.10)
|
|
61
|
+
parser (>= 2.7.0.1)
|
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
63
|
+
regexp_parser (>= 1.7)
|
|
64
|
+
rexml
|
|
65
|
+
rubocop-ast (>= 0.0.3)
|
|
66
|
+
ruby-progressbar (~> 1.7)
|
|
67
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
68
|
+
rubocop-ast (0.0.3)
|
|
69
|
+
parser (>= 2.7.0.1)
|
|
70
|
+
rubocop-performance (1.6.1)
|
|
71
|
+
rubocop (>= 0.71.0)
|
|
72
|
+
ruby-progressbar (1.10.1)
|
|
73
|
+
shellany (0.0.1)
|
|
74
|
+
simplecov (0.18.5)
|
|
75
|
+
docile (~> 1.1)
|
|
76
|
+
simplecov-html (~> 0.11)
|
|
77
|
+
simplecov-html (0.12.2)
|
|
78
|
+
thor (1.0.1)
|
|
79
|
+
unicode-display_width (1.7.0)
|
|
80
|
+
|
|
81
|
+
PLATFORMS
|
|
82
|
+
ruby
|
|
83
|
+
|
|
84
|
+
DEPENDENCIES
|
|
85
|
+
bundler (~> 2.1, >= 2.1.4)
|
|
86
|
+
byebug (~> 11.1)
|
|
87
|
+
guard (~> 2.16)
|
|
88
|
+
guard-minitest (~> 2.4)
|
|
89
|
+
minitest (~> 5.0)
|
|
90
|
+
minitest-reporters (~> 1.4)
|
|
91
|
+
mocha (~> 1.11)
|
|
92
|
+
pry (~> 0.13)
|
|
93
|
+
rake (~> 12.0)
|
|
94
|
+
rubocop (~> 0.85)
|
|
95
|
+
rubocop-performance (~> 1.5)
|
|
96
|
+
simplecov (~> 0.18.5)
|
|
97
|
+
suzanne!
|
|
98
|
+
|
|
99
|
+
BUNDLED WITH
|
|
100
|
+
2.1.4
|
data/Guardfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'byebug'
|
|
4
|
+
|
|
5
|
+
# A sample Guardfile
|
|
6
|
+
# More info at https://github.com/guard/guard#readme
|
|
7
|
+
|
|
8
|
+
# Uncomment and set this to only include directories you want to watch
|
|
9
|
+
def check_dir_existence(dir)
|
|
10
|
+
return dir if Dir.exist?(dir)
|
|
11
|
+
|
|
12
|
+
UI.warning("Directory #{dir} does not exist")
|
|
13
|
+
false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
directories(
|
|
17
|
+
%w[lib test].select do |dir|
|
|
18
|
+
check_dir_existence(dir)
|
|
19
|
+
end
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
## Note: if you are using the `directories` clause above and you are not
|
|
23
|
+
## watching the project directory ('.'), then you will want to move
|
|
24
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
|
25
|
+
#
|
|
26
|
+
# $ mkdir config
|
|
27
|
+
# $ mv Guardfile config/
|
|
28
|
+
# $ ln -s config/Guardfile .
|
|
29
|
+
#
|
|
30
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
|
31
|
+
|
|
32
|
+
guard :minitest, all_on_start: false do
|
|
33
|
+
# with Minitest::Unit
|
|
34
|
+
watch(%r{^test/(.*)/?test_(.*)\.rb$})
|
|
35
|
+
watch(%r{^test/(.*)/?(.*)_test\.rb$})
|
|
36
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
|
37
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
|
38
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
|
39
|
+
|
|
40
|
+
# Rails 4
|
|
41
|
+
watch(%r{^lib/(.+)\.rb$}) do |m|
|
|
42
|
+
"test/lib/#{m[1]}_test.rb"
|
|
43
|
+
end
|
|
44
|
+
watch(%r{^test/.+_test\.rb$})
|
|
45
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
|
46
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Cedric Degremont
|
|
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/Makefile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Suzanne
|
|
2
|
+
|
|
3
|
+
A striped-down version of [Figaro](https://github.com/laserlemon/figaro),
|
|
4
|
+
allowing env variables to be managed through YAML files.
|
|
5
|
+
|
|
6
|
+
Currently meant to be used within a Rails project. Currently, like Figaro,
|
|
7
|
+
we assume that the config file is in 'config/application.yml'.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'suzanne'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
And then execute:
|
|
19
|
+
|
|
20
|
+
$ bundle install
|
|
21
|
+
|
|
22
|
+
Or install it yourself as:
|
|
23
|
+
|
|
24
|
+
$ gem install suzanne
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Define a YAML file:
|
|
29
|
+
```yaml
|
|
30
|
+
development:
|
|
31
|
+
super_secret_key: abcdef
|
|
32
|
+
|
|
33
|
+
test:
|
|
34
|
+
super_secret_key: fedcba
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Initialize Suzanne:
|
|
38
|
+
```ruby
|
|
39
|
+
require 'suzanne'
|
|
40
|
+
|
|
41
|
+
Rails.env
|
|
42
|
+
=> 'development'
|
|
43
|
+
Suzanne.env.super_secret_key
|
|
44
|
+
=> 'abcdef'
|
|
45
|
+
Suzanne.env.no_such_key
|
|
46
|
+
=> nil
|
|
47
|
+
```
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
Run `bundle exec rake test` to run the tests.
|
|
51
|
+
|
|
52
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
53
|
+
|
|
54
|
+
## Naming
|
|
55
|
+
In case you are wondering about the gem name => [The_Marriage_of_Figaro] https://en.wikipedia.org/wiki/The_Marriage_of_Figaro_(play).
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
58
|
+
|
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Facilecomm/suzanne. 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]/suzanne/blob/master/CODE_OF_CONDUCT.md).
|
|
60
|
+
|
|
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 Suzanne project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Facilecomm/suzanne/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
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 'suzanne'
|
|
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
data/lib/suzanne.rb
ADDED
data/lib/suzanne/env.rb
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'suzanne/env_reader'
|
|
4
|
+
|
|
5
|
+
module Suzanne
|
|
6
|
+
class Env
|
|
7
|
+
class NoConfigFileFound < StandardError; end
|
|
8
|
+
class NoSegmentFound < KeyError; end
|
|
9
|
+
class CouldNotParseConfigFile < RuntimeError; end
|
|
10
|
+
|
|
11
|
+
def self.rails
|
|
12
|
+
::Rails
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.root_relative_config_file_path
|
|
16
|
+
['config', 'application.yml'].freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
init_config_hash
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def env
|
|
24
|
+
@env ||= Suzanne::EnvReader.new(
|
|
25
|
+
env_config_hash
|
|
26
|
+
)
|
|
27
|
+
rescue KeyError
|
|
28
|
+
raise NoSegmentFound, "No segment found for #{rails.env}."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
attr_reader :config_hash
|
|
34
|
+
|
|
35
|
+
def init_config_hash
|
|
36
|
+
return if production?
|
|
37
|
+
|
|
38
|
+
init_from_file
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def init_from_file
|
|
42
|
+
check_config_file_exists
|
|
43
|
+
@config_hash = YAML.load_file(config_file_path)
|
|
44
|
+
check_config_hash
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def env_config_hash
|
|
48
|
+
return {} if production?
|
|
49
|
+
|
|
50
|
+
config_hash.fetch(
|
|
51
|
+
rails.env.to_s
|
|
52
|
+
)
|
|
53
|
+
rescue KeyError
|
|
54
|
+
raise NoSegmentFound, "No segment found for #{rails.env}."
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def check_config_file_exists
|
|
58
|
+
return if config_file_exists?
|
|
59
|
+
|
|
60
|
+
raise NoConfigFileFound
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def check_config_hash
|
|
64
|
+
return if config_hash.is_a?(Hash)
|
|
65
|
+
|
|
66
|
+
raise CouldNotParseConfigFile
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def config_file_exists?
|
|
70
|
+
File.exist? config_file_path
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def config_file_path
|
|
74
|
+
rails.root.join(*root_relative_config_file_path)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def root_relative_config_file_path
|
|
78
|
+
self.class.root_relative_config_file_path
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def production?
|
|
82
|
+
rails.env.production?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def rails
|
|
86
|
+
self.class.rails
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Suzanne
|
|
4
|
+
class EnvReader
|
|
5
|
+
class MissingKey < StandardError
|
|
6
|
+
def initialize(key)
|
|
7
|
+
super("Missing required configuration key: #{key.inspect}")
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# ENV takes priority over config_hash
|
|
12
|
+
def initialize(config_hash)
|
|
13
|
+
@env = config_hash.merge(ENV)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
'Suzanne env'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def inspect
|
|
21
|
+
'Suzanne env'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def respond_to?(method, *)
|
|
25
|
+
key, punctuation = extract_key_from_method(method)
|
|
26
|
+
|
|
27
|
+
return true if punctuation == '?'
|
|
28
|
+
return (key?(key) || super) if punctuation == '!'
|
|
29
|
+
|
|
30
|
+
true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
attr_reader :env
|
|
36
|
+
|
|
37
|
+
def method_missing(method, *)
|
|
38
|
+
key, punctuation = extract_key_from_method(method)
|
|
39
|
+
|
|
40
|
+
return fetch_key!(key) if punctuation == '!'
|
|
41
|
+
return !!send(key) if punctuation == '?'
|
|
42
|
+
return get_value(key) if key && !punctuation
|
|
43
|
+
rescue NoMethodError
|
|
44
|
+
super
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def respond_to_missing?(method, *)
|
|
48
|
+
key, punctuation = extract_key_from_method(method)
|
|
49
|
+
|
|
50
|
+
return (key?(key) || super) if punctuation == '!'
|
|
51
|
+
return true if punctuation == '?'
|
|
52
|
+
|
|
53
|
+
true
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def fetch_key!(key)
|
|
57
|
+
send(key) || missing_key!(key)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def extract_key_from_method(method)
|
|
61
|
+
method.to_s.downcase.match(%r{^(.+?)([!?=])?$}).captures
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def key?(key)
|
|
65
|
+
env.any? { |k, _| k.downcase == key }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def missing_key!(key)
|
|
69
|
+
raise MissingKey.new(key) # rubocop:disable Style/RaiseArgs
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def get_value(key)
|
|
73
|
+
_, value = env.detect { |k, _v| k.downcase == key }
|
|
74
|
+
value
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
data/suzanne.gemspec
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/suzanne/version'
|
|
4
|
+
|
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'suzanne'
|
|
8
|
+
spec.version = Suzanne::VERSION
|
|
9
|
+
spec.authors = ['Shippingbo']
|
|
10
|
+
spec.email = ['tech@facilecomm.com']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'File-based env variables management'
|
|
13
|
+
spec.description = 'Minimal Figaro-style env variables management'
|
|
14
|
+
spec.homepage = 'https://github.com/Facilecomm/suzanne'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
|
17
|
+
|
|
18
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
19
|
+
|
|
20
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
|
21
|
+
# spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
|
|
22
|
+
# spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
|
|
23
|
+
|
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
|
25
|
+
# The `git ls-files -z` loads the files
|
|
26
|
+
# in the RubyGem that have been added into git.
|
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
28
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
29
|
+
f.match(%r{^(test|spec|features)/})
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
spec.bindir = 'exe'
|
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
34
|
+
spec.require_paths = ['lib']
|
|
35
|
+
|
|
36
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
|
37
|
+
spec.add_development_dependency 'byebug', '~> 11.1'
|
|
38
|
+
spec.add_development_dependency 'guard', '~> 2.16'
|
|
39
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.4'
|
|
40
|
+
spec.add_development_dependency 'minitest', '~> 5.11'
|
|
41
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.4'
|
|
42
|
+
spec.add_development_dependency 'mocha', '~> 1.11'
|
|
43
|
+
spec.add_development_dependency 'pry', '~> 0.13'
|
|
44
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
45
|
+
spec.add_development_dependency 'rubocop', '~> 0.85'
|
|
46
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
|
47
|
+
spec.add_development_dependency 'simplecov', '~> 0.18.5'
|
|
48
|
+
end
|
|
49
|
+
# rubocop:enable Metrics/BlockLength
|
metadata
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: suzanne
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Shippingbo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.1'
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 2.1.4
|
|
23
|
+
type: :development
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '2.1'
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 2.1.4
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: byebug
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '11.1'
|
|
40
|
+
type: :development
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '11.1'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: guard
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.16'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '2.16'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: guard-minitest
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '2.4'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '2.4'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: minitest
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '5.11'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '5.11'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: minitest-reporters
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '1.4'
|
|
96
|
+
type: :development
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '1.4'
|
|
103
|
+
- !ruby/object:Gem::Dependency
|
|
104
|
+
name: mocha
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '1.11'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '1.11'
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: pry
|
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0.13'
|
|
124
|
+
type: :development
|
|
125
|
+
prerelease: false
|
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0.13'
|
|
131
|
+
- !ruby/object:Gem::Dependency
|
|
132
|
+
name: rake
|
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - "~>"
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '13.0'
|
|
138
|
+
type: :development
|
|
139
|
+
prerelease: false
|
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - "~>"
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '13.0'
|
|
145
|
+
- !ruby/object:Gem::Dependency
|
|
146
|
+
name: rubocop
|
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - "~>"
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '0.85'
|
|
152
|
+
type: :development
|
|
153
|
+
prerelease: false
|
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - "~>"
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '0.85'
|
|
159
|
+
- !ruby/object:Gem::Dependency
|
|
160
|
+
name: rubocop-performance
|
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - "~>"
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '1.5'
|
|
166
|
+
type: :development
|
|
167
|
+
prerelease: false
|
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
169
|
+
requirements:
|
|
170
|
+
- - "~>"
|
|
171
|
+
- !ruby/object:Gem::Version
|
|
172
|
+
version: '1.5'
|
|
173
|
+
- !ruby/object:Gem::Dependency
|
|
174
|
+
name: simplecov
|
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
|
176
|
+
requirements:
|
|
177
|
+
- - "~>"
|
|
178
|
+
- !ruby/object:Gem::Version
|
|
179
|
+
version: 0.18.5
|
|
180
|
+
type: :development
|
|
181
|
+
prerelease: false
|
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
183
|
+
requirements:
|
|
184
|
+
- - "~>"
|
|
185
|
+
- !ruby/object:Gem::Version
|
|
186
|
+
version: 0.18.5
|
|
187
|
+
description: Minimal Figaro-style env variables management
|
|
188
|
+
email:
|
|
189
|
+
- tech@facilecomm.com
|
|
190
|
+
executables: []
|
|
191
|
+
extensions: []
|
|
192
|
+
extra_rdoc_files: []
|
|
193
|
+
files:
|
|
194
|
+
- ".gitignore"
|
|
195
|
+
- ".rubocop.yml"
|
|
196
|
+
- ".ruby_version"
|
|
197
|
+
- ".travis.yml"
|
|
198
|
+
- CODE_OF_CONDUCT.md
|
|
199
|
+
- Gemfile
|
|
200
|
+
- Gemfile.lock
|
|
201
|
+
- Guardfile
|
|
202
|
+
- LICENSE.txt
|
|
203
|
+
- Makefile
|
|
204
|
+
- README.md
|
|
205
|
+
- Rakefile
|
|
206
|
+
- bin/console
|
|
207
|
+
- bin/setup
|
|
208
|
+
- lib/suzanne.rb
|
|
209
|
+
- lib/suzanne/env.rb
|
|
210
|
+
- lib/suzanne/env_reader.rb
|
|
211
|
+
- lib/suzanne/version.rb
|
|
212
|
+
- suzanne.gemspec
|
|
213
|
+
homepage: https://github.com/Facilecomm/suzanne
|
|
214
|
+
licenses:
|
|
215
|
+
- MIT
|
|
216
|
+
metadata: {}
|
|
217
|
+
post_install_message:
|
|
218
|
+
rdoc_options: []
|
|
219
|
+
require_paths:
|
|
220
|
+
- lib
|
|
221
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
222
|
+
requirements:
|
|
223
|
+
- - ">="
|
|
224
|
+
- !ruby/object:Gem::Version
|
|
225
|
+
version: 2.6.0
|
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
|
+
requirements:
|
|
228
|
+
- - ">="
|
|
229
|
+
- !ruby/object:Gem::Version
|
|
230
|
+
version: '0'
|
|
231
|
+
requirements: []
|
|
232
|
+
rubygems_version: 3.0.1
|
|
233
|
+
signing_key:
|
|
234
|
+
specification_version: 4
|
|
235
|
+
summary: File-based env variables management
|
|
236
|
+
test_files: []
|