credentials_for_rails_env 1.0.0 → 1.0.1
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 +27 -2
- data/lib/credentials_for_rails_env/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78d5383e7b8cdd80b1f71e67458b4e011aefce866884f0097a19a319f3b740e7
|
4
|
+
data.tar.gz: 0f824a80f6efb86a5d84e96cc114f6d7d904d6de4e41128fcce9ca5a72a46673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6986fcd834221e93dd32415a4916ddeee1e665047817e53a1705462adc4c7cc2ba0dce206204f203b8ce4b80fc3ab37428de81bbb218cb28c53ce8010c8fd17f
|
7
|
+
data.tar.gz: 9f6bdb04342eaf6916602221110f0967fa7c36283ec80f8ed7f7004085997b7e715957fc1af53795d3987354dc7e3e378988da7d3183f5075ec00e86ca19d9c6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# CredentialsForRailsEnv
|
2
2
|
|
3
|
-
Now you can easily fetch different credentials for the each of your RAILS_ENV environments. The new Rails.application.credentials.env
|
3
|
+
Now you can easily fetch different credentials for the each of your RAILS_ENV environments. The new Rails.application.credentials.env object does the work for you. Here is a sample credentials file.
|
4
4
|
|
5
5
|
```yaml
|
6
6
|
$ EDITOR=vim rails credentials:edit
|
@@ -14,7 +14,7 @@ production:
|
|
14
14
|
foo: production foo
|
15
15
|
```
|
16
16
|
|
17
|
-
The new credentials.env
|
17
|
+
The new credentials.env object will return values from the RAILS_ENV slice of the credentials. For example when RAILS_ENV == "development":
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
Rails.application.credentials.env.foo => "development foo"
|
@@ -32,6 +32,31 @@ You can still call "Rails.application.credentials" as usual to see the global cr
|
|
32
32
|
Rails.application.credentials.foo => "global foo"
|
33
33
|
```
|
34
34
|
|
35
|
+
This works by extending ActiveSupport::EncryptedConfiguration to take an optional rails_env parameter.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
module Rails
|
39
|
+
class Application < Engine
|
40
|
+
def encrypted(path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY")
|
41
|
+
ActiveSupport::EncryptedConfiguration.new(
|
42
|
+
config_path: Rails.root.join(path),
|
43
|
+
key_path: Rails.root.join(key_path),
|
44
|
+
env_key: env_key,
|
45
|
+
raise_if_missing_key: config.require_master_key,
|
46
|
+
rails_env: Rails.env
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
You can use this interface to open any encrypted file and access the RAILS_ENV specific configuration values.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
my_credentials = Rails.application.encrypted("config/my_credentials.yml.enc")
|
57
|
+
my_bar = my_credentials.env.bar
|
58
|
+
```
|
59
|
+
|
35
60
|
## Installation
|
36
61
|
|
37
62
|
Add this line to your application's Gemfile:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credentials_for_rails_env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Gorman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|