hanami-settings-stores 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: f2361fa59d804b5036ad6a843b9f38c75308554f786386ce2ec9acac2c3441f2
4
+ data.tar.gz: f608a5c736208e1be95995d9a083cff71e9c9af3e6d3dfcbfe4475d7f2fb0ecf
5
+ SHA512:
6
+ metadata.gz: 451b9a9796b6acec960d5542ee0359e4d761d7a20aab58452e9c927d66e05bffc37ea48660c45fbcc71176464785782607d2821540cf8af6a03d19e6cabf410e
7
+ data.tar.gz: c193fac8e097d8975a54dac1ae6c1fcda6f11c6c1297031e267eed8456e2451dda952075b26c233ddd0de69acaad2b2ff608bcac0d95a928265195309620e6b9
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::Settings::Stores::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
+ class Settings
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::Settings::Stores::CompositeStore.new(
13
+ # Hanami::Settings::EnvStore.new,
14
+ # Hanami::Settings::Stores::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,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zeitwerk"
4
+
5
+ module Hanami
6
+ class Settings
7
+ end
8
+ end
9
+
10
+ Zeitwerk::Loader.new.tap do |loader|
11
+ loader.tag = "hanami-settings-stores"
12
+ loader.push_dir(File.join(File.dirname(__FILE__), "hanami", "settings"), namespace: Hanami::Settings)
13
+ loader.ignore(__FILE__)
14
+ end.setup
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hanami-settings-stores
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Allen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hanami
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
41
+ description: Pluggable settings stores that fetch secrets from password managers like
42
+ 1Password and Bitwarden for use with Hanami::Settings.
43
+ email:
44
+ - hello@aaronmallen.me
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - CHANGELOG.md
50
+ - LICENSE
51
+ - lib/hanami-settings-stores.rb
52
+ - lib/hanami/settings/composite_store.rb
53
+ homepage: https://github.com/aaronmallen/hanami-settings-stores
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ bug_tracker_uri: https://github.com/aaronmallen/hanami-settings-stores/issues
58
+ changelog_uri: https://github.com/aaronmallen/hanami-settings-stores/blob/main/CHANGELOG.md
59
+ homepage_uri: https://github.com/aaronmallen/hanami-settings-stores
60
+ rubygems_mfa_required: 'true'
61
+ source_code_uri: https://github.com/aaronmallen/hanami-settings-stores
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '3.2'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.4.19
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Password manager-backed settings stores for Hanami
81
+ test_files: []