kreds 1.1.7 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25d3eedf22bd754fdefe50c162f437fbced4417d1dc22170f7a63e950c5ccf27
4
- data.tar.gz: 21e488de4ad9d8f7777e5215e10709e2089cf65a97c43f075ccb23871dbf593d
3
+ metadata.gz: 0b4201b42666b2af466df309108cbdd034af995fe503a390517e7466a365047f
4
+ data.tar.gz: 99889e39b1ab9175ee93dbbde3ecaccacd0178c07062cf99cefb428f89a58ec6
5
5
  SHA512:
6
- metadata.gz: 94388daa3c0f6415135f437c4d76d2097492d7963e195bc038b5e1a6a2ae06838e60638234bd88c0aa51de87706ded1254fcb3627e6a4f561da882bb7a2191d3
7
- data.tar.gz: 80c30b05d7aca780b1d1b4eee7766516daf110885ebdc1e744189906032355a116b1e082d28783851e98312639d2b377ac3ef1a485a5df99a8b6255e16c36064
6
+ metadata.gz: dbd88cdfd58f5a9759999c79b34713d0c161b663f78a948a8f32b5ddf4f987eedb1e49e82956800b68b776f5fa6c79395b50251694bfa58ca84a3bebebdb1522
7
+ data.tar.gz: 2cc1444000ed81fa464ffef8037f68f915885015126be94e046c412cde0a9991be4622b4e8f2f06a54f7c7940b3d5e23016a413b55548ef3c9f5fb3832ef3568
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## v2.0.1
2
+
3
+ - Fixed `false` credential values being treated as blank
4
+ - Clarified the error message raised when no credentials keys are provided
5
+
6
+ ## v2.0.0
7
+
8
+ - Dropped support for Ruby 3.2
9
+ - Dropped support for Rails 7.1
10
+ - Improved error messages and input validation
11
+ - Added `Kreds.env_show` method
12
+ - `Kreds.env_fetch!` now raises `InvalidArgumentError` when called with no keys
13
+
1
14
  ## v1.1.7
2
15
 
3
16
  - Added support for Ruby 4
data/README.md CHANGED
@@ -24,10 +24,10 @@ Rails.application.credentials.fetch(:recaptcha).fetch(:key)
24
24
 
25
25
  # Kreds (clear, human-readable errors):
26
26
  Kreds.fetch!(:recaptcha, :site_key)
27
- # => Blank value in credentials: [:recaptcha][:site_key] (Kreds::BlankCredentialsError)
27
+ # => Blank value in credentials: :recaptcha => :site_key (Kreds::BlankCredentialsError)
28
28
 
29
29
  Kreds.fetch!(:recaptcha, :key)
30
- # => Credentials key not found: [:recaptcha][:key] (Kreds::UnknownCredentialsError)
30
+ # => Credentials key not found: :recaptcha => :key (Kreds::UnknownCredentialsError)
31
31
  ```
32
32
 
33
33
  ## Table of Contents
@@ -139,30 +139,44 @@ Useful for debugging and exploring available credentials in the Rails console.
139
139
 
140
140
  ```ruby
141
141
  Kreds.show
142
+ # => { production: { aws: { access_key_id: "...", secret_access_key: "..." } }, ... }
143
+ ```
144
+
145
+ **`Kreds.env_show`**
146
+
147
+ Like `show`, but scoped to the current Rails environment.
148
+
149
+ **Returns:** Hash containing credentials for `Rails.env`
150
+
151
+ ```ruby
152
+ # In production, returns credentials[:production]
153
+ Kreds.env_show
142
154
  # => { aws: { access_key_id: "...", secret_access_key: "..." }, ... }
143
155
  ```
144
156
 
145
157
  ## Getting Help and Contributing
146
158
 
147
159
  ### Getting Help
148
- Have a question or need assistance? Open a discussion in our [discussions section](https://github.com/enjaku4/kreds/discussions) for:
160
+
161
+ Have a question or need assistance? Open a discussion in the [discussions section](https://github.com/enjaku4/kreds/discussions) for:
162
+
149
163
  - Usage questions
150
164
  - Implementation guidance
151
- - Feature suggestions
165
+ - Open-ended ideas or suggestions
166
+
167
+ ### Issues
168
+
169
+ [Issues](https://github.com/enjaku4/kreds/issues) track bugs, planned features, and other work. When reporting a bug, please include:
152
170
 
153
- ### Reporting Issues
154
- Found a bug? Please [create an issue](https://github.com/enjaku4/kreds/issues) with:
155
171
  - A clear description of the problem
156
172
  - Steps to reproduce the issue
157
- - Your environment details (Rails version, Ruby version, etc.)
173
+ - Your environment details (Rails and Ruby versions, OS, etc.)
158
174
 
159
175
  ### Contributing Code
160
- Ready to contribute? You can:
161
- - Fix bugs by submitting pull requests
162
- - Improve documentation
163
- - Add new features (please discuss first in our [discussions section](https://github.com/enjaku4/kreds/discussions))
164
176
 
165
- Before contributing, please read the [contributing guidelines](https://github.com/enjaku4/kreds/blob/master/CONTRIBUTING.md)
177
+ Any open issue is free to pick up or discuss. Check the [project board](https://github.com/users/enjaku4/projects/14) or [issues tab](https://github.com/enjaku4/kreds/issues).
178
+
179
+ Before contributing, please read the [contributing guidelines](https://github.com/enjaku4/kreds/blob/master/CONTRIBUTING.md).
166
180
 
167
181
  ## License
168
182
 
data/kreds.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.summary = "The missing shorthand for Rails credentials"
17
17
  spec.description = "Simpler and safer Rails credentials access with blank value detection and clear error messages"
18
18
  spec.license = "MIT"
19
- spec.required_ruby_version = ">= 3.2", "< 4.1"
19
+ spec.required_ruby_version = ">= 3.3", "< 4.1"
20
20
 
21
21
  spec.files = [
22
22
  "kreds.gemspec", "README.md", "CHANGELOG.md", "LICENSE.txt"
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency "rails", ">= 7.1", "< 8.2"
27
+ spec.add_dependency "rails", ">= 7.2", "< 8.2"
28
28
  end
data/lib/kreds/fetch.rb CHANGED
@@ -14,7 +14,7 @@ module Kreds
14
14
  end
15
15
 
16
16
  def env_fetch!(*keys, var: nil, &)
17
- fetch!(Rails.env, *keys, var:, &)
17
+ fetch!(Rails.env, *Kreds::Inputs.process(keys, as: :symbol_array), var:, &)
18
18
  end
19
19
 
20
20
  def var!(var, &)
@@ -32,8 +32,8 @@ module Kreds
32
32
  def fetch_key(hash, key, path, keys)
33
33
  value = hash.fetch(key)
34
34
 
35
- raise Kreds::BlankCredentialsError, "Blank value in credentials: #{path_to_s(path)}" if value.blank?
36
- raise Kreds::UnknownCredentialsError, "Credentials key not found: #{path_to_s(path)}[:#{keys[path.size]}]" unless value.is_a?(Hash) || keys == path
35
+ raise Kreds::BlankCredentialsError, "Blank value in credentials: #{path_to_s(path)}" if value != false && value.blank?
36
+ raise Kreds::UnknownCredentialsError, "Credentials key not found: #{path_to_s(path.append(keys[path.size]))}" unless value.is_a?(Hash) || keys == path
37
37
 
38
38
  value
39
39
  rescue KeyError
@@ -41,7 +41,7 @@ module Kreds
41
41
  end
42
42
 
43
43
  def fallback_to_var(error, var, &)
44
- return raise_or_yield(error, &) if var.blank?
44
+ return raise_or_yield(error, &) if var.nil?
45
45
 
46
46
  var!(var, &)
47
47
  rescue Kreds::BlankEnvironmentVariableError, Kreds::UnknownEnvironmentVariableError => e
@@ -53,7 +53,7 @@ module Kreds
53
53
  end
54
54
 
55
55
  def path_to_s(path)
56
- "[:#{path.join("][:")}]"
56
+ path.map(&:inspect).join(" => ")
57
57
  end
58
58
  end
59
59
  end
data/lib/kreds/inputs.rb CHANGED
@@ -11,7 +11,9 @@ module Kreds
11
11
  private
12
12
 
13
13
  def symbol_array(value)
14
- return value.map(&:to_sym) if value.is_a?(Array) && value.any? && value.all? { _1.is_a?(String) || _1.is_a?(Symbol) }
14
+ raise(Kreds::InvalidArgumentError, "No credentials keys provided") if value == []
15
+
16
+ return value.map(&:to_sym) if value.is_a?(Array) && value.all? { _1.is_a?(String) || _1.is_a?(Symbol) }
15
17
 
16
18
  raise(Kreds::InvalidArgumentError, "Expected an array of symbols or strings, got `#{value.inspect}`")
17
19
  end
data/lib/kreds/show.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  module Kreds
2
2
  module Show
3
3
  def show
4
- Rails.application.credentials.as_json.deep_symbolize_keys
4
+ Rails.application.credentials.config.to_h
5
+ end
6
+
7
+ def env_show
8
+ show[Rails.env.to_sym] || {}
5
9
  end
6
10
  end
7
11
  end
data/lib/kreds/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kreds
2
- VERSION = "1.1.7".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kreds
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - enjaku4
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-07-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '7.1'
18
+ version: '7.2'
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '8.2'
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '7.1'
28
+ version: '7.2'
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: '8.2'
@@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '3.2'
67
+ version: '3.3'
68
68
  - - "<"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '4.1'
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.7.2
77
+ rubygems_version: 4.0.3
78
78
  specification_version: 4
79
79
  summary: The missing shorthand for Rails credentials
80
80
  test_files: []