garnish 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ 0.0.5 (February 29, 2012)
2
+
3
+ * Remove cruft from Guardfile so Guard works again. Fix broken tests from last
4
+ push.
5
+
1
6
  0.0.4 (February 16, 2012)
2
7
 
3
8
  * Overhaul on how relationships are manager by a Collection class now.
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ gem 'i18n' #Why doesn't activesupport require this?
8
8
  group :development do
9
9
  gem 'guard'
10
10
  gem 'guard-rspec'
11
- gem 'guard-spin'
12
11
  end
13
12
 
14
13
  gemspec
data/Guardfile CHANGED
@@ -1,24 +1,4 @@
1
- guard 'bundler' do
2
- watch('Gemfile')
3
- # Uncomment next line if Gemfile contain `gemspec' command
4
- # watch(/^.+\.gemspec/)
5
- end
6
-
7
- guard 'spin' do
8
- # uses the .rspec file
9
- # --colour --fail-fast --format documentation --tag ~slow
10
- watch(%r{^spec/.+_spec\.rb})
11
- watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
12
- watch(%r{^app/(.+)\.haml}) { |m| "spec/#{m[1]}.haml_spec.rb" }
13
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
- watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
15
- watch('Gemfile')
16
- watch('Gemfile.lock')
17
- watch('spec/spec_helper.rb')
18
- watch('Guardfile')
19
- end
20
-
21
- guard 'rspec', :cli => "--color --order random", :version => 2, :rvm => ['1.9.3'] do
1
+ guard 'rspec', :cli => "--color --order random", :version => 2 do
22
2
  watch(%r{^spec/.+_spec\.rb$})
23
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
24
4
  watch('spec/spec_helper.rb') { "spec" }
@@ -13,18 +13,26 @@ module Garnish
13
13
  @template = template
14
14
  end
15
15
 
16
- # Call the method on the relation object and then convert the results
16
+ # Call each on the relation and return the block
17
17
  #
18
18
  # @example
19
19
  # blog.posts.each { |post| post.name }
20
20
  #
21
21
  # @return [Collection]
22
- [:to_a, :each].map do |method|
23
- define_method method do
24
- records = @relation.send(method)
25
- convert(records)
26
- records
27
- end
22
+ def each(&block)
23
+ to_a.each { |member| block.call(member) }
24
+ end
25
+
26
+ # Call to_a and return converted records
27
+ #
28
+ # @example
29
+ # blog.posts.each { |post| post.name }
30
+ #
31
+ # @return [Collection]
32
+ def to_a
33
+ records = @relation.to_a
34
+ convert(records)
35
+ records
28
36
  end
29
37
 
30
38
  def respond_to?(method)
@@ -1,3 +1,3 @@
1
1
  module Garnish
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -10,9 +10,20 @@ describe Garnish::Collection do
10
10
  collection.relation.should eq(relation)
11
11
  end
12
12
 
13
- it "should pass the each method to the relation" do
14
- relation.should_receive(:each)
15
- collection.each
13
+ describe "the each method" do
14
+ let(:array) { stub(:array, :each => nil) }
15
+ before { collection.stub(:convert => array) }
16
+
17
+ it "should call to_a" do
18
+ relation.should_receive(:to_a).and_return(array)
19
+ collection.each
20
+ end
21
+
22
+ it "should call each on the resulting array" do
23
+ relation.stub(:to_a => array)
24
+ array.should_receive(:each)
25
+ collection.each
26
+ end
16
27
  end
17
28
 
18
29
  it "should pass the to_a method to the relation" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garnish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-17 00:00:00.000000000 Z
12
+ date: 2012-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70340124404820 !ruby/object:Gem::Requirement
16
+ requirement: &70136304742880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70340124404820
24
+ version_requirements: *70136304742880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70340124404220 !ruby/object:Gem::Requirement
27
+ requirement: &70136304742360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70340124404220
35
+ version_requirements: *70136304742360
36
36
  description: Provides an easy to use and transparent system for implementing the Decorator
37
37
  Pattern
38
38
  email: