bindan 0.1.0 → 0.1.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: 41a496e6f91cd22b627b887d5b0cb209cd3c6d277dedbf527dd38c774d444273
4
- data.tar.gz: 6dea83b8c98edfa91989d2b488180e250710336cfe7b6470e257cec75c292c89
3
+ metadata.gz: 77be6a8a1a9d6b820162f7314d2059a3d30913d54df5bac04f97715f78ccbbf7
4
+ data.tar.gz: fbc74c7696fbdc82e1dfcbfd1cb19ef772173af876796b738c68a338e50e8129
5
5
  SHA512:
6
- metadata.gz: 0ffd5b03d4a1c9a76c696a514fbaa5bac9d323820dc19c88229b0ba88c6e6e893b6bd6b2e8d1659d325e4f235f906b87d14e37741ed0ba7045e11bcf8be4dcf7
7
- data.tar.gz: 5a46f6c97809b06dc6dc4aa7b75a2e5093059b71f6baeb6fd75450f303471b7f005fee21f995787866d2341b1440a1f3d5fedd8dcfb3be98e77f81e0bf000a0e
6
+ metadata.gz: f486ad2603b6116a4ec212d0ac297e3ba86c2b2d9cd3269f2e5a9c64f7ab4c92d2cdd24480c3b4056ffa31a6e552ba7a001651089986a756cb8e70dd39bcb562
7
+ data.tar.gz: 626eb96b617d2b5cafe34102ce68f87b73160fcf3b019ab23b46c3b634b7539c5211e075bcfedef86df9fba78a9f0089c007304aa117888bdd4d066a7e75a425
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bindan
2
2
  [![Gem Version](https://badge.fury.io/rb/bindan.svg)](https://badge.fury.io/rb/bindan)
3
- [![CI](https://github.com/wtnabe/bindan/actions/workflows/main.yml/badge.svg)](https://github.com/wtnabe/bindan/actions/workflows/main.yml)
3
+ [![CI](https://github.com/wtnabe/bindan/actions/workflows/test.yml/badge.svg)](https://github.com/wtnabe/bindan/actions/workflows/test.yml)
4
4
 
5
5
  Bindan is a Ruby gem for building single configuration object from various sources with providers (that is bundled Google Cloud Storage and Firestore platform by default). It provides a flexible way to manage application settings, supporting lazy initialization and seamless switching between development (using emulators) and production (eg. actual GCP services) environments.
6
6
 
@@ -52,6 +52,22 @@ end
52
52
  puts config.database_host # => "localhost"
53
53
  ```
54
54
 
55
+ or
56
+
57
+ ```ruby
58
+ require "bindan"
59
+
60
+ class App
61
+ extend Bindan
62
+ end
63
+
64
+ App.configure do |c, pr|
65
+ c.database_host = pr.env["DATABASE_HOST"] || "localhost"
66
+ end
67
+
68
+ # unless $DATABASE_HOST environment variable
69
+ puts App.config.database_host # => "localhost"
70
+ ```
55
71
  ### with Multiple Providers
56
72
 
57
73
  in Gemfile
@@ -66,6 +82,8 @@ and
66
82
 
67
83
  ```ruby
68
84
  require "bindan"
85
+ require "google/client/storage"
86
+ require "google/client/firestore"
69
87
 
70
88
  # Define your configuration providers
71
89
  providers = {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bindan
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/bindan.rb CHANGED
@@ -15,10 +15,31 @@ module Bindan
15
15
  if block.is_a? Proc
16
16
  container = OpenStruct.new
17
17
  block.call(container, Struct.new(*providers.keys).new(*providers.values)) # steep:ignore
18
+ if instance_variables.include?(:@_config)
19
+ instance_variable_set :@_config, container.freeze
20
+ end
18
21
  container
19
22
  else
20
23
  warn "no block given for `configure'"
21
24
  end
22
25
  end
23
26
  module_function :configure
27
+
28
+ #
29
+ # @param [Class] klass
30
+ # @return [self]
31
+ #
32
+ def self.extended(klass)
33
+ klass.instance_eval do
34
+ @_config = nil
35
+
36
+ #
37
+ # @return [OpenStruct]
38
+ #
39
+ def self.config
40
+ @_config
41
+ end
42
+ end
43
+ public :configure
44
+ end
24
45
  end
data/sig/bindan.rbs CHANGED
@@ -1,8 +1,19 @@
1
1
  module Bindan
2
+ #
3
+ # @param [Class] klass
4
+ # @return [self]
5
+ #
6
+ def self.extended: (untyped klass) -> untyped
7
+
2
8
  #
3
9
  # @param [Hash[String | Symbol, Provider]] providers
4
10
  # @param [Proc] block
5
11
  # @return [OpenStruct]
6
12
  #
7
13
  def self?.configure: (?providers: ::Hash[Symbol, untyped]) ?{ (::OpenStruct, untyped) -> untyped } -> ::OpenStruct?
14
+
15
+ #
16
+ # @return [OpenStruct]
17
+ #
18
+ def self?.config: () -> ::OpenStruct?
8
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - wtnabe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-03 00:00:00.000000000 Z
11
+ date: 2025-08-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Bindan is a Ruby gem for building single configuration object from various
14
14
  sources with providers (that is bundled Google Cloud Storage and Firestore platform