configurer 0.0.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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/configurer.rb +19 -0
- data/test/helper.rb +10 -0
- data/test/test_configurer.rb +27 -0
- metadata +72 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Joe Edelman and Citizen Logistics, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= configurer
|
2
|
+
|
3
|
+
# to use in your class
|
4
|
+
|
5
|
+
class Foo
|
6
|
+
extend Configurer; config :redis
|
7
|
+
|
8
|
+
def bar
|
9
|
+
redis.set "foo", "bar"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# to set globally
|
15
|
+
|
16
|
+
WORLDWIDE.redis { }
|
17
|
+
|
18
|
+
|
19
|
+
# or to set just for foo
|
20
|
+
|
21
|
+
Foo.config.redis { }
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2010 Joe Edelman, Citizen Logistics, Inc. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "configurer"
|
8
|
+
gem.summary = %Q{a new take on ruby cross-class configuration}
|
9
|
+
gem.email = "joe@citizenlogistics.com"
|
10
|
+
gem.homepage = "http://github.com/jxe/configurer"
|
11
|
+
gem.authors = ["Joe Edelman"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/test_*.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :test => :check_dependencies
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "configable #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/lib/configurer.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# a new take on ruby cross-class configuration
|
2
|
+
|
3
|
+
module Configurer
|
4
|
+
class HashMM < Hash
|
5
|
+
def method_missing(meth, *args, &blk); self[meth] = blk; end
|
6
|
+
end
|
7
|
+
|
8
|
+
::WORLDWIDE = HashMM.new
|
9
|
+
|
10
|
+
def config *syms
|
11
|
+
return @configurer if syms.empty?
|
12
|
+
configurer = @configurer ||= HashMM.new{|h,k| WORLDWIDE[k] }
|
13
|
+
syms.each do |sym|
|
14
|
+
meth = proc{ configurer[sym].call }
|
15
|
+
define_method(sym, &meth)
|
16
|
+
(class << self;self;end).send(:define_method, sym, &meth)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestConfigable < Test::Unit::TestCase
|
4
|
+
should "set a global config" do
|
5
|
+
|
6
|
+
THING = []
|
7
|
+
|
8
|
+
class Foo
|
9
|
+
extend Configurer; config :bar
|
10
|
+
def try
|
11
|
+
raise unless bar == :good
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
WORLDWIDE.bar { THING.push :hi; :good }
|
16
|
+
assert WORLDWIDE[:bar]
|
17
|
+
|
18
|
+
Foo.new.try
|
19
|
+
assert_equal :hi, THING.first
|
20
|
+
assert_equal :good, Foo.bar
|
21
|
+
THING.pop; THING.pop
|
22
|
+
|
23
|
+
Foo.config.bar { THING.push :bye; :good }
|
24
|
+
Foo.new.try
|
25
|
+
raise unless THING.first == :bye
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: configurer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Joe Edelman
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-08 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: joe@citizenlogistics.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- .document
|
32
|
+
- .gitignore
|
33
|
+
- LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- VERSION
|
37
|
+
- lib/configurer.rb
|
38
|
+
- test/helper.rb
|
39
|
+
- test/test_configurer.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/jxe/configurer
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --charset=UTF-8
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.6
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: a new take on ruby cross-class configuration
|
70
|
+
test_files:
|
71
|
+
- test/helper.rb
|
72
|
+
- test/test_configurer.rb
|