hexx-settings 0.1.0 → 0.2.0
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/Guardfile +1 -1
- data/README.md +25 -10
- data/lib/hexx/settings.rb +10 -0
- data/lib/hexx/settings/version.rb +1 -1
- data/spec/{tests → unit}/settings_spec.rb +11 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccaf5248db078fad3c483a32553e641e96787f76
|
4
|
+
data.tar.gz: c8731c6418062d828cf63e0a08a039482a8a4447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceb08c39c2f162e7dd41386c787430d0bead4fd30881b20a942e40978b7f4a266e03f3443f5479818f49c5f82e8e1873b759a67c6c01457d735ce68d7083847c
|
7
|
+
data.tar.gz: 5f9ba43c2564f68e5b102a1c2f0ea6a94ec4bfdc9a4db0922128b73615a1512c7c04b3fd62c5f63425394d914799b8a41e744305575d243ea4561ecf9a4bd6de
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -35,29 +35,44 @@ end # module MyGem
|
|
35
35
|
|
36
36
|
The class provides a [singleton instance] to store settings in.
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
### configure
|
39
|
+
|
40
|
+
The class method `.configure` yields the block with access to its configurable
|
41
|
+
singleton instance:
|
41
42
|
|
42
43
|
```ruby
|
43
44
|
MyGem::Settings.configure do |config|
|
44
45
|
config.foo = :bar
|
45
46
|
end
|
47
|
+
```
|
48
|
+
|
49
|
+
### []
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
The class method `[]` is a shortcut to the instance variable:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
MyGem::Settings[:foo] # => :bar
|
50
55
|
```
|
51
56
|
|
52
|
-
|
53
|
-
|
57
|
+
### initialize_from
|
58
|
+
|
59
|
+
The class method `.initialize_from` to load settings from given initializer:
|
54
60
|
|
55
61
|
```ruby
|
56
62
|
MyGem::Settings.initialize_from "my_module", at: ENV["PATH_TO_INITIALIZERS"]
|
57
63
|
```
|
58
64
|
|
59
|
-
The method doesn't fail when the initializer hasn't been found,
|
60
|
-
warns the user.
|
65
|
+
The method doesn't fail when the initializer hasn't been found,
|
66
|
+
but only warns the user.
|
67
|
+
|
68
|
+
### reset
|
69
|
+
|
70
|
+
The class method `.reset` clears all settings
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
MyGem::Settings.reset
|
74
|
+
MyGem::Settings[:foo] # => nil
|
75
|
+
```
|
61
76
|
|
62
77
|
[singleton instance]: http://ruby-doc.org/stdlib-1.9.3/libdoc/singleton/rdoc/Singleton.html
|
63
78
|
|
data/lib/hexx/settings.rb
CHANGED
@@ -70,6 +70,16 @@ module Hexx
|
|
70
70
|
warn "You should provide the '#{ filename }' initializer"
|
71
71
|
end
|
72
72
|
|
73
|
+
# Resets all settings
|
74
|
+
#
|
75
|
+
# @return [undefined]
|
76
|
+
#
|
77
|
+
def self.reset
|
78
|
+
instance.instance_variables.each do |variable|
|
79
|
+
instance.instance_variable_set variable, nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
73
83
|
end # class Settings
|
74
84
|
|
75
85
|
end # module Hexx
|
@@ -133,4 +133,15 @@ describe Hexx::Settings do
|
|
133
133
|
|
134
134
|
end # describe .initialize_from
|
135
135
|
|
136
|
+
describe ".reset" do
|
137
|
+
|
138
|
+
before { instance.foo = "foo" }
|
139
|
+
subject { klass.reset }
|
140
|
+
|
141
|
+
it "resets settings" do
|
142
|
+
expect { subject }.to change { klass[:foo] }.from("foo").to nil
|
143
|
+
end
|
144
|
+
|
145
|
+
end # describe .reset
|
146
|
+
|
136
147
|
end # describe Hexx::Settings
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexx-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hexx-rspec
|
@@ -60,7 +60,7 @@ files:
|
|
60
60
|
- lib/hexx/settings.rb
|
61
61
|
- lib/hexx/settings/version.rb
|
62
62
|
- spec/spec_helper.rb
|
63
|
-
- spec/
|
63
|
+
- spec/unit/settings_spec.rb
|
64
64
|
homepage: https://github.com/nepalez/hexx-settings
|
65
65
|
licenses:
|
66
66
|
- MIT
|
@@ -87,5 +87,5 @@ specification_version: 4
|
|
87
87
|
summary: The interface for a gem's settings storage
|
88
88
|
test_files:
|
89
89
|
- spec/spec_helper.rb
|
90
|
-
- spec/
|
90
|
+
- spec/unit/settings_spec.rb
|
91
91
|
has_rdoc:
|