garofi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +37 -0
- data/lib/garofi.rb +38 -0
- data/lib/garofi/railtie.rb +7 -0
- data/lib/garofi/version.rb +3 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09129dce6393d83714a4cfce93e4f4824f6531cb5cba340602cad088f4a32783'
|
4
|
+
data.tar.gz: 0fcad2d86881dbc0cd530c90430377e1d5f2f27ad8f01a6d3e41560e400e83fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd3869db60345dca441e80f4a8b9ffee388c8ecabc4bdc29e2103049ef633e7d909990a2df212bae5d4db06b4b80fbe17a820fa17dfdda6524cc7099b5e2b44b
|
7
|
+
data.tar.gz: f96d97adb42bb2d926e36fc2439d1ade3414d166932f59890a1dd20a636d6db86f1dae0cbd761538832feda6c277210cc1fba85c94d5998537f0488025b44bd3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Florent Beaurain
|
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,37 @@
|
|
1
|
+
# Garofi
|
2
|
+
|
3
|
+
A modest environment variables loader
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application’s Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'garofi'
|
11
|
+
```
|
12
|
+
|
13
|
+
And run:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## How It Works
|
20
|
+
|
21
|
+
1. Garofi will load the environment variable defined in `config/application.yml` into your ENV
|
22
|
+
|
23
|
+
2. Use Ruby methods to access them:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ENV['REDIS_URL']
|
27
|
+
ENV.fetch('DATABASE_URL')
|
28
|
+
```
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
33
|
+
|
34
|
+
- Report [bugs](https://github.com/beauraF/garofi/issues)
|
35
|
+
- Fix bugs and submit [pull requests](https://github.com/beauraF/garofi/pulls)
|
36
|
+
- Write, clarify, or fix documentation
|
37
|
+
- Suggest or add new features
|
data/lib/garofi.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'erb'
|
5
|
+
require_relative 'garofi/version'
|
6
|
+
|
7
|
+
module Garofi
|
8
|
+
CONFIGURATION_PATH = 'config/application.yml'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def load
|
12
|
+
read_configuration
|
13
|
+
set_global_configuration
|
14
|
+
set_environment_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def read_configuration
|
20
|
+
@configuration = ::YAML.load(
|
21
|
+
ERB.new(File.read(CONFIGURATION_PATH)).result
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_global_configuration
|
26
|
+
@configuration.each do |key, value|
|
27
|
+
next if value.is_a?(Hash)
|
28
|
+
ENV[key] = value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_environment_configuration
|
33
|
+
@configuration.fetch(::Rails.env, {}).each { |key, value| ENV[key] = value }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
require_relative 'garofi/railtie'
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: garofi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florent Beaurain
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: beaurain.florent@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/garofi.rb
|
22
|
+
- lib/garofi/railtie.rb
|
23
|
+
- lib/garofi/version.rb
|
24
|
+
homepage: https://github.com/beauraF/garofi
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.6'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubygems_version: 3.2.3
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: A modest environment variables loader
|
47
|
+
test_files: []
|