ransack 0.7.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -3
- data/CONTRIBUTING.md +1 -2
- data/Gemfile +3 -3
- data/README.md +78 -57
- data/lib/ransack/adapters/active_record.rb +2 -0
- data/lib/ransack/adapters/active_record/3.0/context.rb +9 -15
- data/lib/ransack/adapters/active_record/3.1/context.rb +9 -14
- data/lib/ransack/adapters/active_record/3.2/context.rb +44 -0
- data/lib/ransack/adapters/active_record/context.rb +11 -9
- data/lib/ransack/constants.rb +6 -1
- data/lib/ransack/context.rb +15 -1
- data/lib/ransack/helpers/form_builder.rb +2 -1
- data/lib/ransack/helpers/form_helper.rb +3 -2
- data/lib/ransack/locale/es.yml +1 -1
- data/lib/ransack/locale/fr.yml +70 -0
- data/lib/ransack/translate.rb +9 -8
- data/lib/ransack/version.rb +1 -1
- data/ransack.gemspec +3 -3
- data/spec/ransack/adapters/active_record/context_spec.rb +6 -0
- data/spec/ransack/helpers/form_builder_spec.rb +16 -6
- data/spec/ransack/helpers/form_helper_spec.rb +57 -10
- data/spec/ransack/predicate_spec.rb +37 -4
- data/spec/ransack/search_spec.rb +50 -35
- data/spec/spec_helper.rb +2 -0
- data/spec/support/en.yml +3 -1
- data/spec/support/schema.rb +40 -35
- metadata +16 -29
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,8 @@ Sham.define do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
RSpec.configure do |config|
|
23
|
+
config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior'
|
24
|
+
|
23
25
|
config.before(:suite) do
|
24
26
|
puts '=' * 80
|
25
27
|
puts "Running specs against ActiveRecord #{ActiveRecord::VERSION::STRING} and ARel #{Arel::VERSION}..."
|
data/spec/support/en.yml
CHANGED
data/spec/support/schema.rb
CHANGED
@@ -6,6 +6,13 @@ ActiveRecord::Base.establish_connection(
|
|
6
6
|
)
|
7
7
|
|
8
8
|
class Person < ActiveRecord::Base
|
9
|
+
if ActiveRecord::VERSION::MAJOR == 3
|
10
|
+
default_scope order('id DESC')
|
11
|
+
else
|
12
|
+
default_scope { order('id DESC') }
|
13
|
+
# The new activerecord syntax "{ order(id: :desc) }" does not work
|
14
|
+
# with Ruby 1.8.7 which we still need to support for Rails 3
|
15
|
+
end
|
9
16
|
belongs_to :parent, :class_name => 'Person', :foreign_key => :parent_id
|
10
17
|
has_many :children, :class_name => 'Person', :foreign_key => :parent_id
|
11
18
|
has_many :articles
|
@@ -45,46 +52,44 @@ end
|
|
45
52
|
|
46
53
|
module Schema
|
47
54
|
def self.create
|
48
|
-
ActiveRecord::
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
create_table :articles, :force => true do |t|
|
61
|
-
t.integer :person_id
|
62
|
-
t.string :title
|
63
|
-
t.text :body
|
64
|
-
end
|
55
|
+
ActiveRecord::Migration.verbose = false
|
56
|
+
|
57
|
+
ActiveRecord::Schema.define do
|
58
|
+
create_table :people, :force => true do |t|
|
59
|
+
t.integer :parent_id
|
60
|
+
t.string :name
|
61
|
+
t.integer :salary
|
62
|
+
t.boolean :awesome, :default => false
|
63
|
+
t.timestamps
|
64
|
+
end
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
create_table :articles, :force => true do |t|
|
67
|
+
t.integer :person_id
|
68
|
+
t.string :title
|
69
|
+
t.text :body
|
70
|
+
end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
create_table :comments, :force => true do |t|
|
73
|
+
t.integer :article_id
|
74
|
+
t.integer :person_id
|
75
|
+
t.text :body
|
76
|
+
end
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
78
|
+
create_table :tags, :force => true do |t|
|
79
|
+
t.string :name
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
82
|
+
create_table :articles_tags, :force => true, :id => false do |t|
|
83
|
+
t.integer :article_id
|
84
|
+
t.integer :tag_id
|
85
|
+
end
|
86
86
|
|
87
|
+
create_table :notes, :force => true do |t|
|
88
|
+
t.integer :notable_id
|
89
|
+
t.string :notable_type
|
90
|
+
t.string :note
|
87
91
|
end
|
92
|
+
|
88
93
|
end
|
89
94
|
|
90
95
|
10.times do
|
@@ -108,4 +113,4 @@ module Schema
|
|
108
113
|
Comment.make(:body => 'First post!', :article => Article.make(:title => 'Hello, world!'))
|
109
114
|
|
110
115
|
end
|
111
|
-
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ernie Miller
|
@@ -10,60 +9,53 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activerecord
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '3.0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - '>='
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '3.0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: actionpack
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '3.0'
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '3.0'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: polyamorous
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
46
|
- - ~>
|
53
47
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
48
|
+
version: 0.6.0
|
55
49
|
type: :runtime
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
53
|
- - ~>
|
61
54
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.
|
55
|
+
version: 0.6.0
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: rspec
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
60
|
- - ~>
|
69
61
|
- !ruby/object:Gem::Version
|
@@ -71,7 +63,6 @@ dependencies:
|
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
67
|
- - ~>
|
77
68
|
- !ruby/object:Gem::Version
|
@@ -79,7 +70,6 @@ dependencies:
|
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: machinist
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
74
|
- - ~>
|
85
75
|
- !ruby/object:Gem::Version
|
@@ -87,7 +77,6 @@ dependencies:
|
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
81
|
- - ~>
|
93
82
|
- !ruby/object:Gem::Version
|
@@ -95,7 +84,6 @@ dependencies:
|
|
95
84
|
- !ruby/object:Gem::Dependency
|
96
85
|
name: faker
|
97
86
|
requirement: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
87
|
requirements:
|
100
88
|
- - ~>
|
101
89
|
- !ruby/object:Gem::Version
|
@@ -103,7 +91,6 @@ dependencies:
|
|
103
91
|
type: :development
|
104
92
|
prerelease: false
|
105
93
|
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
94
|
requirements:
|
108
95
|
- - ~>
|
109
96
|
- !ruby/object:Gem::Version
|
@@ -111,7 +98,6 @@ dependencies:
|
|
111
98
|
- !ruby/object:Gem::Dependency
|
112
99
|
name: sqlite3
|
113
100
|
requirement: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
101
|
requirements:
|
116
102
|
- - ~>
|
117
103
|
- !ruby/object:Gem::Version
|
@@ -119,7 +105,6 @@ dependencies:
|
|
119
105
|
type: :development
|
120
106
|
prerelease: false
|
121
107
|
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
108
|
requirements:
|
124
109
|
- - ~>
|
125
110
|
- !ruby/object:Gem::Version
|
@@ -145,6 +130,7 @@ files:
|
|
145
130
|
- lib/ransack/adapters/active_record/3.0/compat.rb
|
146
131
|
- lib/ransack/adapters/active_record/3.0/context.rb
|
147
132
|
- lib/ransack/adapters/active_record/3.1/context.rb
|
133
|
+
- lib/ransack/adapters/active_record/3.2/context.rb
|
148
134
|
- lib/ransack/adapters/active_record/base.rb
|
149
135
|
- lib/ransack/adapters/active_record/compat.rb
|
150
136
|
- lib/ransack/adapters/active_record/context.rb
|
@@ -157,6 +143,7 @@ files:
|
|
157
143
|
- lib/ransack/locale/cs.yml
|
158
144
|
- lib/ransack/locale/en.yml
|
159
145
|
- lib/ransack/locale/es.yml
|
146
|
+
- lib/ransack/locale/fr.yml
|
160
147
|
- lib/ransack/naming.rb
|
161
148
|
- lib/ransack/nodes.rb
|
162
149
|
- lib/ransack/nodes/attribute.rb
|
@@ -194,27 +181,26 @@ files:
|
|
194
181
|
- spec/support/schema.rb
|
195
182
|
homepage: https://github.com/ernie/ransack
|
196
183
|
licenses: []
|
184
|
+
metadata: {}
|
197
185
|
post_install_message:
|
198
186
|
rdoc_options: []
|
199
187
|
require_paths:
|
200
188
|
- lib
|
201
189
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
-
none: false
|
203
190
|
requirements:
|
204
|
-
- -
|
191
|
+
- - '>='
|
205
192
|
- !ruby/object:Gem::Version
|
206
193
|
version: '0'
|
207
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
|
-
none: false
|
209
195
|
requirements:
|
210
|
-
- -
|
196
|
+
- - '>='
|
211
197
|
- !ruby/object:Gem::Version
|
212
198
|
version: '0'
|
213
199
|
requirements: []
|
214
200
|
rubyforge_project: ransack
|
215
|
-
rubygems_version:
|
201
|
+
rubygems_version: 2.0.0
|
216
202
|
signing_key:
|
217
|
-
specification_version:
|
203
|
+
specification_version: 4
|
218
204
|
summary: Object-based searching for ActiveRecord (currently).
|
219
205
|
test_files:
|
220
206
|
- spec/blueprints/articles.rb
|
@@ -236,3 +222,4 @@ test_files:
|
|
236
222
|
- spec/spec_helper.rb
|
237
223
|
- spec/support/en.yml
|
238
224
|
- spec/support/schema.rb
|
225
|
+
has_rdoc:
|