config_set 0.1.4

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.
Files changed (4) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +34 -0
  3. data/lib/config_set.rb +48 -0
  4. metadata +81 -0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011 Justin Reagor - cheapRoc
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+
2
+ ConfigSet
3
+ =========
4
+
5
+ ConfigSet is the only configuration utility you'll ever need for your app, ever (I know it'll be mine).
6
+
7
+ At a glance, ConfigSet is just a data structure for storing settings values. I'm hoping that ConfigSet will continue to stay tiny at its core while becoming a general framework for handling configurations using various patterns; persisted, exportable, etc.
8
+
9
+ This library came about while building various gems and realizing I needed a level of abstraction to share between them. I really like the functionality of [ahoward/configuration](https://github.com/ahoward/configuration) and I was largely inspired by it, however I noticed I could do the same thing in six times the size. I also hope to utilize the base in other forms such as being backed by Redis.
10
+
11
+
12
+ Usage
13
+ -----
14
+
15
+ For now just check out the specs until I have time to explain it better. God help you if you can't understand the specs.
16
+
17
+ Install
18
+ -------
19
+
20
+ Once I've released it all you have to do is:
21
+
22
+ `gem install config_set`
23
+
24
+
25
+ Contribute
26
+ ----------
27
+
28
+ * Fork the project.
29
+ * Make your feature addition or bug fix.
30
+ * Messy code is not code, its trash.
31
+ * Add specs/tests for it. Your patch or feature won't be looked at otherwise.
32
+ * Commit, do not mess with Rakefile, version, gemspec, or spec_helper.
33
+ * Send me a pull request on a topic branch in your own repo. I'll include it.
34
+ * Commit rights if you have a lot of tested functionality that's relevant to the roadmap.
data/lib/config_set.rb ADDED
@@ -0,0 +1,48 @@
1
+ class ConfigSet
2
+
3
+ VERSION = '0.1.4'
4
+
5
+ Index = Hash.new
6
+
7
+ def initialize(name)
8
+ @name = name
9
+ end
10
+
11
+ def yielding(&block)
12
+ @yielding = true
13
+ yield
14
+ @yielding = false
15
+ end
16
+
17
+ def self.for(name, &block)
18
+ config = Index[name] ||= ConfigSet.new(name)
19
+ block && config.yielding { config.instance_eval &block }
20
+ config
21
+ end
22
+
23
+ def copy_vars(base)
24
+ (base.instance_variables - [:@name, :@yielding]).each do |name|
25
+ instance_variable_set name, base.instance_variable_get(name)
26
+ end
27
+ end
28
+
29
+ def method_missing(name, *args, &block)
30
+ case
31
+ when name.to_s =~ /\=/
32
+ instance_variable_set("@#{name.to_s.gsub(/\=/, '')}", args[0])
33
+ when @yielding && (args[0] || block)
34
+ if block
35
+ value = ConfigSet.new(name)
36
+ value.copy_vars(self)
37
+ value.yielding { value.instance_eval &block }
38
+ else
39
+ value = args[0]
40
+ end
41
+
42
+ instance_variable_set "@#{name}", value
43
+ when !args[0]
44
+ instance_variable_get "@#{name}"
45
+ end
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: config_set
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 4
9
+ version: 0.1.4
10
+ platform: ruby
11
+ authors:
12
+ - Justin Reagor
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-31 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bacon
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ description: ConfigSet is the only configuration utility you'll ever need for your app, ever
34
+ email:
35
+ - cheapRoc@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/config_set.rb
44
+ - LICENSE
45
+ - README.md
46
+ has_rdoc: true
47
+ homepage: http://github.com/cheapRoc/config_set
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 3
71
+ - 6
72
+ version: 1.3.6
73
+ requirements: []
74
+
75
+ rubyforge_project: config_spec
76
+ rubygems_version: 1.3.7
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: The best way to manage your application's dependencies
80
+ test_files: []
81
+