credentials_for_rails_env 1.0.1 → 2.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: 78d5383e7b8cdd80b1f71e67458b4e011aefce866884f0097a19a319f3b740e7
4
- data.tar.gz: 0f824a80f6efb86a5d84e96cc114f6d7d904d6de4e41128fcce9ca5a72a46673
3
+ metadata.gz: 8d4baa163cf9728a3bb695b0b6ca6285946da9317c2073c9e6ca42996637a86b
4
+ data.tar.gz: 0cf7b53577839548b6dba8d1ce9954aad1d50ee154fe731c58f05470b71aa980
5
5
  SHA512:
6
- metadata.gz: 6986fcd834221e93dd32415a4916ddeee1e665047817e53a1705462adc4c7cc2ba0dce206204f203b8ce4b80fc3ab37428de81bbb218cb28c53ce8010c8fd17f
7
- data.tar.gz: 9f6bdb04342eaf6916602221110f0967fa7c36283ec80f8ed7f7004085997b7e715957fc1af53795d3987354dc7e3e378988da7d3183f5075ec00e86ca19d9c6
6
+ metadata.gz: 9c48591d067e32656bd0f4c3e4c54e0c26203a7b43ac57f52852218f82726db603ecdb9050814ebe312c4a9d2679dc837d8c56d91c7bf8438cf10f897d88f29f
7
+ data.tar.gz: 83f2af9737961f1c5291bc2919bf2c662c27c6fcd947f46a9b436039c9411e94daa04983bb8426b42feaadd37f3465256aab366166ace316572c1f78a8a02e8b
@@ -0,0 +1,210 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - '**/templates/**/*'
8
+ - '**/vendor/**/*'
9
+ - 'actionpack/lib/action_dispatch/journey/parser.rb'
10
+ - 'railties/test/fixtures/tmp/**/*'
11
+
12
+ Performance:
13
+ Exclude:
14
+ - '**/test/**/*'
15
+
16
+ Rails:
17
+ Enabled: true
18
+
19
+ # Prefer assert_not over assert !
20
+ Rails/AssertNot:
21
+ Include:
22
+ - '**/test/**/*'
23
+
24
+ # Prefer assert_not_x over refute_x
25
+ Rails/RefuteMethods:
26
+ Include:
27
+ - '**/test/**/*'
28
+
29
+ # Prefer &&/|| over and/or.
30
+ Style/AndOr:
31
+ Enabled: true
32
+
33
+ # Do not use braces for hash literals when they are the last argument of a
34
+ # method call.
35
+ Style/BracesAroundHashParameters:
36
+ Enabled: true
37
+ EnforcedStyle: context_dependent
38
+
39
+ # Align `when` with `case`.
40
+ Layout/CaseIndentation:
41
+ Enabled: true
42
+
43
+ # Align comments with method definitions.
44
+ Layout/CommentIndentation:
45
+ Enabled: true
46
+
47
+ Layout/ElseAlignment:
48
+ Enabled: true
49
+
50
+ # Align `end` with the matching keyword or starting expression except for
51
+ # assignments, where it should be aligned with the LHS.
52
+ Layout/EndAlignment:
53
+ Enabled: true
54
+ EnforcedStyleAlignWith: variable
55
+ AutoCorrect: true
56
+
57
+ Layout/EmptyLineAfterMagicComment:
58
+ Enabled: true
59
+
60
+ Layout/EmptyLinesAroundBlockBody:
61
+ Enabled: true
62
+
63
+ # In a regular class definition, no empty lines around the body.
64
+ Layout/EmptyLinesAroundClassBody:
65
+ Enabled: true
66
+
67
+ # In a regular method definition, no empty lines around the body.
68
+ Layout/EmptyLinesAroundMethodBody:
69
+ Enabled: true
70
+
71
+ # In a regular module definition, no empty lines around the body.
72
+ Layout/EmptyLinesAroundModuleBody:
73
+ Enabled: true
74
+
75
+ Layout/FirstParameterIndentation:
76
+ Enabled: true
77
+
78
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
79
+ Style/HashSyntax:
80
+ Enabled: true
81
+
82
+ # Method definitions after `private` or `protected` isolated calls need one
83
+ # extra level of indentation.
84
+ Layout/IndentationConsistency:
85
+ Enabled: true
86
+ EnforcedStyle: rails
87
+
88
+ # Two spaces, no tabs (for indentation).
89
+ Layout/IndentationWidth:
90
+ Enabled: true
91
+
92
+ Layout/LeadingCommentSpace:
93
+ Enabled: true
94
+
95
+ Layout/SpaceAfterColon:
96
+ Enabled: true
97
+
98
+ Layout/SpaceAfterComma:
99
+ Enabled: true
100
+
101
+ Layout/SpaceAroundEqualsInParameterDefault:
102
+ Enabled: true
103
+
104
+ Layout/SpaceAroundKeyword:
105
+ Enabled: true
106
+
107
+ Layout/SpaceAroundOperators:
108
+ Enabled: true
109
+
110
+ Layout/SpaceBeforeComma:
111
+ Enabled: true
112
+
113
+ Layout/SpaceBeforeFirstArg:
114
+ Enabled: true
115
+
116
+ Style/DefWithParentheses:
117
+ Enabled: true
118
+
119
+ # Defining a method with parameters needs parentheses.
120
+ Style/MethodDefParentheses:
121
+ Enabled: true
122
+
123
+ Style/FrozenStringLiteralComment:
124
+ Enabled: true
125
+ EnforcedStyle: always
126
+ Exclude:
127
+ - 'actionview/test/**/*.builder'
128
+ - 'actionview/test/**/*.ruby'
129
+ - 'actionpack/test/**/*.builder'
130
+ - 'actionpack/test/**/*.ruby'
131
+ - 'activestorage/db/migrate/**/*.rb'
132
+
133
+ # Use `foo {}` not `foo{}`.
134
+ Layout/SpaceBeforeBlockBraces:
135
+ Enabled: true
136
+
137
+ # Use `foo { bar }` not `foo {bar}`.
138
+ Layout/SpaceInsideBlockBraces:
139
+ Enabled: true
140
+
141
+ # Use `{ a: 1 }` not `{a:1}`.
142
+ Layout/SpaceInsideHashLiteralBraces:
143
+ Enabled: true
144
+
145
+ Layout/SpaceInsideParens:
146
+ Enabled: true
147
+
148
+ # Check quotes usage according to lint rule below.
149
+ Style/StringLiterals:
150
+ Enabled: true
151
+ EnforcedStyle: double_quotes
152
+
153
+ # Detect hard tabs, no hard tabs.
154
+ Layout/Tab:
155
+ Enabled: true
156
+
157
+ # Blank lines should not have any spaces.
158
+ Layout/TrailingBlankLines:
159
+ Enabled: true
160
+
161
+ # No trailing whitespace.
162
+ Layout/TrailingWhitespace:
163
+ Enabled: true
164
+
165
+ # Use quotes for string literals when they are enough.
166
+ Style/UnneededPercentQ:
167
+ Enabled: true
168
+
169
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
170
+ Lint/RequireParentheses:
171
+ Enabled: true
172
+
173
+ Lint/StringConversionInInterpolation:
174
+ Enabled: true
175
+
176
+ Lint/UriEscapeUnescape:
177
+ Enabled: true
178
+
179
+ Style/ParenthesesAroundCondition:
180
+ Enabled: true
181
+
182
+ Style/RedundantReturn:
183
+ Enabled: true
184
+ AllowMultipleReturnValues: true
185
+
186
+ Style/Semicolon:
187
+ Enabled: true
188
+ AllowAsExpressionSeparator: true
189
+
190
+ # Prefer Foo.method over Foo::method
191
+ Style/ColonMethodCall:
192
+ Enabled: true
193
+
194
+ Style/TrivialAccessors:
195
+ Enabled: true
196
+
197
+ Performance/FlatMap:
198
+ Enabled: true
199
+
200
+ Performance/RedundantMerge:
201
+ Enabled: true
202
+
203
+ Performance/StartWith:
204
+ Enabled: true
205
+
206
+ Performance/EndWith:
207
+ Enabled: true
208
+
209
+ Performance/RegexpMatch:
210
+ Enabled: true
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- credentials_for_rails_env (1.0.0)
4
+ credentials_for_rails_env (2.0)
5
5
  rails (~> 5.2)
6
6
 
7
7
  GEM
@@ -64,7 +64,7 @@ GEM
64
64
  nokogiri (>= 1.5.9)
65
65
  mail (2.7.0)
66
66
  mini_mime (>= 0.1.1)
67
- marcel (0.3.2)
67
+ marcel (0.3.3)
68
68
  mimemagic (~> 0.3.2)
69
69
  method_source (0.9.0)
70
70
  mimemagic (0.3.2)
data/README.md CHANGED
@@ -9,7 +9,7 @@ $ EDITOR=vim rails credentials:edit
9
9
  ```yaml
10
10
  foo: global foo
11
11
  development:
12
- foo: development foo
12
+ foo: <%= ["development", "foo"].join(" ") %>
13
13
  production:
14
14
  foo: production foo
15
15
  ```
@@ -24,7 +24,7 @@ Rails.application.credentials.env.fetch(:foo) => "development foo"
24
24
  Rails.application.credentials.env.config => { foo: "development foo" }
25
25
  ```
26
26
 
27
- This makes it very easy to migrate from the deprecated Rails 5.1 secrets convention to the new Rails 5.2 credentials convention. Just add the contents of your secrets file to your credentials file and replace all calls to "Rails.application.secrets" with calls to "Rails.application.credentials.env". Then you can delete your secrets files.
27
+ This makes it very easy to migrate from the deprecated Rails 5.1 encrypted secrets convention to the new Rails 5.2 credentials convention. Just add the contents of your secrets file to your credentials file and replace all calls to "Rails.application.secrets" with calls to "Rails.application.credentials.env". Then you can delete your secrets files.
28
28
 
29
29
  You can still call "Rails.application.credentials" as usual to see the global credentials view.
30
30
 
@@ -32,7 +32,7 @@ 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.
35
+ This works by extending ActiveSupport::EncryptedConfiguration to filter files with ERB to interpret "<%= ... %>" marks in ruby and to take an optional rails_env parameter.
36
36
 
37
37
  ```ruby
38
38
  module Rails
@@ -69,7 +69,7 @@ And then execute:
69
69
 
70
70
  $ bundle
71
71
 
72
- Or install it yourself as:
72
+ Or install it yourself:
73
73
 
74
74
  $ gem install credentials_for_rails_env
75
75
 
@@ -89,6 +89,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
89
89
 
90
90
  To install this gem onto your local machine, run `bundle exec rake install`.
91
91
 
92
+ ## Versions
93
+
94
+ ##### Version 0.1.0 2018-09-09
95
+
96
+ Provided Rails.application.credentials_env interface.
97
+
98
+ ##### Version 1.0.0 2018-09-13
99
+
100
+ Provided Rails.application.credentials.env interface.
101
+
102
+ ##### Version 2.0 2018-09-16
103
+
104
+ Implemented ERB filtering <%= :ruby %>.
105
+
92
106
  ## Contributing
93
107
 
94
108
  Bug reports and pull requests are welcome on GitHub at https://github.com/jgorman/credentials_for_rails_env.
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Convenient access to credentials[Rails.env][:foo]."
12
12
  spec.description =
13
13
  "Fetch the current RAILS_ENV specific credentials from" +
14
- " Rails.application.credentials_env.foo just like" +
14
+ " Rails.application.credentials.env.foo just like" +
15
15
  " Rails.application.secrets.foo."
16
16
  spec.homepage = "https://github.com/jgorman/credentials_for_rails_env"
17
17
  spec.license = "MIT"
@@ -1,14 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "yaml"
4
- require "active_support/encrypted_file"
5
- require "active_support/ordered_options"
6
- require "active_support/core_ext/object/inclusion"
7
- require "active_support/core_ext/module/delegation"
3
+ require "active_support/encrypted_configuration"
4
+ require "erb"
8
5
 
9
6
  module ActiveSupport
10
7
  class EncryptedConfiguration < EncryptedFile
11
-
12
8
  def initialize(config_path:, key_path:, env_key:, raise_if_missing_key:,
13
9
  rails_env: nil)
14
10
  super content_path: config_path, key_path: key_path,
@@ -16,20 +12,13 @@ module ActiveSupport
16
12
  @rails_env = rails_env
17
13
  end
18
14
 
19
- def write(contents)
20
- deserialize(contents)
21
- @config = @options = @env = nil # Reinitialize for changed content.
22
-
23
- super
24
- end
25
-
26
15
  class RailsEnv < BasicObject
27
16
  delegate :[], :fetch, to: :config
28
17
  delegate_missing_to :options
29
18
 
30
19
  def initialize(full_config, rails_env)
31
20
  @full_config = full_config || {}
32
- @rails_env = rails_env || ''
21
+ @rails_env = rails_env || ""
33
22
  end
34
23
 
35
24
  def config
@@ -45,5 +34,12 @@ module ActiveSupport
45
34
  def env
46
35
  @env ||= RailsEnv.new(config, @rails_env)
47
36
  end
37
+
38
+ private
39
+
40
+ def deserialize(config)
41
+ @config = @options = @env = nil # Reinitialize for changed content.
42
+ config.present? ? YAML.load(ERB.new(config).result, content_path) : {}
43
+ end
48
44
  end
49
45
  end
@@ -1,7 +1,5 @@
1
- # Rails.application.credentials.env fetches Rails.env slice of the credentials.
1
+ # frozen_string_literal: true
2
2
 
3
3
  require "credentials_for_rails_env/version"
4
- require "active_support/encrypted_configuration"
5
4
  require "active_support/encrypted_configuration_env"
6
- require "rails/application"
7
5
  require "rails/application_encrypted"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CredentialsForRailsEnv
2
- VERSION = "1.0.1"
4
+ VERSION = "2.0"
3
5
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/application"
1
4
 
2
5
  module Rails
3
6
  class Application < Engine
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.1
4
+ version: '2.0'
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-14 00:00:00.000000000 Z
11
+ date: 2018-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
- description: Fetch the current RAILS_ENV specific credentials from Rails.application.credentials_env.foo
83
+ description: Fetch the current RAILS_ENV specific credentials from Rails.application.credentials.env.foo
84
84
  just like Rails.application.secrets.foo.
85
85
  email:
86
86
  - johngorman2@gmail.com
@@ -90,6 +90,7 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
+ - ".rubocop.yml"
93
94
  - ".travis.yml"
94
95
  - Gemfile
95
96
  - Gemfile.lock