convenient_scopes 0.8.1 → 0.8.2

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/Rakefile CHANGED
@@ -44,12 +44,16 @@ task :test => :check_dependencies
44
44
 
45
45
  task :default => :test
46
46
 
47
- require 'rdoc/task'
48
- Rake::RDocTask.new do |rdoc|
49
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+ begin
48
+ require 'rdoc/task'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
51
 
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "convenient_scopes #{version}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "convenient_scopes #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+ rescue LoadError
58
+ puts "rdoc requiring snafu"
55
59
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{convenient_scopes}
8
- s.version = "0.8.1"
8
+ s.version = "0.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ivan Schneider"]
12
- s.date = %q{2011-07-16}
12
+ s.date = %q{2011-07-19}
13
13
  s.description = %q{Dynamic scopes by convention for ActiveRecord 3}
14
14
  s.email = %q{isc@massivebraingames.com}
15
15
  s.extra_rdoc_files = [
@@ -33,16 +33,8 @@ Gem::Specification.new do |s|
33
33
  ]
34
34
  s.homepage = %q{http://github.com/isc/convenient_scopes}
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.5.2}
36
+ s.rubygems_version = %q{1.6.2}
37
37
  s.summary = %q{Dynamic scopes by convention for ActiveRecord 3}
38
- s.test_files = [
39
- "test/helper.rb",
40
- "test/test_all_and_any_conditions.rb",
41
- "test/test_associations.rb",
42
- "test/test_conditions.rb",
43
- "test/test_ordering.rb",
44
- "test/test_search_with_hash.rb"
45
- ]
46
38
 
47
39
  if s.respond_to? :specification_version then
48
40
  s.specification_version = 3
@@ -18,7 +18,7 @@ module ConvenientScopes
18
18
  def search search_scopes
19
19
  res = scoped
20
20
  search_scopes.each do |name, args|
21
- if scopes.keys.include?(name.to_sym) || !respond_to?(name)
21
+ if scopes.keys.include?(name.to_sym) || ar_relation_methods?(name) || !respond_to?(name)
22
22
  res = res.send name, args unless args == false
23
23
  else
24
24
  raise InvalidScopes
@@ -27,6 +27,11 @@ module ConvenientScopes
27
27
  res
28
28
  end
29
29
 
30
+ def ar_relation_methods? name
31
+ (ActiveRecord::Relation::MULTI_VALUE_METHODS + ActiveRecord::Relation::SINGLE_VALUE_METHODS +
32
+ ActiveRecord::Relation::ASSOCIATION_METHODS).include? name
33
+ end
34
+
30
35
  def determine_order_scope_data name, direction
31
36
  if column_names.include? name.to_s
32
37
  unscoped.order("#{quoted_table_name}.#{name} #{direction}")
@@ -40,6 +40,10 @@ class TestSearchWithHash < Test::Unit::TestCase
40
40
  assert_equal [], User.where(:age => 37).search(:first_name_is => 'Angelo')
41
41
  end
42
42
 
43
+ should "be able to pass common ar methods in search" do
44
+ assert_equal [@bob], User.search(:where => "age = 37")
45
+ end
46
+
43
47
  end
44
48
 
45
49
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convenient_scopes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 1
10
- version: 0.8.1
9
+ - 2
10
+ version: 0.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ivan Schneider
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-16 00:00:00 +02:00
18
+ date: 2011-07-19 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -115,14 +115,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements: []
116
116
 
117
117
  rubyforge_project:
118
- rubygems_version: 1.5.2
118
+ rubygems_version: 1.6.2
119
119
  signing_key:
120
120
  specification_version: 3
121
121
  summary: Dynamic scopes by convention for ActiveRecord 3
122
- test_files:
123
- - test/helper.rb
124
- - test/test_all_and_any_conditions.rb
125
- - test/test_associations.rb
126
- - test/test_conditions.rb
127
- - test/test_ordering.rb
128
- - test/test_search_with_hash.rb
122
+ test_files: []
123
+