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 +4 -4
- data/README.md +19 -1
- data/lib/bindan/version.rb +1 -1
- data/lib/bindan.rb +21 -0
- data/sig/bindan.rbs +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77be6a8a1a9d6b820162f7314d2059a3d30913d54df5bac04f97715f78ccbbf7
|
|
4
|
+
data.tar.gz: fbc74c7696fbdc82e1dfcbfd1cb19ef772173af876796b738c68a338e50e8129
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f486ad2603b6116a4ec212d0ac297e3ba86c2b2d9cd3269f2e5a9c64f7ab4c92d2cdd24480c3b4056ffa31a6e552ba7a001651089986a756cb8e70dd39bcb562
|
|
7
|
+
data.tar.gz: 626eb96b617d2b5cafe34102ce68f87b73160fcf3b019ab23b46c3b634b7539c5211e075bcfedef86df9fba78a9f0089c007304aa117888bdd4d066a7e75a425
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Bindan
|
|
2
2
|
[](https://badge.fury.io/rb/bindan)
|
|
3
|
-
[](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 = {
|
data/lib/bindan/version.rb
CHANGED
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.
|
|
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-
|
|
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
|