garnish 0.0.4 → 0.0.5
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/CHANGELOG.rdoc +5 -0
- data/Gemfile +0 -1
- data/Guardfile +1 -21
- data/lib/garnish/collection.rb +15 -7
- data/lib/garnish/version.rb +1 -1
- data/spec/garnish/collection_spec.rb +14 -3
- metadata +6 -6
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,24 +1,4 @@
|
|
1
|
-
guard '
|
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" }
|
data/lib/garnish/collection.rb
CHANGED
@@ -13,18 +13,26 @@ module Garnish
|
|
13
13
|
@template = template
|
14
14
|
end
|
15
15
|
|
16
|
-
# Call
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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)
|
data/lib/garnish/version.rb
CHANGED
@@ -10,9 +10,20 @@ describe Garnish::Collection do
|
|
10
10
|
collection.relation.should eq(relation)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
collection.
|
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
|
+
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *70136304742880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
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: *
|
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:
|