lab42_config 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d7807c37c337523025ea0c138b49835f28c43951
4
+ data.tar.gz: 6b392b4c90ad4a8fd700d09e4ec458e4bce10aa5
5
+ SHA512:
6
+ metadata.gz: 612ad33c38bf8d82bc9bddc9d647ec8b3084f1625bf9c50bdc5bdf0a1a86d8d6a1cdc9cf461666458c7a0eda83aa6d81bfbb557052f9f2c7a80551a64bcf085b
7
+ data.tar.gz: c51dd4e9c0b52f2f0042f851d3ad6581b94d740ee30c0ad34275bf8a694bfa3ebe67121d0a9407b4b2b43c6c4f520d2175849af387b8ce66d45eaa6923244aa9
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Robert Dober
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # lab42\_config
2
+
3
+ Refactor your configuration away
4
+
5
+ ## Configure a Class
6
+
7
+ For details see the corresponding [QED demo](https://github.com/RobertDober/lab42_config/blob/master/demo/class.md).
8
+
@@ -0,0 +1,15 @@
1
+ require_relative 'instance'
2
+
3
+ module Lab42
4
+ module Config
5
+ module ClassMethods
6
+ def config &blk
7
+ __config__.instance_exec &blk
8
+ __config__.freeze!
9
+ end
10
+ def __config__
11
+ @__config__ ||= Lab42::Config::Instance.new
12
+ end
13
+ end # module ClassMethods
14
+ end # module Config
15
+ end # module Lab42
@@ -0,0 +1,23 @@
1
+ module Lab42
2
+ module Config
3
+ class Instance < BasicObject
4
+
5
+ def freeze!
6
+ __values__.freeze
7
+ end
8
+ private
9
+ def method_missing name, *args, &blk
10
+ super if args.size > 1
11
+ return __values__.fetch( name ){ super } if args.empty? && blk.!
12
+
13
+ __values__[ name ] = args.first || instance_exec(&blk)
14
+ end
15
+
16
+ def __values__
17
+ @__values__ ||= {}
18
+ end
19
+
20
+
21
+ end # class Instance
22
+ end # module Config
23
+ end # module Lab42
@@ -0,0 +1,5 @@
1
+ module Lab42
2
+ module Config
3
+ VERSION = '0.0.1'
4
+ end
5
+ end # module Lab42
@@ -0,0 +1,14 @@
1
+ require_relative 'config/class_methods'
2
+
3
+ module Lab42
4
+ module Config
5
+
6
+ def self.included into
7
+ into.extend ClassMethods
8
+ end
9
+ def configuration
10
+ self.class.__config__
11
+ end
12
+
13
+ end # module Config
14
+ end # module Lab42
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lab42_config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Robert Dober
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: forwarder2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-nav
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: qed
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ae
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: travis-lint
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ description: Define configuration values with defaults and lazy evaluation on a per
112
+ class or per instance level
113
+ email: robert.dober@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - LICENSE
119
+ - README.md
120
+ - lib/lab42/config.rb
121
+ - lib/lab42/config/class_methods.rb
122
+ - lib/lab42/config/instance.rb
123
+ - lib/lab42/config/version.rb
124
+ homepage: https://github.com/RobertDober/lab42_config
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 2.0.0
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.2.2
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Refactor your configuration code away!
148
+ test_files: []