ryanb-scope-builder 0.1.0 → 0.1.1

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 CHANGED
@@ -0,0 +1,7 @@
1
+ *0.1.1* (June 26th, 2008)
2
+
3
+ * scope_builder can be called on any Scope
4
+
5
+ *0.1.0* (June 26th, 2008)
6
+
7
+ * initial release
data/Manifest CHANGED
@@ -1,10 +1,12 @@
1
1
  CHANGELOG
2
2
  lib/scope_builder/builder.rb
3
3
  lib/scope_builder/model_additions.rb
4
+ lib/scope_builder/scope_additions.rb
4
5
  lib/scope_builder.rb
5
6
  LICENSE
6
7
  Manifest
7
8
  README
9
+ scope-builder.gemspec
8
10
  spec/models/product.rb
9
11
  spec/scope_builder/builder_spec.rb
10
12
  spec/spec_helper.rb
data/README CHANGED
@@ -5,13 +5,13 @@ Build up named scopes conditionally.
5
5
 
6
6
  == Install
7
7
 
8
- First install the gem.
8
+ First specify it in your Rails config.
9
9
 
10
- gem install ryanb-scope-builder --source=http://gems.github.com
10
+ config.gem 'ryanb-scope-builder', :lib => 'scope_builder', :source => 'http://gems.github.com'
11
11
 
12
- Then specify it in your Rails config.
12
+ And then install it.
13
13
 
14
- config.gem 'ryanb-scope-builder', :lib => 'scope_builder', :source => 'http://gems.github.com'
14
+ rake gems:install
15
15
 
16
16
  Rails 2.1 or later required.
17
17
 
@@ -39,6 +39,12 @@ search method.
39
39
  end
40
40
  end
41
41
 
42
+ The scope_builder method can also be called on an existing scope.
43
+
44
+ products = Product.released.visible
45
+ builder = products.scope_builder
46
+ builder.cheap if only_show_cheap_products?
47
+
42
48
 
43
49
  == Development
44
50
 
@@ -0,0 +1,13 @@
1
+ module ScopeBuilder
2
+ module ScopeAdditions
3
+ def scope_builder
4
+ builder = Builder.new(self)
5
+ yield(builder) if block_given?
6
+ builder
7
+ end
8
+ end
9
+ end
10
+
11
+ class ActiveRecord::NamedScope::Scope
12
+ include ScopeBuilder::ScopeAdditions
13
+ end
data/lib/scope_builder.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
2
  require 'scope_builder/model_additions'
3
+ require 'scope_builder/scope_additions'
3
4
  require 'scope_builder/builder'
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Scope-builder-0.1.0
2
+ # Gem::Specification for Scope-builder-0.1.1
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{scope-builder}
7
- s.version = "0.1.0"
7
+ s.version = "0.1.1"
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
10
  s.authors = ["Ryan Bates"]
11
11
  s.date = %q{2008-06-26}
12
12
  s.description = %q{Build up named scopes conditionally.}
13
13
  s.email = %q{ryan (at) railscasts (dot) com}
14
- s.extra_rdoc_files = ["CHANGELOG", "lib/scope_builder/builder.rb", "lib/scope_builder/model_additions.rb", "lib/scope_builder.rb", "LICENSE", "README", "tasks/deployment.rake", "tasks/spec.rake", "TODO"]
15
- s.files = ["CHANGELOG", "lib/scope_builder/builder.rb", "lib/scope_builder/model_additions.rb", "lib/scope_builder.rb", "LICENSE", "Manifest", "README", "spec/models/product.rb", "spec/scope_builder/builder_spec.rb", "spec/spec_helper.rb", "spec/test.sqlite3", "tasks/deployment.rake", "tasks/spec.rake", "TODO", "scope-builder.gemspec"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "lib/scope_builder/builder.rb", "lib/scope_builder/model_additions.rb", "lib/scope_builder/scope_additions.rb", "lib/scope_builder.rb", "LICENSE", "README", "tasks/deployment.rake", "tasks/spec.rake", "TODO"]
15
+ s.files = ["CHANGELOG", "lib/scope_builder/builder.rb", "lib/scope_builder/model_additions.rb", "lib/scope_builder/scope_additions.rb", "lib/scope_builder.rb", "LICENSE", "Manifest", "README", "scope-builder.gemspec", "spec/models/product.rb", "spec/scope_builder/builder_spec.rb", "spec/spec_helper.rb", "spec/test.sqlite3", "tasks/deployment.rake", "tasks/spec.rake", "TODO"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://github.com/ryanb/scope-builder}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Scope-builder", "--main", "README"]
@@ -41,7 +41,7 @@ end
41
41
  # begin
42
42
  # require 'echoe'
43
43
  #
44
- # Echoe.new('scope-builder', '0.1.0') do |p|
44
+ # Echoe.new('scope-builder', '0.1.1') do |p|
45
45
  # p.summary = "Build up named scopes conditionally."
46
46
  # p.description = "Build up named scopes conditionally."
47
47
  # p.url = "http://github.com/ryanb/scope-builder"
@@ -47,4 +47,9 @@ describe ScopeBuilder::Builder do
47
47
  it "should be able to build up scope in block" do
48
48
  Product.scope_builder { |b| b.released }.all.should == Product.released.all
49
49
  end
50
+
51
+ it "should be able to call scope builder on an existing scope" do
52
+ builder = Product.released.scope_builder
53
+ builder.all.should == Product.released.all
54
+ end
50
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ryanb-scope-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bates
@@ -23,6 +23,7 @@ extra_rdoc_files:
23
23
  - CHANGELOG
24
24
  - lib/scope_builder/builder.rb
25
25
  - lib/scope_builder/model_additions.rb
26
+ - lib/scope_builder/scope_additions.rb
26
27
  - lib/scope_builder.rb
27
28
  - LICENSE
28
29
  - README
@@ -33,10 +34,12 @@ files:
33
34
  - CHANGELOG
34
35
  - lib/scope_builder/builder.rb
35
36
  - lib/scope_builder/model_additions.rb
37
+ - lib/scope_builder/scope_additions.rb
36
38
  - lib/scope_builder.rb
37
39
  - LICENSE
38
40
  - Manifest
39
41
  - README
42
+ - scope-builder.gemspec
40
43
  - spec/models/product.rb
41
44
  - spec/scope_builder/builder_spec.rb
42
45
  - spec/spec_helper.rb
@@ -44,7 +47,6 @@ files:
44
47
  - tasks/deployment.rake
45
48
  - tasks/spec.rake
46
49
  - TODO
47
- - scope-builder.gemspec
48
50
  has_rdoc: true
49
51
  homepage: http://github.com/ryanb/scope-builder
50
52
  post_install_message: