hexx-settings 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eea12d82992465509602ac4fa8286d33979127fa
4
- data.tar.gz: 15b2a30e2c8444d6aadd45b7a0731e439dc0529c
3
+ metadata.gz: ccaf5248db078fad3c483a32553e641e96787f76
4
+ data.tar.gz: c8731c6418062d828cf63e0a08a039482a8a4447
5
5
  SHA512:
6
- metadata.gz: c58582296a1408686e04a2649b6e1d99ff5067fd46ef6dab5bc556b2e3270053ecbf45413e9f644a871d46890a27a20d38c10ebec530a530a3dd41849bee98d9
7
- data.tar.gz: a78956b1beaca51250139f65598f4cecb898dd00f2cdbac4872093bce8161247d1f5d442aba01912c8cb066dfab14979fc73fc143c572bea6ba624bb247ab1dd
6
+ metadata.gz: ceb08c39c2f162e7dd41386c787430d0bead4fd30881b20a942e40978b7f4a266e03f3443f5479818f49c5f82e8e1873b759a67c6c01457d735ce68d7083847c
7
+ data.tar.gz: 5f9ba43c2564f68e5b102a1c2f0ea6a94ec4bfdc9a4db0922128b73615a1512c7c04b3fd62c5f63425394d914799b8a41e744305575d243ea4561ecf9a4bd6de
data/Guardfile CHANGED
@@ -5,7 +5,7 @@ guard :rspec, cmd: "bundle exec rspec" do
5
5
  watch(%r{^spec/.+_spec.rb$})
6
6
 
7
7
  watch(%r{^lib/hexx(.+)\.rb$}) do |m|
8
- "spec/tests#{ m[1] }_spec.rb"
8
+ "spec/unit#{ m[1] }_spec.rb"
9
9
  end
10
10
 
11
11
  watch("lib/hexx-settings.rb") { "spec" }
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
- Class `Settings` predefines `configure` and `[]` class methods.
39
- The first one yields the block with the instance of its own, the second
40
- is a shortcut to the instance methods.
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
- MyGem::Settings.instance.foo # => :bar
48
- # this is the same as above:
49
- MyGem::Settings[:foo] # => :bar
51
+ The class method `[]` is a shortcut to the instance variable:
52
+
53
+ ```ruby
54
+ MyGem::Settings[:foo] # => :bar
50
55
  ```
51
56
 
52
- It also provides the class method `.initialize_from` to try loading
53
- settings from given initializer:
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, but instead
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
 
@@ -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
@@ -6,7 +6,7 @@ module Hexx
6
6
 
7
7
  # The semantic version of the module.
8
8
  # @see http://semver.org/ Semantic versioning 2.0
9
- VERSION = "0.1.0".freeze
9
+ VERSION = "0.2.0".freeze
10
10
 
11
11
  end # class Settings
12
12
 
@@ -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.1.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-06 00:00:00.000000000 Z
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/tests/settings_spec.rb
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/tests/settings_spec.rb
90
+ - spec/unit/settings_spec.rb
91
91
  has_rdoc: