dbuilder 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +7 -0
- data/builder.rb +44 -0
- data/dbuilder.gemspec +26 -0
- data/lib/dbuilder.rb +2 -0
- data/lib/dbuilder/builder.rb +55 -0
- data/lib/dbuilder/version.rb +3 -0
- data/meta_builder.rb +56 -0
- data/spec/dbuilder_spec.rb +14 -0
- data/spec/integration_spec.rb +40 -0
- data/spec/lib/builder_spec.rb +182 -0
- data/spec/spec_helper.rb +3 -0
- metadata +169 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use 1.9.3@dbuilder
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jeremy W. Rowe
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Dbuilder
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dbuilder'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dbuilder
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
def SomeBuilder
|
23
|
+
extend Dbuilder::Builder
|
24
|
+
builder_default :meth_name, "meth value"
|
25
|
+
end
|
26
|
+
|
27
|
+
klazz = SomeBuilder.build # This will return a class 'Some' with the method meth_name
|
28
|
+
klazz.new # to create an instance of the class
|
29
|
+
|
30
|
+
def SomeOtherBuilder
|
31
|
+
extend Dbuilder::Builder
|
32
|
+
builder_defaults :m1, 1, :m2, 2, :m3, "terrible movie"
|
33
|
+
end
|
34
|
+
|
35
|
+
# this is an example of the short hand way of creating multiple builder_default calls
|
36
|
+
```
|
37
|
+
|
38
|
+
### builder\_default method
|
39
|
+
* This method can be used as many times as you want inside of a builder class declaration
|
40
|
+
* The first param is the method name
|
41
|
+
|
42
|
+
### builder\_defaults method
|
43
|
+
* This method can be used as many times as you want inside of a builder class declaration
|
44
|
+
* This takes touples of method name, value
|
45
|
+
|
46
|
+
### \_with methods
|
47
|
+
* For each method defined with builder\_default or builder\_defaults
|
48
|
+
there is a matching \_with method.
|
49
|
+
* the purpose of the \_with methods is to override the default return value of the method
|
50
|
+
* Example:
|
51
|
+
```ruby
|
52
|
+
def SomeBuilder
|
53
|
+
extend Dbuilder::Builder
|
54
|
+
builder_default :meth, "meth value"
|
55
|
+
end
|
56
|
+
|
57
|
+
SomeBuilder.with_meth("head").build
|
58
|
+
|
59
|
+
# This would build up a class of Some with an instance method of meth, and its return value be "head" as apposed to "meth value"
|
60
|
+
```
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
1. Fork it
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/builder.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class Builder
|
2
|
+
def self.with_first_name(first_name)
|
3
|
+
@first_name = first_name
|
4
|
+
self
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.with_last_name(last_name)
|
8
|
+
@last_name = last_name
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.with_age(age)
|
13
|
+
@age = age
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.with_sex(sex)
|
18
|
+
@sex = sex
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.build
|
23
|
+
props = {
|
24
|
+
first_name: @first_name || 'Sally',
|
25
|
+
last_name: @last_name || 'Smith',
|
26
|
+
age: @age || 1,
|
27
|
+
sex: @sex || 'F'
|
28
|
+
}
|
29
|
+
Human.new props
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
class Human
|
35
|
+
attr_reader :first_name, :last_name, :age, :sex
|
36
|
+
def initialize(args = {})
|
37
|
+
@first_name = args[:first_name]
|
38
|
+
@last_name = args[:last_name]
|
39
|
+
@age = args[:age]
|
40
|
+
@sex = args[:sex]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/dbuilder.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dbuilder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "dbuilder"
|
8
|
+
gem.version = Dbuilder::VERSION
|
9
|
+
gem.authors = ["Jeremy W. Rowe"]
|
10
|
+
gem.email = ["jeremy.w.rowe@gmail.com"]
|
11
|
+
gem.description = %q{Simple builder pattern injection for ruby}
|
12
|
+
gem.summary = %q{This is a toy gem used to harness the power of the builder pattern in the ruby environment.}
|
13
|
+
gem.homepage = "http://github.com/jeremywrowe/dbuilder"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency('rake')
|
21
|
+
gem.add_development_dependency('guard')
|
22
|
+
gem.add_development_dependency('guard-minitest')
|
23
|
+
gem.add_development_dependency('rb-fsevent', '~> 0.9.1')
|
24
|
+
gem.add_development_dependency('growl')
|
25
|
+
gem.add_development_dependency('pry')
|
26
|
+
end
|
data/lib/dbuilder.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Dbuilder::Builder
|
2
|
+
|
3
|
+
def self.extended(klass)
|
4
|
+
validate_class_name klass.name
|
5
|
+
construct_builder_hashes klass.name.gsub(/builder$/i, "")
|
6
|
+
end
|
7
|
+
|
8
|
+
def builder_default(key, value)
|
9
|
+
klazz = class << self; self; end
|
10
|
+
Thread.current["#{self.class_name}_builder_defaults"][key.to_sym] = value
|
11
|
+
klazz.send(:define_method, "with_#{key}".to_sym) do |overridden_value|
|
12
|
+
Thread.current["#{self.class_name}_builder_overrides"][key.to_sym] = overridden_value
|
13
|
+
self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def builder_defaults(*defaults)
|
18
|
+
raise "bulder_defaults expects pair arguments example: builder_defaults key, value, key, value ..." unless defaults.size % 2 == 0
|
19
|
+
defaults.each_slice 2 do |pie|
|
20
|
+
builder_default pie[0], pie[1]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def class_name
|
25
|
+
name.gsub(/builder$/i, "")
|
26
|
+
end
|
27
|
+
|
28
|
+
def build
|
29
|
+
defaults = Thread.current["#{class_name}_builder_defaults"]
|
30
|
+
overrides = Thread.current["#{class_name}_builder_overrides"]
|
31
|
+
properties = defaults.merge overrides
|
32
|
+
obj =\
|
33
|
+
begin
|
34
|
+
Kernel.const_get class_name
|
35
|
+
rescue
|
36
|
+
Object.const_set class_name, Class.new
|
37
|
+
end
|
38
|
+
properties.each {|k,v| obj.send(:define_method, k.to_sym){v} }
|
39
|
+
obj
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def self.validate_class_name(name)
|
45
|
+
unless name.end_with? "Builder"
|
46
|
+
raise "The extending class must have 'Builder' at the end of the class name"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.construct_builder_hashes(class_name)
|
51
|
+
class_name
|
52
|
+
Thread.current["#{class_name}_builder_defaults"] = Hash.new
|
53
|
+
Thread.current["#{class_name}_builder_overrides"] = Hash.new
|
54
|
+
end
|
55
|
+
end
|
data/meta_builder.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module MetaBuilder
|
2
|
+
|
3
|
+
def self.extended(klass)
|
4
|
+
name = klass.name.gsub(/builder$/i, "")
|
5
|
+
raise "The extending class must have 'Builder' on the class name" unless klass.name.downcase.include? "builder"
|
6
|
+
Thread.current["#{name.downcase}_builder_defaults"] = Hash.new
|
7
|
+
Thread.current["#{name.downcase}_builder_override"] = Hash.new
|
8
|
+
klass.instance_variable_set("@_builder_name", name)
|
9
|
+
Kernel.const_set name, Class
|
10
|
+
end
|
11
|
+
|
12
|
+
def builder_defaults(*defaults)
|
13
|
+
raise "bulder_defaults expects pair arguments example: builder_defaults key, value, key, value ..." unless defaults.size % 2 == 0
|
14
|
+
defaults.each_slice(2) do |pie|
|
15
|
+
builder_default pie[0], pie[1]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def builder_default(key, val)
|
20
|
+
klazz = class << self; self; end
|
21
|
+
name = @_builder_name.downcase
|
22
|
+
klazz.send(:define_method, "with_#{key}".to_sym) do |overridden_val|
|
23
|
+
Thread.current["#{name}_builder_defaults"][key.to_sym] = val
|
24
|
+
Thread.current["#{name}_builder_override"][key.to_sym] = overridden_val
|
25
|
+
return self
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def build
|
30
|
+
name = @_builder_name.downcase
|
31
|
+
klazz = Kernel.const_get @_builder_name
|
32
|
+
#klazz.instance_eval do
|
33
|
+
defaults = Thread.current["#{name}_builder_defaults"]
|
34
|
+
override = Thread.current["#{name}_builder_override"]
|
35
|
+
properties = defaults.merge override
|
36
|
+
properties.each do |key, value|
|
37
|
+
klazz.send(:define_method, key.to_sym) do
|
38
|
+
value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
#end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class FooBuilder
|
48
|
+
extend MetaBuilder
|
49
|
+
builder_defaults :foo, 'bar', :bar, 'drank'
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
other_instance = FooBuilder.build
|
54
|
+
instance = FooBuilder.with_foo('zoo').with_bar('d').build
|
55
|
+
|
56
|
+
puts other_instance.instance_methods.grep /foo/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
require_relative '../lib/dbuilder'
|
3
|
+
|
4
|
+
describe Dbuilder do
|
5
|
+
|
6
|
+
it "has the correct version" do
|
7
|
+
Dbuilder::VERSION.must_equal "0.5.0"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should include Dbuilder::Builder" do
|
11
|
+
defined?(Dbuilder::Builder).must_equal "constant"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
require 'dbuilder'
|
3
|
+
|
4
|
+
describe "Dbuilder Gem integration" do
|
5
|
+
|
6
|
+
it "creates an object that can be built up with a builder" do
|
7
|
+
objekt = AbcBuilder.build.new
|
8
|
+
objekt.letters.must_equal "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "plays nice in a threaded environment threads" do
|
12
|
+
results = []
|
13
|
+
1000.times do
|
14
|
+
results << Thread.new do
|
15
|
+
Thread.current['test_val'] = rand(100)
|
16
|
+
class ValBuilder
|
17
|
+
extend Dbuilder::Builder
|
18
|
+
builder_defaults :values, (1..(Thread.current['test_val'] + 1))
|
19
|
+
end
|
20
|
+
|
21
|
+
sleep 0.5
|
22
|
+
ValBuilder.build.new.values.must_equal((1..(Thread.current['test_val'] + 1)))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
results.each{|t| t.join}
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
class Abc
|
30
|
+
def letters
|
31
|
+
Array(letters_of_the_alphabet).join(",")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class AbcBuilder
|
36
|
+
extend Dbuilder::Builder
|
37
|
+
builder_defaults :letters_of_the_alphabet, ("a".."z")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/dbuilder'
|
3
|
+
require_relative '../../lib/dbuilder/builder.rb'
|
4
|
+
|
5
|
+
describe Dbuilder::Builder do
|
6
|
+
|
7
|
+
describe ".extended" do
|
8
|
+
it "should throw an exception if the extended class does not have 'Builder' at the end of it's name" do
|
9
|
+
lambda { class Foo; extend Dbuilder::Builder; end }.must_raise(RuntimeError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should throw an exception if the exteded class has the builder name at the begining of it's class name instead of the end" do
|
13
|
+
lambda { class BuilderFoo; extend Dbuilder::Builder; end }.must_raise(RuntimeError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not throw an exception if the extending class has 'Builder' at the end it's class name" do
|
17
|
+
lambda { class FooBuilder; extend Dbuilder::Builder; end }.must_be_silent
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have empty hashes for storing defaults / overridden builder methods" do
|
21
|
+
Thread.current["Test_builder_defaults"].must_equal Hash.new
|
22
|
+
Thread.current["Test_builder_overrides"].must_equal Hash.new
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have empty hashes for storing defaults / overridden builder methods for a second class" do
|
26
|
+
Thread.current["OtherTest_builder_defaults"].must_equal Hash.new
|
27
|
+
Thread.current["OtherTest_builder_overrides"].must_equal Hash.new
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should create the correct class_name method" do
|
31
|
+
class FooBarBuilder
|
32
|
+
extend Dbuilder::Builder
|
33
|
+
end.must_respond_to "class_name"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return the correct value from class_name method" do
|
37
|
+
class FooBarBuilder
|
38
|
+
extend Dbuilder::Builder
|
39
|
+
end
|
40
|
+
FooBarBuilder.class_name.must_equal "FooBar"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".builder_default" do
|
46
|
+
it "responds properly from to an extending class" do
|
47
|
+
TestBuilder.must_respond_to "builder_default"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should define the proper with_ method" do
|
51
|
+
SimpleExtensionBuilder.must_respond_to "with_tom"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have chainable _with methods" do
|
55
|
+
SimpleExtensionBuilder.with_tom("jones").must_equal SimpleExtensionBuilder
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have the proper default should be defined" do
|
59
|
+
Thread.current["SimpleExtension_builder_defaults"].must_equal({tom: "cat"})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be able to change the values of the overridden values" do
|
63
|
+
class OverriddenDefaultValuesBuilder
|
64
|
+
extend Dbuilder::Builder
|
65
|
+
builder_default :foo, 'bar'
|
66
|
+
end
|
67
|
+
OverriddenDefaultValuesBuilder.with_foo("zooooo")
|
68
|
+
Thread.current["OverriddenDefaultValues_builder_overrides"].must_equal({foo: "zooooo"})
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should have the correct default after an override occurs" do
|
72
|
+
class OverriddenDefaultValuesBuilder
|
73
|
+
extend Dbuilder::Builder
|
74
|
+
builder_default :foo, 'bar'
|
75
|
+
end
|
76
|
+
OverriddenDefaultValuesBuilder.with_foo("zooooo")
|
77
|
+
Thread.current["OverriddenDefaultValues_builder_defaults"].must_equal({foo: "bar"})
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should be able to handle multiple builder_default calls" do
|
81
|
+
class OverriddenDefaultValuesBuilder
|
82
|
+
extend Dbuilder::Builder
|
83
|
+
builder_default :foo, 'bar'
|
84
|
+
builder_default :zoo, 'moo'
|
85
|
+
builder_default :kitty, 'meow'
|
86
|
+
end
|
87
|
+
Thread.current["OverriddenDefaultValues_builder_defaults"].must_equal({foo: "bar", zoo: "moo", kitty: "meow"})
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe ".builder_defaults" do
|
92
|
+
it "responds properly to an extending class" do
|
93
|
+
TestBuilder.must_respond_to "builder_defaults"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should raise an error if an even amount of params are not passed in" do
|
97
|
+
lambda {
|
98
|
+
class FooBuilder
|
99
|
+
extend Dbuilder::Builder
|
100
|
+
builder_defaults :foo
|
101
|
+
end
|
102
|
+
}.must_raise(RuntimeError)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should not raise an error if an even number of params are passed in" do
|
106
|
+
lambda {
|
107
|
+
class FooBuilder
|
108
|
+
extend Dbuilder::Builder
|
109
|
+
builder_defaults :foo, "bar"
|
110
|
+
end
|
111
|
+
}.must_be_silent
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should not raise an error if a large even number of params are passed in" do
|
115
|
+
lambda {
|
116
|
+
class FooBuilder
|
117
|
+
extend Dbuilder::Builder
|
118
|
+
builder_defaults :foo, "bar", :zoo, "moo", :dick, "tracy", "ronald", "mcdonald"
|
119
|
+
end
|
120
|
+
}.must_be_silent
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should have all of the proper _with methods" do
|
124
|
+
class FooBuilder
|
125
|
+
extend Dbuilder::Builder
|
126
|
+
builder_defaults :foo, "bar", :zoo, "moo", :dick, "tracy", "ronald", "mcdonald"
|
127
|
+
end
|
128
|
+
FooBuilder.must_respond_to "with_foo"
|
129
|
+
FooBuilder.must_respond_to "with_zoo"
|
130
|
+
FooBuilder.must_respond_to "with_dick"
|
131
|
+
FooBuilder.must_respond_to "with_ronald"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe ".build" do
|
136
|
+
|
137
|
+
it "should create the appropriate class" do
|
138
|
+
SimpleExtensionBuilder.build.must_equal SimpleExtension
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should respond to the appropriate methods" do
|
142
|
+
target = SimpleExtensionBuilder.build.new
|
143
|
+
target.must_respond_to :tom
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should have the correct values for the default methods" do
|
147
|
+
target = SimpleExtensionBuilder.build.new
|
148
|
+
target.tom.must_equal "cat"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "it appends to existing classes" do
|
152
|
+
OriginalBuilder.build.new.must_respond_to "gangsta"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
class Original
|
159
|
+
def gangsta
|
160
|
+
"Biggy Smalls"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
class OriginalBuilder
|
165
|
+
extend Dbuilder::Builder
|
166
|
+
builder_defaults :ja, "rule"
|
167
|
+
end
|
168
|
+
|
169
|
+
class TestBuilder
|
170
|
+
extend Dbuilder::Builder
|
171
|
+
end
|
172
|
+
|
173
|
+
class OtherTestBuilder
|
174
|
+
extend Dbuilder::Builder
|
175
|
+
end
|
176
|
+
|
177
|
+
class SimpleExtensionBuilder
|
178
|
+
extend Dbuilder::Builder
|
179
|
+
builder_default "tom", "cat"
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dbuilder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeremy W. Rowe
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-minitest
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rb-fsevent
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.9.1
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: growl
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: pry
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Simple builder pattern injection for ruby
|
111
|
+
email:
|
112
|
+
- jeremy.w.rowe@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rvmrc
|
119
|
+
- Gemfile
|
120
|
+
- Guardfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- builder.rb
|
125
|
+
- dbuilder.gemspec
|
126
|
+
- lib/dbuilder.rb
|
127
|
+
- lib/dbuilder/builder.rb
|
128
|
+
- lib/dbuilder/version.rb
|
129
|
+
- meta_builder.rb
|
130
|
+
- spec/dbuilder_spec.rb
|
131
|
+
- spec/integration_spec.rb
|
132
|
+
- spec/lib/builder_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
homepage: http://github.com/jeremywrowe/dbuilder
|
135
|
+
licenses: []
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
hash: -1814299444136315727
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: -1814299444136315727
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.24
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: This is a toy gem used to harness the power of the builder pattern in the
|
164
|
+
ruby environment.
|
165
|
+
test_files:
|
166
|
+
- spec/dbuilder_spec.rb
|
167
|
+
- spec/integration_spec.rb
|
168
|
+
- spec/lib/builder_spec.rb
|
169
|
+
- spec/spec_helper.rb
|