r_creds 0.2.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 355bd57c7b2ef3d439272e1dae2a0a58d512a1901bbd0ceb8d0b444f4d53f28f
4
- data.tar.gz: '08cf613107791096f38dd13213267bb48fc7ab97b3ca5f2b5079a787bd0a7a66'
3
+ metadata.gz: 6dd1860431415700bcdb3c5cfe8249ab7e347148ef6eae93ba7abc5baac2e2d5
4
+ data.tar.gz: bc7d1438135385c86674116f2cb578d9bfd286a87b000023d97b63a2416370c9
5
5
  SHA512:
6
- metadata.gz: 1d5948ec954d7f0f0169879902295444f797ea6f09c84de104cd81da35320e1ee76865e2277137a6d934dcd28a17f1c50673d2ebcf86da26c7f0573c53a549a8
7
- data.tar.gz: e736f5120c567151ad481a89c3602f1189ad9a58502ae955606600042408419d03db988fdc6965c94fc8b5a68541cd16245ae43272834ad1488c4eac9e8349bc
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
- RCreds uses `Rails.env` to determinate environment. But you can set any environement.
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
 
@@ -22,7 +22,7 @@ module RCreds
22
22
  end
23
23
 
24
24
  def fetch
25
- cred = Rails.application.credentials.dig(environment, *keys)
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
@@ -1,3 +1,3 @@
1
1
  module RCreds
2
- VERSION = "0.2.1"
2
+ VERSION = "1.0.0"
3
3
  end
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.2.1
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-03-09 00:00:00.000000000 Z
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
- rubyforge_project:
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