scoped-search 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,109 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0.rc)
6
+ actionpack (= 3.0.0.rc)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0.rc)
9
+ activemodel (= 3.0.0.rc)
10
+ activesupport (= 3.0.0.rc)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.9)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.22)
18
+ activemodel (3.0.0.rc)
19
+ activesupport (= 3.0.0.rc)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activerecord (3.0.0.rc)
23
+ activemodel (= 3.0.0.rc)
24
+ activesupport (= 3.0.0.rc)
25
+ arel (~> 0.4.0)
26
+ tzinfo (~> 0.3.22)
27
+ activeresource (3.0.0.rc)
28
+ activemodel (= 3.0.0.rc)
29
+ activesupport (= 3.0.0.rc)
30
+ activesupport (3.0.0.rc)
31
+ arel (0.4.0)
32
+ activesupport (>= 3.0.0.beta)
33
+ builder (2.1.2)
34
+ columnize (0.3.1)
35
+ diff-lcs (1.1.2)
36
+ erubis (2.6.6)
37
+ abstract (>= 1.0.0)
38
+ gemcutter (0.6.1)
39
+ git (1.2.5)
40
+ i18n (0.4.1)
41
+ jeweler (1.4.0)
42
+ gemcutter (>= 0.1.0)
43
+ git (>= 1.2.5)
44
+ rubyforge (>= 2.0.0)
45
+ json_pure (1.4.3)
46
+ linecache (0.43)
47
+ mail (2.2.5)
48
+ activesupport (>= 2.3.6)
49
+ mime-types
50
+ treetop (>= 1.4.5)
51
+ mime-types (1.16)
52
+ nokogiri (1.4.2)
53
+ polyglot (0.3.1)
54
+ rack (1.2.1)
55
+ rack-mount (0.6.9)
56
+ rack (>= 1.0.0)
57
+ rack-test (0.5.4)
58
+ rack (>= 1.0)
59
+ rails (3.0.0.rc)
60
+ actionmailer (= 3.0.0.rc)
61
+ actionpack (= 3.0.0.rc)
62
+ activerecord (= 3.0.0.rc)
63
+ activeresource (= 3.0.0.rc)
64
+ activesupport (= 3.0.0.rc)
65
+ bundler (>= 1.0.0.rc.1)
66
+ railties (= 3.0.0.rc)
67
+ railties (3.0.0.rc)
68
+ actionpack (= 3.0.0.rc)
69
+ activesupport (= 3.0.0.rc)
70
+ rake (>= 0.8.3)
71
+ thor (~> 0.14.0)
72
+ rake (0.8.7)
73
+ rspec (2.0.0.beta.19)
74
+ rspec-core (= 2.0.0.beta.19)
75
+ rspec-expectations (= 2.0.0.beta.19)
76
+ rspec-mocks (= 2.0.0.beta.19)
77
+ rspec-core (2.0.0.beta.19)
78
+ rspec-expectations (2.0.0.beta.19)
79
+ diff-lcs (>= 1.1.2)
80
+ rspec-mocks (2.0.0.beta.19)
81
+ rspec-rails (2.0.0.beta.19)
82
+ rspec (= 2.0.0.beta.19)
83
+ webrat (>= 0.7.2.beta.1)
84
+ ruby-debug (0.10.3)
85
+ columnize (>= 0.1)
86
+ ruby-debug-base (~> 0.10.3.0)
87
+ ruby-debug-base (0.10.3)
88
+ linecache (>= 0.3)
89
+ rubyforge (2.0.4)
90
+ json_pure (>= 1.1.7)
91
+ sqlite3-ruby (1.3.1)
92
+ thor (0.14.0)
93
+ treetop (1.4.8)
94
+ polyglot (>= 0.3.1)
95
+ tzinfo (0.3.22)
96
+ webrat (0.7.2.beta.1)
97
+ nokogiri (>= 1.2.0)
98
+ rack (>= 1.0)
99
+ rack-test (>= 0.5.3)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ jeweler
106
+ rails (>= 3.0.0.rc)
107
+ rspec-rails (>= 2.0.0.beta.17)
108
+ ruby-debug
109
+ sqlite3-ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
@@ -5,10 +5,7 @@
5
5
  class ScopedSearch
6
6
  class Base
7
7
  extend ActiveModel::Naming
8
-
9
- SINGLE_SCOPES_VALUES = %w(true 1)
10
- EXCLUDED_SCOPES_VALUES = %w(false 0)
11
-
8
+
12
9
  attr_reader :attributes, :model_class, :attributes_merged
13
10
 
14
11
  def initialize(klass, options)
@@ -33,21 +30,22 @@ class ScopedSearch
33
30
 
34
31
  def build_relation
35
32
  return model_class if attributes.empty?
36
- attributes.reject { |k,v| v.blank? || EXCLUDED_SCOPES_VALUES.include?(v.to_s) }.inject(model_class) do |s, k|
33
+ attributes.reject { |k,v| v.blank? || v.to_s == "false" }.inject(model_class) do |s, k|
37
34
  if model_class.scopes.keys.include?(k.first.to_sym)
38
-
39
- if k.size == 2 && !k.last.is_a?(Array) && SINGLE_SCOPES_VALUES.include?(k.last.to_s)
35
+ if k.second.is_a?(Array) && multi_params?(k.first)
36
+ s.send(*k.flatten)
37
+ elsif k.second.to_s == "true"
40
38
  s.send(k.first)
41
39
  else
42
- multi_params?(k.first) ? s.send(*k.flatten) : s.send(k.first, k[1..-1].flatten)
40
+ s.send(k.first, k.second)
43
41
  end
44
-
42
+
45
43
  else
46
44
  s
47
45
  end
48
46
  end
49
47
  end
50
-
48
+
51
49
  def to_key; nil; end
52
50
 
53
51
  def method_missing(method_name, *args)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scoped-search}
8
- s.version = "0.6.0"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["slainer68"]
12
- s.date = %q{2010-07-28}
12
+ s.date = %q{2010-08-04}
13
13
  s.description = %q{Easily implement search forms and column ordering based on your models scopes. For Rails 3, compatible with ActiveRecord and Mongoid.}
14
14
  s.email = %q{slainer68@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".gitignore",
21
21
  "Gemfile",
22
+ "Gemfile.lock",
22
23
  "LICENSE",
23
24
  "README.textile",
24
25
  "Rakefile",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoped-search
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - slainer68
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-28 00:00:00 +02:00
18
+ date: 2010-08-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,6 +46,7 @@ extra_rdoc_files:
46
46
  files:
47
47
  - .gitignore
48
48
  - Gemfile
49
+ - Gemfile.lock
49
50
  - LICENSE
50
51
  - README.textile
51
52
  - Rakefile