secvault 2.1.0 → 2.3.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: 2c2c9db7124c8ac60bf772bcb42c1367f9e5a25a72c977aecc717da47ec401e8
4
- data.tar.gz: a8a46d584bf49e2ec7ca1bbfc9609c64b25642406a55efaf79f7f8e5eeeccbba
3
+ metadata.gz: 441940b63b8d897f1ad3b84bf43168d20dcbf62017a604e201538cee0315a7ca
4
+ data.tar.gz: fdd75a75105b0c34efb26096499ec6ffeac7340a170d4f8fcb7188c3f0d4e3db
5
5
  SHA512:
6
- metadata.gz: 52ffd8869e91255f41bbf5bcba424efa8ccfd2a7ec3227c97a8430cd2a21ecbf816558a966ad68afeff611889085b91af765012a9c1529c27917b56cab9aceab
7
- data.tar.gz: 191341590209b60085ad54047813788e3bd809ad84791c7aacca546bbc9870a653ae6c6811bce083b8e187aae9d14f9d3bdb5b6c533b549dda356e917816828d
6
+ metadata.gz: 14fc56f53ff8729262cb5fa07bf2de96e908d7c4f6b00a1134ea2c86b3a433b220a24b3399ad43e97846cadd0bc79546780a4e0fce5318448497b62d5fba0714
7
+ data.tar.gz: 3e4c8387fa38263e3bf99436211b3eaadf6b3d7d2aa5ec483cc6b19fc9dcbcb9bd402b9099e800fcc8c6fb9fc09b8281875415fdd90570fbee6625d324706032
data/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.3.0] - 2025-09-22
4
+
5
+ ### Changed
6
+
7
+ - **Better method naming**: Renamed `setup_rails_71_integration!` to `setup_backward_compatibility_with_older_rails!`
8
+ - **More generic approach**: New method name works for any older Rails version, not just 7.1
9
+ - **Updated documentation**: README now uses "Older Rails Integration" instead of "Rails 7.1 Integration"
10
+ - **Clearer version support**: Documentation now shows "Rails 7.1 and older" for better clarity
11
+
12
+ ### Backward Compatibility
13
+
14
+ - ✅ **Old method name still works**: `setup_rails_71_integration!` is aliased to the new method
15
+ - ✅ **No breaking changes**: All existing code continues to work
16
+ - ✅ **Updated test apps**: Rails 7.1 test app uses the new, cleaner method name
17
+
18
+ ### Benefits
19
+
20
+ - **Future-proof naming**: Works for Rails 7.1, 7.0, 6.x, or any version with native secrets
21
+ - **Clearer intent**: Method name clearly indicates it's for backward compatibility
22
+ - **Better documentation**: More generic approach in README and code comments
23
+ - **Maintained compatibility**: Existing users don't need to change anything
24
+
25
+ ## [2.2.0] - 2025-09-22
26
+
27
+ ### Added
28
+
29
+ - **New simplified API**: `Rails::Secrets.load()` - cleaner method to load default config/secrets.yml
30
+ - **Enhanced README** with comprehensive examples for multiple files usage
31
+ - **Better documentation** showing how to parse custom files and multiple file merging
32
+ - **Backward compatibility aliases** - `parse_default` and `read` still work
33
+
34
+ ### Changed
35
+
36
+ - **Improved method naming**: `Rails::Secrets.load()` is now the preferred method over `parse_default()`
37
+ - **Enhanced documentation** in code with clear examples for single file, multiple files, and custom paths
38
+ - **Better README examples** showing advanced usage patterns
39
+
40
+ ### Examples Added
41
+
42
+ - Multiple secrets files merging: `Rails::Secrets.parse(['secrets.yml', 'secrets.local.yml'], env: Rails.env)`
43
+ - Environment-specific loading: `Rails::Secrets.load(env: 'production')`
44
+ - Custom file parsing: `Rails::Secrets.parse(['config/custom.yml'], env: Rails.env)`
45
+ - Multiple path support: `Rails::Secrets.parse([Rails.root.join('config', 'secrets.yml')], env: Rails.env)`
46
+
47
+ ### Backward Compatibility
48
+
49
+ - ✅ All existing methods still work
50
+ - ✅ `parse_default` → `load` (alias maintained)
51
+ - ✅ `read` → `load` (alias maintained)
52
+ - ✅ No breaking changes
53
+
3
54
  ## [2.1.0] - 2025-09-22
4
55
 
5
56
  ### Removed
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Restores the classic Rails `secrets.yml` functionality that was removed in Rails 7.2. Uses simple, plain YAML files for environment-specific secrets management.
4
4
 
5
5
  **Rails Version Support:**
6
- - **Rails 7.1**: Manual setup (see Rails 7.1 Integration below)
6
+ - **Rails 7.1 and older**: Manual setup (see Older Rails Integration below)
7
7
  - **Rails 7.2+**: Automatic setup
8
8
  - **Rails 8.0+**: Full compatibility
9
9
 
@@ -51,13 +51,46 @@ production:
51
51
  api_key: <%= ENV['API_KEY'] %>
52
52
  ```
53
53
 
54
- ## Rails 7.1 Integration
54
+ ## Advanced Usage
55
55
 
56
- Test Secvault in Rails 7.1 before upgrading to 7.2+:
56
+ **Multiple secrets files (merged in order):**
57
+ ```ruby
58
+ # Parse multiple files - later files override earlier ones
59
+ secrets = Rails::Secrets.parse([
60
+ 'config/secrets.yml',
61
+ 'config/secrets.local.yml',
62
+ 'config/secrets.production.yml'
63
+ ], env: Rails.env)
64
+ ```
65
+
66
+ **Load specific environment:**
67
+ ```ruby
68
+ # Load production secrets in any environment
69
+ production_secrets = Rails::Secrets.load(env: 'production')
70
+
71
+ # Load development secrets
72
+ dev_secrets = Rails::Secrets.load(env: 'development')
73
+ ```
74
+
75
+ **Custom files:**
76
+ ```ruby
77
+ # Parse a custom secrets file
78
+ custom_secrets = Rails::Secrets.parse(['config/custom.yml'], env: Rails.env)
79
+
80
+ # Parse from different paths
81
+ all_secrets = Rails::Secrets.parse([
82
+ Rails.root.join('config', 'secrets.yml'),
83
+ Rails.root.join('config', 'deploy', 'secrets.yml')
84
+ ], env: Rails.env)
85
+ ```
86
+
87
+ ## Older Rails Integration
88
+
89
+ For Rails versions with existing secrets functionality (like Rails 7.1), use Secvault to test before upgrading:
57
90
 
58
91
  ```ruby
59
92
  # config/initializers/secvault.rb
60
- Secvault.setup_rails_71_integration!
93
+ Secvault.setup_backward_compatibility_with_older_rails!
61
94
  ```
62
95
 
63
96
  This replaces Rails.application.secrets with Secvault functionality. Your existing Rails 7.1 code works unchanged:
@@ -65,7 +98,8 @@ This replaces Rails.application.secrets with Secvault functionality. Your existi
65
98
  ```ruby
66
99
  Rails.application.secrets.api_key # ✅ Works
67
100
  Rails.application.secrets.oauth_settings # ✅ Works
68
- Rails::Secrets.parse_default # ✅ Enhanced functionality
101
+ Rails::Secrets.load # ✅ Load default config/secrets.yml
102
+ Rails::Secrets.parse(['custom.yml'], env: Rails.env) # ✅ Parse custom files
69
103
  ```
70
104
 
71
105
 
@@ -7,43 +7,41 @@ module Secvault
7
7
  module RailsSecrets
8
8
  extend self
9
9
 
10
- # Classic Rails::Secrets.parse method
10
+ # Parse secrets from one or more YAML files
11
11
  #
12
- # Parses secrets files with support for:
13
- # - ERB templating
12
+ # Supports:
13
+ # - ERB templating for environment variables
14
14
  # - Shared sections that apply to all environments
15
15
  # - Environment-specific sections
16
+ # - Multiple files (merged in order)
16
17
  # - Deep symbolized keys
17
18
  #
18
- # Example usage:
19
- # Rails::Secrets.parse([Pathname.new('config/secrets.yml')], env: 'development')
20
- #
21
- # Example secrets.yml structure:
22
- # shared:
23
- # common_key: shared_value
19
+ # Examples:
20
+ # # Single file
21
+ # Rails::Secrets.parse(['config/secrets.yml'], env: 'development')
24
22
  #
25
- # development:
26
- # secret_key_base: dev_secret
27
- # api_key: dev_api_key
23
+ # # Multiple files (merged in order)
24
+ # Rails::Secrets.parse([
25
+ # 'config/secrets.yml',
26
+ # 'config/secrets.local.yml'
27
+ # ], env: 'development')
28
28
  #
29
- # production:
30
- # secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
31
- # api_key: <%= ENV["API_KEY"] %>
32
- #
29
+ # # Load default config/secrets.yml
30
+ # Rails::Secrets.load # uses current Rails.env
31
+ # Rails::Secrets.load(env: 'production')
33
32
  def parse(paths, env:)
34
33
  Secvault::Secrets.parse(paths, env: env.to_s)
35
34
  end
36
35
 
37
- # Convenience method to parse the default secrets file
38
- def parse_default(env: Rails.env)
36
+ # Load secrets from the default config/secrets.yml file
37
+ def load(env: Rails.env)
39
38
  secrets_path = Rails.root.join("config/secrets.yml")
40
39
  parse([secrets_path], env: env)
41
40
  end
42
41
 
43
- # Read and parse secrets for the current Rails environment
44
- def read(env: Rails.env)
45
- parse_default(env: env)
46
- end
42
+ # Backward compatibility aliases (deprecated)
43
+ alias_method :parse_default, :load
44
+ alias_method :read, :load
47
45
  end
48
46
  end
49
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Secvault
4
- VERSION = "2.1.0"
4
+ VERSION = "2.3.0"
5
5
  end
data/lib/secvault.rb CHANGED
@@ -44,7 +44,8 @@ loader.setup
44
44
  # ## Usage:
45
45
  # Rails.application.secrets.api_key
46
46
  # Rails.application.secrets.oauth_settings[:google_client_id]
47
- # Rails::Secrets.parse_default(env: 'development')
47
+ # Rails::Secrets.load(env: 'development') # Load default config/secrets.yml
48
+ # Rails::Secrets.parse(['custom.yml'], env: Rails.env) # Parse custom files
48
49
  #
49
50
  # ## Getting Started:
50
51
  # 1. Create config/secrets.yml with your secrets
@@ -64,18 +65,18 @@ module Secvault
64
65
  require "secvault/rails_secrets"
65
66
  end
66
67
 
67
- # Helper method to set up Secvault for Rails 7.1 applications
68
- # This provides an easy way to integrate Secvault into Rails 7.1 apps
69
- # that still have native Rails::Secrets functionality.
68
+ # Helper method to set up Secvault for older Rails versions
69
+ # This provides an easy way to integrate Secvault into older Rails apps
70
+ # that still have native Rails::Secrets functionality (like Rails 7.1).
70
71
  #
71
72
  # Usage in an initializer:
72
- # Secvault.setup_rails_71_integration!
73
+ # Secvault.setup_backward_compatibility_with_older_rails!
73
74
  #
74
75
  # This will:
75
76
  # 1. Override native Rails::Secrets with Secvault implementation
76
77
  # 2. Replace Rails.application.secrets with Secvault-powered functionality
77
78
  # 3. Load secrets from config/secrets.yml automatically
78
- def setup_rails_71_integration!
79
+ def setup_backward_compatibility_with_older_rails!
79
80
  # Override native Rails::Secrets
80
81
  if defined?(Rails::Secrets)
81
82
  Rails.send(:remove_const, :Secrets)
@@ -108,6 +109,9 @@ module Secvault
108
109
  end
109
110
  end
110
111
  end
112
+
113
+ # Backward compatibility alias
114
+ alias_method :setup_rails_71_integration!, :setup_backward_compatibility_with_older_rails!
111
115
  end
112
116
 
113
117
  Secvault.install! if defined?(Rails)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secvault
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unnikrishnan KP