hanami-secret-settings 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bda4320560f1e09328fce36b82f78cb42aa6b5e6c0bbbca127dad45bd472aeaf
4
+ data.tar.gz: 8910d4059ba20dd94a59de67994e47eb0b2ee67c18a67e55b7612f95cecf8cca
5
+ SHA512:
6
+ metadata.gz: 40d44aeebf548471d106eb4b037979ece1d4ae37ee74ffd41440bf7b75256b498040de17c1873819a68a77a2afb6397480310b6fc8b25555818f7de3bb8fb33a
7
+ data.tar.gz: 671cb7c1922c9062423195d0f74bce7a9b2f732c95f37e0ceac7225601f298e5bdf9cf52b7563dcc5f998383752b87a02950b8377f372f5c8249ba31e842a20a
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - `Hanami::SecretSettings::CompositeStore` - chains multiple stores with fallback resolution
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aaron Allen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module SecretSettings
5
+ # A settings store that chains multiple stores with fallback resolution.
6
+ #
7
+ # Each store is tried in order. The first store to return a value wins.
8
+ # Stores must implement `#fetch` with the same signature as `Hash#fetch`.
9
+ #
10
+ # @example
11
+ # # config/app.rb
12
+ # config.settings_store = Hanami::SecretSettings::CompositeStore.new(
13
+ # Hanami::Settings::EnvStore.new,
14
+ # Hanami::SecretSettings::OnePasswordStore.new(vault: "Production", item: "MyApp")
15
+ # )
16
+ #
17
+ # @api public
18
+ # @since 0.1.0
19
+ class CompositeStore
20
+ # @param stores [Array<#fetch>] ordered list of stores to query
21
+ def initialize(*stores)
22
+ @stores = stores
23
+ end
24
+
25
+ # Fetches a value by trying each store in order.
26
+ #
27
+ # @param name [String, Symbol] the setting name
28
+ # @param args [Array] optional default value
29
+ # @yield [name] optional block for default value
30
+ # @return [Object] the setting value
31
+ # @raise [KeyError] if no store has the key and no default is given
32
+ #
33
+ # @api public
34
+ # @since 0.1.0
35
+ def fetch(name, *args, &block)
36
+ @stores.each do |store|
37
+ value = store.fetch(name, NOT_SET)
38
+ return value unless value.equal?(NOT_SET)
39
+ end
40
+
41
+ return args.first unless args.empty?
42
+ return yield(name) if block
43
+
44
+ raise KeyError, "key not found: #{name.inspect}"
45
+ end
46
+
47
+ NOT_SET = Object.new.freeze
48
+ private_constant :NOT_SET
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "secret_settings/version"
4
+ require_relative "secret_settings/composite_store"
5
+
6
+ module Hanami
7
+ module SecretSettings
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hanami-secret-settings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Allen
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: hanami
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.2'
26
+ description: Pluggable settings stores that fetch secrets from password managers like
27
+ 1Password and Bitwarden for use with Hanami::Settings.
28
+ email:
29
+ - hello@aaronmallen.me
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - LICENSE
36
+ - lib/hanami/secret_settings.rb
37
+ - lib/hanami/secret_settings/composite_store.rb
38
+ homepage: https://github.com/aaronmallen/hanami-secret-settings
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ bug_tracker_uri: https://github.com/aaronmallen/hanami-secret-settings/issues
43
+ changelog_uri: https://github.com/aaronmallen/hanami-secret-settings/blob/main/CHANGELOG.md
44
+ homepage_uri: https://github.com/aaronmallen/hanami-secret-settings
45
+ rubygems_mfa_required: 'true'
46
+ source_code_uri: https://github.com/aaronmallen/hanami-secret-settings
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 4.0.3
62
+ specification_version: 4
63
+ summary: Password manager-backed settings stores for Hanami
64
+ test_files: []