jelly_bird 0.0.5 → 0.0.6

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/Readme.md CHANGED
@@ -75,7 +75,14 @@ remember that if you wanna embbed one into another please don't specify them at
75
75
 
76
76
  Now just use it in tests!
77
77
 
78
- $ Powered by
78
+ # Changlelog
79
+
80
+ 0.0.6 - Added ability for `.gen` and `.generate` to take blocks which receives object to make things aka `save`
81
+ 0.0.5 - Fixed bugs
82
+ 0.0.4 - Yanked version
83
+ 0.0.1 -> 0.0.3 - Initial release
84
+
85
+ # Powered by
79
86
  It is powered by `randexp` gem and initial concept was based on `dm-sweatshop` syntax. Big thanks to this two projects.
80
87
 
81
88
 
@@ -2,15 +2,16 @@ module JellyBird
2
2
 
3
3
  module Generate
4
4
 
5
- def gen(opts = {})
6
- generate(:default, opts)
5
+ def gen(opts = {}, &block)
6
+ generate(:default, opts, &block)
7
7
  end
8
8
 
9
- def generate(name = :default, opts = {})
9
+ def generate(name = :default, opts = {}, &block)
10
10
  options = self::generator(name).call if self::generator(name)
11
11
  options.merge!(opts)
12
12
  obj = self.new(options)
13
- options.each_pair { |key, value| obj[key] = value } if obj.kind_of?(Hash)
13
+ options.each_pair { |key, value| obj[key] = value } if obj.kind_of?(Hash)
14
+ yield(obj) if block_given?
14
15
  obj
15
16
  end
16
17
 
@@ -1,3 +1,3 @@
1
1
  module JellyBird
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -7,6 +7,10 @@ class Mummy
7
7
  self.attributes = opts
8
8
  end
9
9
 
10
+ def bandage
11
+ self.attributes[:bandage] = true
12
+ end
13
+
10
14
  end
11
15
 
12
16
  class Dummy < Hash; end
@@ -119,6 +123,12 @@ describe JellyBird do
119
123
 
120
124
  end
121
125
 
126
+ it "should be able to run bandage within gen " do
127
+ mummy = Mummy.gen {|mummy| mummy.bandage }
128
+ mummy.should be_kind_of(Mummy)
129
+ mummy.attributes[:bandage].should be_true
130
+ end
131
+
122
132
  end
123
133
 
124
134
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jelly_bird
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - JO
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-12 00:00:00 +01:00
18
+ date: 2011-09-02 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency