r_creds 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/r_creds/fetcher.rb +23 -2
- data/lib/r_creds/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: 6dd1860431415700bcdb3c5cfe8249ab7e347148ef6eae93ba7abc5baac2e2d5
|
4
|
+
data.tar.gz: bc7d1438135385c86674116f2cb578d9bfd286a87b000023d97b63a2416370c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '03859241069cfdf516736ea7c5ec7c4642044bf3f198c85878197691d392b19440bc97fca15809e663bf4d99c05daecd89636db73f8549fb9977fe7b07c6fb95'
|
7
|
+
data.tar.gz: 9e924fd9095f29ceb92c2109b782110d88c3df2f7fe293e6e29fc390008f042afd3084ab314d5cd9cc7cb4b8f421a9556dd818d4455c4792b6bf0f3bbda847f2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# RCreds
|
1
|
+
# RCreds v1.0.0
|
2
2
|
|
3
|
-
RCreds makes working with Rails 5.2 credentials easier
|
3
|
+
RCreds makes working with Rails 5.2/6.0 credentials easier
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -42,10 +42,14 @@ RCreds.fetch(:aws, :access_key_id, default: 'some_default_test_key') # output: s
|
|
42
42
|
```
|
43
43
|
RCreds searches for values in following order: credentials.yml > ENV > default and returns nil if nothing match
|
44
44
|
|
45
|
-
|
45
|
+
# DEPRECATED
|
46
|
+
`Rails 6 loads only one specific environment credentials and does not allow to cahnge it.`
|
47
|
+
|
48
|
+
RCreds uses `Rails.env` to determinate environment. But you can set any environment.
|
46
49
|
```ruby
|
47
50
|
RCreds.fetch(:aws, :access_key_id, environment: 'production')
|
48
51
|
```
|
52
|
+
`Will be removed in next version`
|
49
53
|
|
50
54
|
## Development
|
51
55
|
|
data/lib/r_creds/fetcher.rb
CHANGED
@@ -22,7 +22,7 @@ module RCreds
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def fetch
|
25
|
-
cred =
|
25
|
+
cred = send("fetch_rails_#{@rails_version}")
|
26
26
|
|
27
27
|
presence?(cred) || presence?(ENV[keys.join('_').upcase]) || default
|
28
28
|
end
|
@@ -41,10 +41,31 @@ module RCreds
|
|
41
41
|
cred.respond_to?(:empty?) ? !!cred.empty? : !cred
|
42
42
|
end
|
43
43
|
|
44
|
+
def fetch_rails_5
|
45
|
+
Rails.application.credentials.dig(environment, *keys)
|
46
|
+
end
|
47
|
+
|
48
|
+
def fetch_rails_6
|
49
|
+
if rails6_multi_env?
|
50
|
+
puts "WARNING! Environment choice does not work in Rails 6. Fetching credentials for '#{Rails.env}'" if presence?(@environment)
|
51
|
+
Rails.application.credentials.dig(*keys)
|
52
|
+
else
|
53
|
+
Rails.application.credentials.dig(environment, *keys)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def rails6_multi_env?
|
58
|
+
Rails.application.credentials.content_path.basename.to_s != 'credentials.yml.enc'
|
59
|
+
end
|
60
|
+
|
44
61
|
def check_rails
|
45
|
-
return true if defined?(::Rails)
|
62
|
+
return define_rails_strategy && true if defined?(::Rails)
|
46
63
|
|
47
64
|
raise NoRailsError.new 'RCreds works with 5.2 and above'
|
48
65
|
end
|
66
|
+
|
67
|
+
def define_rails_strategy
|
68
|
+
@rails_version = Rails.version.to_i
|
69
|
+
end
|
49
70
|
end
|
50
71
|
end
|
data/lib/r_creds/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_creds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OrestF
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
87
|
-
rubygems_version: 2.7.7
|
86
|
+
rubygems_version: 3.0.1
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: RCreds makes working with Rails 5.2 credentials easier
|