ruby-conf 0.0.0 → 0.1.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/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/VERSION +1 -1
- data/lib/ruby-conf.rb +60 -0
- data/ruby-conf.gemspec +5 -2
- data/spec/lib/ruby-conf_spec.rb +80 -0
- data/spec/spec_helper.rb +2 -1
- metadata +30 -14
- data/spec/ruby-conf_spec.rb +0 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,6 +13,7 @@ GEM
|
|
13
13
|
rcov (1.0.0)
|
14
14
|
rdoc (3.12)
|
15
15
|
json (~> 1.4)
|
16
|
+
rr (1.0.4)
|
16
17
|
rspec (2.8.0)
|
17
18
|
rspec-core (~> 2.8.0)
|
18
19
|
rspec-expectations (~> 2.8.0)
|
@@ -31,5 +32,6 @@ DEPENDENCIES
|
|
31
32
|
jeweler (~> 1.8.3)
|
32
33
|
rcov
|
33
34
|
rdoc (~> 3.12)
|
35
|
+
rr (~> 1.0.4)
|
34
36
|
rspec (~> 2.8.0)
|
35
37
|
yard (~> 0.7)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/ruby-conf.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
class RubyConf
|
2
|
+
@@configs = {}
|
3
|
+
|
4
|
+
class Config
|
5
|
+
def initialize
|
6
|
+
@attributes = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(name, *args, &block)
|
10
|
+
case(args.size)
|
11
|
+
when 0:
|
12
|
+
if @attributes.has_key? name.to_sym
|
13
|
+
value = @attributes[name.to_sym]
|
14
|
+
|
15
|
+
if value.is_a?(Proc)
|
16
|
+
value.call
|
17
|
+
else
|
18
|
+
value
|
19
|
+
end
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
when 1:
|
24
|
+
@attributes[name.to_sym] = args.first
|
25
|
+
else
|
26
|
+
@attributes[name.to_sym] = args
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def respond_to?(name)
|
31
|
+
if @attributes.has_key? name.to_sym
|
32
|
+
true
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.define(name, &block)
|
40
|
+
@@configs[name.to_sym] = Config.new
|
41
|
+
|
42
|
+
@@configs[name.to_sym].instance_eval &block
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.method_missing(name, *args, &block)
|
46
|
+
if @@configs.has_key? name.to_sym
|
47
|
+
@@configs[name.to_sym]
|
48
|
+
else
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.respond_to?(name)
|
54
|
+
if @@configs.has_key? name.to_sym
|
55
|
+
true
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/ruby-conf.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-conf}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Curtis Schofield & Hollin Wilkins"]
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"VERSION",
|
29
29
|
"lib/ruby-conf.rb",
|
30
30
|
"ruby-conf.gemspec",
|
31
|
-
"spec/ruby-conf_spec.rb",
|
31
|
+
"spec/lib/ruby-conf_spec.rb",
|
32
32
|
"spec/spec_helper.rb"
|
33
33
|
]
|
34
34
|
s.homepage = %q{http://github.com/blazingpair/ruby-conf}
|
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
|
43
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
44
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
45
|
+
s.add_development_dependency(%q<rr>, ["~> 1.0.4"])
|
45
46
|
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
46
47
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
47
48
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
|
|
49
50
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
50
51
|
else
|
51
52
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
53
|
+
s.add_dependency(%q<rr>, ["~> 1.0.4"])
|
52
54
|
s.add_dependency(%q<yard>, ["~> 0.7"])
|
53
55
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
54
56
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -57,6 +59,7 @@ Gem::Specification.new do |s|
|
|
57
59
|
end
|
58
60
|
else
|
59
61
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
62
|
+
s.add_dependency(%q<rr>, ["~> 1.0.4"])
|
60
63
|
s.add_dependency(%q<yard>, ["~> 0.7"])
|
61
64
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
65
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ruby-conf'
|
3
|
+
|
4
|
+
# write it
|
5
|
+
#
|
6
|
+
#RubyConf.define "namespace" do
|
7
|
+
# thingy 'aoeuaoe'
|
8
|
+
#end
|
9
|
+
#
|
10
|
+
## read it
|
11
|
+
#
|
12
|
+
#RubyConf.namespace.thingy
|
13
|
+
|
14
|
+
|
15
|
+
describe RubyConf do
|
16
|
+
subject { RubyConf }
|
17
|
+
|
18
|
+
describe ".define" do
|
19
|
+
it "defines a new configuration with a given name" do
|
20
|
+
subject.define "thing" do end
|
21
|
+
subject.should respond_to(:thing)
|
22
|
+
end
|
23
|
+
it "sets a variable in new configuration with a given name to a value" do
|
24
|
+
subject.define "thing" do
|
25
|
+
honky true
|
26
|
+
end
|
27
|
+
subject.thing.honky.should be_true
|
28
|
+
end
|
29
|
+
describe "namespace with attribute with lambda arg" do
|
30
|
+
before do
|
31
|
+
subject.define 'with_llama' do
|
32
|
+
get_wool lambda {
|
33
|
+
@shear_count = @shear_count.to_i + 1
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
it "should return the value of lambda" do
|
38
|
+
subject.with_llama.get_wool.should == 1
|
39
|
+
end
|
40
|
+
it "should return the value of lambda dynamicly" do
|
41
|
+
subject.with_llama.get_wool.should == 1
|
42
|
+
subject.with_llama.get_wool.should == 2
|
43
|
+
subject.with_llama.get_wool.should == 3
|
44
|
+
end
|
45
|
+
end
|
46
|
+
describe "namespace with attribute with extra args" do
|
47
|
+
before do
|
48
|
+
subject.define "namespace" do
|
49
|
+
attribute "hello", "tiny" , "tim"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
it "sets an array" do
|
53
|
+
subject.namespace.attribute.should == %w(hello tiny tim)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
describe "namespaced to 'cake' with flour and water" do
|
57
|
+
before do
|
58
|
+
subject.define "cake" do
|
59
|
+
flour "1 cup"
|
60
|
+
water "1/3 cup"
|
61
|
+
skim_milk "2/3 cup"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
it "cake has 1 cup of flour" do
|
65
|
+
subject.cake.flour.should == '1 cup'
|
66
|
+
end
|
67
|
+
it "cake has 1 cup of water" do
|
68
|
+
subject.cake.water.should == '1/3 cup'
|
69
|
+
end
|
70
|
+
it "responds to skim_milk" do
|
71
|
+
subject.cake.should respond_to(:skim_milk)
|
72
|
+
end
|
73
|
+
it "our cake has no bees and raises NameError" do
|
74
|
+
lambda do
|
75
|
+
subject.cake.bees
|
76
|
+
end.should raise_error NameError
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
|
+
require 'rr'
|
4
5
|
require 'ruby-conf'
|
5
6
|
|
6
7
|
# Requires supporting files with custom matchers and macros, etc,
|
@@ -8,5 +9,5 @@ require 'ruby-conf'
|
|
8
9
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
10
|
|
10
11
|
RSpec.configure do |config|
|
11
|
-
|
12
|
+
config.mock_with :rr
|
12
13
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Curtis Schofield & Hollin Wilkins
|
@@ -36,9 +36,25 @@ dependencies:
|
|
36
36
|
requirement: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
prerelease: false
|
39
|
-
name:
|
39
|
+
name: rr
|
40
40
|
type: :development
|
41
41
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 31
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 0
|
50
|
+
- 4
|
51
|
+
version: 1.0.4
|
52
|
+
requirement: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
name: yard
|
56
|
+
type: :development
|
57
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
42
58
|
none: false
|
43
59
|
requirements:
|
44
60
|
- - ~>
|
@@ -48,12 +64,12 @@ dependencies:
|
|
48
64
|
- 0
|
49
65
|
- 7
|
50
66
|
version: "0.7"
|
51
|
-
requirement: *
|
67
|
+
requirement: *id003
|
52
68
|
- !ruby/object:Gem::Dependency
|
53
69
|
prerelease: false
|
54
70
|
name: rdoc
|
55
71
|
type: :development
|
56
|
-
version_requirements: &
|
72
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
58
74
|
requirements:
|
59
75
|
- - ~>
|
@@ -63,12 +79,12 @@ dependencies:
|
|
63
79
|
- 3
|
64
80
|
- 12
|
65
81
|
version: "3.12"
|
66
|
-
requirement: *
|
82
|
+
requirement: *id004
|
67
83
|
- !ruby/object:Gem::Dependency
|
68
84
|
prerelease: false
|
69
85
|
name: bundler
|
70
86
|
type: :development
|
71
|
-
version_requirements: &
|
87
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
72
88
|
none: false
|
73
89
|
requirements:
|
74
90
|
- - ~>
|
@@ -79,12 +95,12 @@ dependencies:
|
|
79
95
|
- 0
|
80
96
|
- 0
|
81
97
|
version: 1.0.0
|
82
|
-
requirement: *
|
98
|
+
requirement: *id005
|
83
99
|
- !ruby/object:Gem::Dependency
|
84
100
|
prerelease: false
|
85
101
|
name: jeweler
|
86
102
|
type: :development
|
87
|
-
version_requirements: &
|
103
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
88
104
|
none: false
|
89
105
|
requirements:
|
90
106
|
- - ~>
|
@@ -95,12 +111,12 @@ dependencies:
|
|
95
111
|
- 8
|
96
112
|
- 3
|
97
113
|
version: 1.8.3
|
98
|
-
requirement: *
|
114
|
+
requirement: *id006
|
99
115
|
- !ruby/object:Gem::Dependency
|
100
116
|
prerelease: false
|
101
117
|
name: rcov
|
102
118
|
type: :development
|
103
|
-
version_requirements: &
|
119
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
104
120
|
none: false
|
105
121
|
requirements:
|
106
122
|
- - ">="
|
@@ -109,7 +125,7 @@ dependencies:
|
|
109
125
|
segments:
|
110
126
|
- 0
|
111
127
|
version: "0"
|
112
|
-
requirement: *
|
128
|
+
requirement: *id007
|
113
129
|
description: rubyconf is a ruby configuration dsl that aims to make it simple to write and read configurations for ruby apps without a yaml or xml file
|
114
130
|
email: blazingpair@blazingcloud.net
|
115
131
|
executables: []
|
@@ -131,7 +147,7 @@ files:
|
|
131
147
|
- VERSION
|
132
148
|
- lib/ruby-conf.rb
|
133
149
|
- ruby-conf.gemspec
|
134
|
-
- spec/ruby-conf_spec.rb
|
150
|
+
- spec/lib/ruby-conf_spec.rb
|
135
151
|
- spec/spec_helper.rb
|
136
152
|
has_rdoc: true
|
137
153
|
homepage: http://github.com/blazingpair/ruby-conf
|