confi 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 +7 -0
- data/.github/workflows/rake.yml +31 -0
- data/.gitignore +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.watchr +1 -0
- data/BENCHMARKS +46 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +85 -0
- data/LICENSE +20 -0
- data/README.md +71 -0
- data/Rakefile +11 -0
- data/confi.gemspec +22 -0
- data/lib/confi.rb +46 -0
- data/test/benchmark_test.rb +45 -0
- data/test/confi_test.rb +54 -0
- data/test/include_test.rb +59 -0
- data/test/test_helper.rb +9 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 972b6f8e7309328bd9857eab968434da275e9c753c5a64d82cf0c039a460bbe4
|
4
|
+
data.tar.gz: 265e5a20d66bb72bb005c51461307947dc71e97bbbe887612dc36e39d75adfdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4b7cee86b97bf348d33c9659f69e434f7b5dbcacf0aaf22cb1573885c9d6637b1f620b1c685b0133a1bc53004170d5efc07cc0cb6779c91e4230607505bd95f
|
7
|
+
data.tar.gz: 78bf046e3f95bf8a2bb3c61a56cd6df1b2a9611daa7290c1552e8f003397f496a4c39ff646c47205d224525443ac5a55560458781913ad5aac1951864afcbd2e
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Rake
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
# ruby_version: [head, "3.4", "3.0"]
|
11
|
+
ruby_version: ["3.4"]
|
12
|
+
gemfile:
|
13
|
+
- Gemfile
|
14
|
+
# exclude:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby_version }}
|
23
|
+
bundler-cache: true # 'bundle install' and cache
|
24
|
+
# - name: Bundle install
|
25
|
+
# run: |
|
26
|
+
# bundle config set frozen false
|
27
|
+
# bundle config path /home/runner/bundle
|
28
|
+
# bundle install
|
29
|
+
# bundle update
|
30
|
+
- name: Build and test with Rake
|
31
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rails-8.0
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.4.4
|
data/.watchr
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/home/dk/shared/.watchr-simple
|
data/BENCHMARKS
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
2025-05-27
|
2
|
+
==========
|
3
|
+
ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [x86_64-linux]
|
4
|
+
Warming up --------------------------------------
|
5
|
+
** (empty) 2.724M i/100ms
|
6
|
+
hsh: 2.611M i/100ms
|
7
|
+
hsh[:hugo]: 1.976M i/100ms
|
8
|
+
hsh[:hugo] = true: 1.341M i/100ms
|
9
|
+
hsh["b"]: 1.898M i/100ms
|
10
|
+
hsh["b"] = 3: 1.265M i/100ms
|
11
|
+
** Confi (empty) 2.733M i/100ms
|
12
|
+
Confi.hugo = true: 1.294M i/100ms
|
13
|
+
Confi.hugo: 1.700M i/100ms
|
14
|
+
** User (empty) 2.739M i/100ms
|
15
|
+
user: 2.577M i/100ms
|
16
|
+
user.hugo = true: 1.695M i/100ms
|
17
|
+
user.hugo: 1.813M i/100ms
|
18
|
+
Calculating -------------------------------------
|
19
|
+
** (empty) 26.870M (± 0.5%) i/s (37.22 ns/i) - 136.212M in 5.069431s
|
20
|
+
hsh: 26.171M (± 0.4%) i/s (38.21 ns/i) - 133.162M in 5.088175s
|
21
|
+
hsh[:hugo]: 19.633M (± 0.6%) i/s (50.94 ns/i) - 98.822M in 5.033765s
|
22
|
+
hsh[:hugo] = true: 13.429M (± 0.4%) i/s (74.46 ns/i) - 68.393M in 5.092913s
|
23
|
+
hsh["b"]: 19.057M (± 0.5%) i/s (52.48 ns/i) - 96.824M in 5.081001s
|
24
|
+
hsh["b"] = 3: 12.595M (± 1.1%) i/s (79.39 ns/i) - 63.253M in 5.022507s
|
25
|
+
** Confi (empty) 26.773M (± 0.4%) i/s (37.35 ns/i) - 133.895M in 5.001222s
|
26
|
+
Confi.hugo = true: 12.842M (± 0.9%) i/s (77.87 ns/i) - 64.706M in 5.039055s
|
27
|
+
Confi.hugo: 16.972M (± 0.6%) i/s (58.92 ns/i) - 84.978M in 5.007025s
|
28
|
+
** User (empty) 27.079M (± 0.5%) i/s (36.93 ns/i) - 136.961M in 5.057976s
|
29
|
+
user: 25.655M (± 0.5%) i/s (38.98 ns/i) - 128.853M in 5.022659s
|
30
|
+
user.hugo = true: 16.842M (± 0.4%) i/s (59.38 ns/i) - 84.743M in 5.031835s
|
31
|
+
user.hugo: 17.932M (± 0.4%) i/s (55.77 ns/i) - 90.670M in 5.056536s
|
32
|
+
|
33
|
+
Comparison:
|
34
|
+
** User (empty): 27078912.1 i/s
|
35
|
+
** (empty): 26870068.1 i/s - same-ish: difference falls within error
|
36
|
+
** Confi (empty): 26772970.4 i/s - 1.01x slower
|
37
|
+
hsh: : 26171272.6 i/s - 1.03x slower
|
38
|
+
user: : 25654956.6 i/s - 1.06x slower
|
39
|
+
hsh[:hugo]: : 19632521.2 i/s - 1.38x slower
|
40
|
+
hsh["b"]: : 19056544.7 i/s - 1.42x slower
|
41
|
+
user.hugo: : 17931506.3 i/s - 1.51x slower
|
42
|
+
Confi.hugo: : 16972414.8 i/s - 1.60x slower
|
43
|
+
user.hugo = true: : 16841777.7 i/s - 1.61x slower
|
44
|
+
hsh[:hugo] = true: : 13429358.2 i/s - 2.02x slower
|
45
|
+
Confi.hugo = true: : 12841938.3 i/s - 2.11x slower
|
46
|
+
hsh["b"] = 3: : 12595451.2 i/s - 2.15x slower
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
confi (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.3)
|
10
|
+
benchmark (0.4.0)
|
11
|
+
benchmark-ips (2.14.0)
|
12
|
+
byebug (12.0.0)
|
13
|
+
docile (1.4.1)
|
14
|
+
json (2.12.2)
|
15
|
+
language_server-protocol (3.17.0.5)
|
16
|
+
lint_roller (1.1.0)
|
17
|
+
minitest (5.25.5)
|
18
|
+
parallel (1.27.0)
|
19
|
+
parser (3.3.8.0)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
racc
|
22
|
+
prism (1.4.0)
|
23
|
+
racc (1.8.1)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
rake (13.2.1)
|
26
|
+
regexp_parser (2.10.0)
|
27
|
+
ricecream (0.2.1)
|
28
|
+
rubocop (1.75.7)
|
29
|
+
json (~> 2.3)
|
30
|
+
language_server-protocol (~> 3.17.0.2)
|
31
|
+
lint_roller (~> 1.1.0)
|
32
|
+
parallel (~> 1.10)
|
33
|
+
parser (>= 3.3.0.2)
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
36
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
37
|
+
ruby-progressbar (~> 1.7)
|
38
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
39
|
+
rubocop-ast (1.44.1)
|
40
|
+
parser (>= 3.3.7.2)
|
41
|
+
prism (~> 1.4)
|
42
|
+
rubocop-performance (1.25.0)
|
43
|
+
lint_roller (~> 1.1)
|
44
|
+
rubocop (>= 1.75.0, < 2.0)
|
45
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
46
|
+
ruby-progressbar (1.13.0)
|
47
|
+
simplecov (0.22.0)
|
48
|
+
docile (~> 1.1)
|
49
|
+
simplecov-html (~> 0.11)
|
50
|
+
simplecov_json_formatter (~> 0.1)
|
51
|
+
simplecov-html (0.13.1)
|
52
|
+
simplecov_json_formatter (0.1.4)
|
53
|
+
standard (1.50.0)
|
54
|
+
language_server-protocol (~> 3.17.0.2)
|
55
|
+
lint_roller (~> 1.0)
|
56
|
+
rubocop (~> 1.75.5)
|
57
|
+
standard-custom (~> 1.0.0)
|
58
|
+
standard-performance (~> 1.8)
|
59
|
+
standard-custom (1.0.2)
|
60
|
+
lint_roller (~> 1.0)
|
61
|
+
rubocop (~> 1.50)
|
62
|
+
standard-performance (1.8.0)
|
63
|
+
lint_roller (~> 1.1)
|
64
|
+
rubocop-performance (~> 1.25.0)
|
65
|
+
unicode-display_width (3.1.4)
|
66
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
67
|
+
unicode-emoji (4.0.4)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
x86_64-linux
|
72
|
+
|
73
|
+
DEPENDENCIES
|
74
|
+
benchmark
|
75
|
+
benchmark-ips
|
76
|
+
byebug
|
77
|
+
confi!
|
78
|
+
minitest
|
79
|
+
rake
|
80
|
+
ricecream
|
81
|
+
simplecov
|
82
|
+
standard
|
83
|
+
|
84
|
+
BUNDLED WITH
|
85
|
+
2.6.7
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2025 Dittmar Krall (www.matiq.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Confi
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/confi)
|
4
|
+
[](https://rubygems.org/gems/confi)
|
5
|
+
[](https://github.com/matique/confi/actions/workflows/rake.yml)
|
6
|
+
[](https://github.com/standardrb/standard)
|
7
|
+
[](http://choosealicense.com/licenses/mit/)
|
8
|
+
|
9
|
+
A simple and efficient "configuration" gem for Ruby
|
10
|
+
(can be used in Rails as well).
|
11
|
+
Options can be initialized as required and later be accessed.
|
12
|
+
|
13
|
+
A global *Confi* (the usual usage)
|
14
|
+
as well as an instance (not recommended) configuration
|
15
|
+
are supported.
|
16
|
+
|
17
|
+
See *Usage* below.
|
18
|
+
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
~~~~ruby
|
23
|
+
# Gemfile
|
24
|
+
...
|
25
|
+
gem "confi"
|
26
|
+
...
|
27
|
+
~~~~
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
~~~~ruby
|
32
|
+
require "confi"
|
33
|
+
...
|
34
|
+
Confi.debug = true
|
35
|
+
...
|
36
|
+
if Confi.debug
|
37
|
+
...
|
38
|
+
end
|
39
|
+
...
|
40
|
+
~~~~
|
41
|
+
|
42
|
+
~~~~ruby
|
43
|
+
require "confi"
|
44
|
+
|
45
|
+
class User
|
46
|
+
include Confi
|
47
|
+
end
|
48
|
+
...
|
49
|
+
user = User.new
|
50
|
+
user.debug = false
|
51
|
+
...
|
52
|
+
if user.debug
|
53
|
+
...
|
54
|
+
end
|
55
|
+
...
|
56
|
+
~~~~
|
57
|
+
|
58
|
+
~~~~ruby
|
59
|
+
...
|
60
|
+
# Not yet initialized attribute
|
61
|
+
if Confi.debug # NoMethodError: undefined method 'debug'
|
62
|
+
...
|
63
|
+
end
|
64
|
+
...
|
65
|
+
~~~~
|
66
|
+
|
67
|
+
|
68
|
+
## Miscellaneous
|
69
|
+
|
70
|
+
Copyright (c) 2025 Dittmar Krall (www.matiq.com),
|
71
|
+
released under the [MIT license](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/confi.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# $LOAD_PATH.push File.expand_path("lib", __dir__)
|
2
|
+
|
3
|
+
VERSION = "0.1.1"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "confi"
|
7
|
+
s.version = VERSION
|
8
|
+
s.summary = "Auto attr_accessor for a kind of configuration"
|
9
|
+
s.description = s.summary
|
10
|
+
|
11
|
+
s.authors = ["Dittmar Krall"]
|
12
|
+
s.email = "dittmar.krall@gmail.com"
|
13
|
+
s.homepage = "https://github.com/matique/confi"
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.required_ruby_version = "~> 3"
|
19
|
+
|
20
|
+
s.add_development_dependency "simplecov", ">= 0"
|
21
|
+
s.add_development_dependency "standard", ">= 0"
|
22
|
+
end
|
data/lib/confi.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Confi
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def configure(source = {})
|
7
|
+
source.each { |key, value| accessors(key, value) }
|
8
|
+
yield self if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def dump
|
14
|
+
res = {}
|
15
|
+
@keys.uniq.each { |key| res[key] = send(key) }
|
16
|
+
res
|
17
|
+
end
|
18
|
+
|
19
|
+
def accessors(key, value)
|
20
|
+
@keys ||= []
|
21
|
+
@keys << key.to_sym
|
22
|
+
name = key.to_s
|
23
|
+
writer = "#{name}="
|
24
|
+
var_name = "@AWE_#{name}"
|
25
|
+
|
26
|
+
self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
27
|
+
def #{name}; #{var_name}; end
|
28
|
+
def #{name}=(x); #{var_name} = x; end
|
29
|
+
RUBY
|
30
|
+
send(writer, value)
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(method_name, *args)
|
34
|
+
if method_name.end_with?("=")
|
35
|
+
name = method_name[0..-2]
|
36
|
+
accessors(name, args.first)
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def respond_to_missing?(method_name, include_private = false)
|
44
|
+
method_name.end_with?("=") || super
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# For development purposes; do not waste your tine reading it!
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
require_relative "../lib/confi"
|
5
|
+
require "benchmark"
|
6
|
+
require "benchmark/ips"
|
7
|
+
# ENV["MORE"] = "true"
|
8
|
+
|
9
|
+
class User
|
10
|
+
include Confi
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "ConfigWe timings" do
|
14
|
+
it "times ips" do
|
15
|
+
return unless ENV["MORE"]
|
16
|
+
|
17
|
+
p "********************** Confi timings"
|
18
|
+
hsh = {"a" => 1, "b" => 2, :hugo => 3}
|
19
|
+
user = User.new
|
20
|
+
user.configure(hsh)
|
21
|
+
|
22
|
+
Benchmark.ips do |x|
|
23
|
+
x.report("** (empty)") {}
|
24
|
+
x.report("hsh: ") { hsh }
|
25
|
+
x.report("hsh[:hugo]: ") { hsh[:hugo] }
|
26
|
+
x.report("hsh[:hugo] = true: ") { hsh[:hugo] = true }
|
27
|
+
x.report("hsh[\"b\"]: ") { hsh["b"] }
|
28
|
+
x.report("hsh[\"b\"] = 3: ") { hsh["b"] = 3 }
|
29
|
+
|
30
|
+
x.report("** Confi (empty)") {}
|
31
|
+
# x.report("Confi.b: ") { Confi.b } # expected fail
|
32
|
+
x.report("Confi.hugo = true: ") { Confi.hugo = true }
|
33
|
+
x.report("Confi.hugo: ") { Confi.hugo }
|
34
|
+
# x.report("Confi.a: ") { Confi.a } # expected fail
|
35
|
+
|
36
|
+
x.report("** User (empty)") {}
|
37
|
+
x.report("user: ") { user }
|
38
|
+
# x.report("user.unknown: ") { user.unknown } # expected fail
|
39
|
+
x.report("user.hugo = true: ") { user.hugo = true }
|
40
|
+
x.report("user.hugo: ") { user.hugo }
|
41
|
+
|
42
|
+
x.compare!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/confi_test.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require_relative "../lib/confi"
|
3
|
+
|
4
|
+
describe Confi do
|
5
|
+
let(:int) { 123 }
|
6
|
+
let(:list) { [1, 2, 3] }
|
7
|
+
let(:hsh) { {"a" => 1, "b" => 2, "c" => 3} }
|
8
|
+
let(:symb) { :symbol }
|
9
|
+
|
10
|
+
it "putter & getter" do
|
11
|
+
Confi.a = symb
|
12
|
+
assert_equal symb, Confi.a
|
13
|
+
Confi.a = int
|
14
|
+
assert_equal int, Confi.a
|
15
|
+
end
|
16
|
+
|
17
|
+
it "configures with hash" do
|
18
|
+
Confi.configure(hsh)
|
19
|
+
check hsh
|
20
|
+
end
|
21
|
+
|
22
|
+
it "configures with block" do
|
23
|
+
Confi.configure do |m|
|
24
|
+
m.aa = int
|
25
|
+
m.bb = list
|
26
|
+
end
|
27
|
+
assert_equal int, Confi.aa
|
28
|
+
assert_equal list, Confi.bb
|
29
|
+
end
|
30
|
+
|
31
|
+
it "dumps (private method)" do
|
32
|
+
Confi.configure(hsh)
|
33
|
+
res = Confi.send(:dump)
|
34
|
+
assert res
|
35
|
+
check hsh
|
36
|
+
end
|
37
|
+
|
38
|
+
it "round trip with a YAML file" do
|
39
|
+
Tempfile.create do |f|
|
40
|
+
f.puts YAML.dump(hsh)
|
41
|
+
f.rewind
|
42
|
+
Confi.configure(YAML.load(f.read))
|
43
|
+
check hsh
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def check(hsh)
|
50
|
+
hsh.each { |key, value|
|
51
|
+
assert_equal hsh[key], Confi.send(key)
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "yaml"
|
3
|
+
require_relative "../lib/confi"
|
4
|
+
|
5
|
+
class User
|
6
|
+
include Confi
|
7
|
+
end
|
8
|
+
|
9
|
+
describe User do
|
10
|
+
let(:int) { rand 1..10 }
|
11
|
+
let(:symb) { :symbol }
|
12
|
+
let(:hsh) { {"a" => 1, "b" => 2} }
|
13
|
+
let(:user) { User.new }
|
14
|
+
|
15
|
+
it "rejects uninitialized attribute" do
|
16
|
+
assert_raises {
|
17
|
+
user.unknown
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it "putter & getter" do
|
22
|
+
user.a = symb
|
23
|
+
assert_equal symb, user.a
|
24
|
+
end
|
25
|
+
|
26
|
+
it "configures with hash" do
|
27
|
+
user.configure(hsh)
|
28
|
+
|
29
|
+
assert_equal 1, user.a
|
30
|
+
assert_equal 2, user.b
|
31
|
+
end
|
32
|
+
|
33
|
+
it "configures with block" do
|
34
|
+
user.configure do |spec|
|
35
|
+
spec.c = :c
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_equal :c, user.c
|
39
|
+
end
|
40
|
+
|
41
|
+
it "configures with hash & block" do
|
42
|
+
user.configure(hsh) do |spec|
|
43
|
+
spec.c = :c
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_equal 1, user.a
|
47
|
+
assert_equal :c, user.c
|
48
|
+
end
|
49
|
+
|
50
|
+
it "configure independent instances" do
|
51
|
+
user2 = User.new
|
52
|
+
user.a = symb
|
53
|
+
user2.a = int
|
54
|
+
|
55
|
+
assert_equal symb, user.a
|
56
|
+
assert_equal int, user2.a
|
57
|
+
refute_equal user.a, user2.a
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: confi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dittmar Krall
|
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: simplecov
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :development
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: standard
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
description: Auto attr_accessor for a kind of configuration
|
41
|
+
email: dittmar.krall@gmail.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- ".github/workflows/rake.yml"
|
47
|
+
- ".gitignore"
|
48
|
+
- ".ruby-gemset"
|
49
|
+
- ".ruby-version"
|
50
|
+
- ".watchr"
|
51
|
+
- BENCHMARKS
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- confi.gemspec
|
58
|
+
- lib/confi.rb
|
59
|
+
- test/benchmark_test.rb
|
60
|
+
- test/confi_test.rb
|
61
|
+
- test/include_test.rb
|
62
|
+
- test/test_helper.rb
|
63
|
+
homepage: https://github.com/matique/confi
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.6.7
|
82
|
+
specification_version: 4
|
83
|
+
summary: Auto attr_accessor for a kind of configuration
|
84
|
+
test_files: []
|