hash_dealer 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/hash_dealer.gemspec +2 -2
- data/lib/hash_dealer.rb +4 -2
- data/spec/lib/hash_dealer_spec.rb +8 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.2
|
data/hash_dealer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hash_dealer}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dan Langevin"]
|
12
|
-
s.date = %q{2011-08-
|
12
|
+
s.date = %q{2011-08-22}
|
13
13
|
s.description = %q{Like Factory Girl but for Hashes only}
|
14
14
|
s.email = %q{dan.langevin@lifebooker.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/hash_dealer.rb
CHANGED
@@ -18,7 +18,7 @@ class HashDealer
|
|
18
18
|
|
19
19
|
def self.roll(name, *args)
|
20
20
|
raise Exception.new("No HashDealer called #{name}") unless self.hashes[name]
|
21
|
-
self.hashes[name].
|
21
|
+
self.hashes[name]._attributes(*args)
|
22
22
|
end
|
23
23
|
|
24
24
|
# initializer just calls the block from within our DSL
|
@@ -31,8 +31,10 @@ class HashDealer
|
|
31
31
|
def root(value)
|
32
32
|
@attributes = value
|
33
33
|
end
|
34
|
+
|
34
35
|
# get the stored attributes for this HashDealer
|
35
|
-
def
|
36
|
+
def _attributes(*args)
|
37
|
+
|
36
38
|
# allows us to set a root value
|
37
39
|
return @attributes unless @attributes.is_a?(Hash)
|
38
40
|
att = @parent ? HashDealer.roll(@parent.to_sym) : Hash.new
|
@@ -103,5 +103,12 @@ describe HashDealer do
|
|
103
103
|
end
|
104
104
|
HashDealer.roll(:variable).matcher.should eql([{:abc => ":123", :deff => ":1234"}])
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
|
+
it "should allow defining a hash where one of the keys is attributes" do
|
108
|
+
HashDealer.define(:test) do
|
109
|
+
attributes("test")
|
110
|
+
end
|
111
|
+
HashDealer.roll(:test)[:attributes].should eql("test")
|
112
|
+
HashDealer.roll(:test).matcher[:attributes].should eql(":test")
|
113
|
+
end
|
107
114
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hash_dealer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Langevin
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
hash:
|
132
|
+
hash: 2268842333028353407
|
133
133
|
segments:
|
134
134
|
- 0
|
135
135
|
version: "0"
|