ztk 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ztk/config.rb +34 -0
- data/lib/ztk/version.rb +1 -1
- metadata +3 -3
data/lib/ztk/config.rb
CHANGED
@@ -29,6 +29,40 @@ module ZTK
|
|
29
29
|
|
30
30
|
# Configuration Module
|
31
31
|
#
|
32
|
+
# Extend an existing class with this module to turn it into a singleton
|
33
|
+
# configuration class.
|
34
|
+
#
|
35
|
+
# Given we have some code like:
|
36
|
+
#
|
37
|
+
# class C
|
38
|
+
# extend(ZTK::Config)
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# We can then do things like:
|
42
|
+
#
|
43
|
+
# C.thing = "something"
|
44
|
+
#
|
45
|
+
# or we can reference keys this way:
|
46
|
+
#
|
47
|
+
# C[:thing] = "something"
|
48
|
+
#
|
49
|
+
# Accessing the value is just as simple:
|
50
|
+
#
|
51
|
+
# puts C.thing
|
52
|
+
#
|
53
|
+
# We can also load configurations from disk. Assuming we have a file (i.e. config.rb) like:
|
54
|
+
#
|
55
|
+
# message "Hello World"
|
56
|
+
# thing (1+1)
|
57
|
+
#
|
58
|
+
# We can load it like so:
|
59
|
+
#
|
60
|
+
# C.from_file("config.rb")
|
61
|
+
#
|
62
|
+
# Then we can reference the configuration defined in the file as easily as:
|
63
|
+
#
|
64
|
+
# puts C.message
|
65
|
+
#
|
32
66
|
# @author Zachary Patten <zachary@jovelabs.net>
|
33
67
|
module Config
|
34
68
|
|
data/lib/ztk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
208
|
version: '0'
|
209
209
|
segments:
|
210
210
|
- 0
|
211
|
-
hash: -
|
211
|
+
hash: -2074197007212519057
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
213
|
none: false
|
214
214
|
requirements:
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash: -
|
220
|
+
hash: -2074197007212519057
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
223
|
rubygems_version: 1.8.24
|