cre 2 → 2.1.0
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 +4 -4
- data/README.md +9 -1
- data/lib/cre.rb +13 -5
- data/lib/cre/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf0ccab29a3078c0e4d71a116f3b3b62c462491979f04b4013383784dad9414e
|
4
|
+
data.tar.gz: f1b7b6f3ff7f326f9da48e011340ccbf45b8094b3388a8985aeb85c2f922b21f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c12abb3409d58f4237cbf0893f07bdecfeeb61e7546dde866fde4c8bcd4d62da744601a040cfdeb4a3448d5094d07032455cd3df6aa3fb880b5e86472d25dbe2
|
7
|
+
data.tar.gz: e1791a9e14e1cc4abeff3f6598d36b2c212cfc5f185a0d7774b8759fbc843cd2087eb4a16c3e248a131eb51370291db1689b9c5b5ee82040bfd869325218b7f3
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ Instead of going the long way:
|
|
11
11
|
## Usage
|
12
12
|
By default it uses the currently active rails environment.
|
13
13
|
Specify the environment specifically by adding it as the first argument.
|
14
|
+
But do remember that it only considers `defined environments` in `config/environments`
|
14
15
|
|
15
16
|
`Cre.dig(:production, :password)`
|
16
17
|
|
@@ -25,6 +26,14 @@ development:
|
|
25
26
|
test:
|
26
27
|
aws_key: 'somekeytest'
|
27
28
|
password: 'fakepass'
|
29
|
+
```
|
30
|
+
It also supports deeper nested credentials for example:
|
31
|
+
```
|
32
|
+
Cre.dig(:production, :aws, :client, secret, :key)
|
33
|
+
```
|
34
|
+
Or:
|
35
|
+
```
|
36
|
+
Cre.dig(:something, :nested, :multiple, :layers, :deep)
|
28
37
|
```
|
29
38
|
## Installation
|
30
39
|
Add this line to your application's Gemfile:
|
@@ -44,7 +53,6 @@ $ gem install cre
|
|
44
53
|
```
|
45
54
|
|
46
55
|
##Todo:
|
47
|
-
- Add support for more and less levels of nesting.
|
48
56
|
- Exeption handeling
|
49
57
|
|
50
58
|
## Contributing
|
data/lib/cre.rb
CHANGED
@@ -13,10 +13,18 @@ module Cre
|
|
13
13
|
# The dig method here is just an aesthetic thing to keep us in context.
|
14
14
|
# TODO: Add support for deeply nested credentials.
|
15
15
|
|
16
|
-
def self.dig(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def self.dig(*credentials)
|
17
|
+
env, credentials = if defined_environments.include? credentials[0].to_sym
|
18
|
+
[credentials[0].to_sym, credentials[1..-1].flatten.map(&:to_sym)]
|
19
|
+
else
|
20
|
+
[Rails.env.to_sym, [credentials].flatten.map(&:to_sym)]
|
21
|
+
end
|
22
|
+
Rails.application.credentials.dig(env, *credentials)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.defined_environments
|
28
|
+
Dir.entries(Rails.root.join('config','environments').to_s).grep(/\.rb$/).map{ |filename| File.basename(filename, '.rb').to_sym }
|
21
29
|
end
|
22
30
|
end
|
data/lib/cre/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khalil Gharbaoui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -143,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.7.7
|
146
|
+
rubygems_version: 3.0.8
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: Fetch rails credentials the easy way!
|