mongoid-filterable 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78743b377f67ff51a0cd93129f3b5a9b975b937e60b6fc12479c09cf3d2f7c8b
4
- data.tar.gz: b84102c6f3aa6147fcfdd45e008bb48ba708854fc3d023964bb1cacacf27b092
3
+ metadata.gz: ee668ea1b497adc91c147956f1f390abf02038e6b9968dff39345c1c3901c0be
4
+ data.tar.gz: 0f94be3a0505256cb8bd205c281ed5a2beb239262c05528efd71876aa5516360
5
5
  SHA512:
6
- metadata.gz: ea813f93c96f3faf030cf6aa64866b58a947ae5f438cea237a23727ae348f2266ad29918a7ea452be21340e56ad3d409619a681cce461eaa0e9e6cfd1b7868e2
7
- data.tar.gz: 819e2fb4acbb612df9a79974e488d3f864e6c9e45550ee5ce31611ea772e67e055adc3173f106f033bcd60ca59b8563c29efe321063febff284189a73ca45460
6
+ metadata.gz: 265830fc7d04d50f90e2d19907baeeb7e6fc324e297f3b21108022ac6606d0881b6a967566db18f133e80090b0d6b7eb1b40198847a5dff631a931ac9d8477a8
7
+ data.tar.gz: a4fc72a06601a609655d67ff7276fd8e7ccf11f1ccc533641445681fab98f8baa900986db840a61d5928c365c955326b4bfb08e18aceee453256b636ac94131d
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.1
4
+ - 2.6.0
5
5
  before_install: gem install bundler -v 1.16.1
6
6
 
7
7
  gemfile:
data/README.md CHANGED
@@ -43,10 +43,10 @@ end
43
43
 
44
44
  City.create(name: 'city1', people: 100)
45
45
  City.create(name: 'city2', people: 1000)
46
- City.filter({name: 'city'}).count # => 2
47
- City.filter({name: 'city1'}).count # => 1
48
- City.filter({name: ''}).count # => 0
49
- City.filter({people: 500}) # => 1
46
+ City.filtrate({name: 'city'}).count # => 2
47
+ City.filtrate({name: 'city1'}).count # => 1
48
+ City.filtrate({name: ''}).count # => 0
49
+ City.filtrate({people: 500}) # => 1
50
50
  ```
51
51
 
52
52
  #### Operator
@@ -57,8 +57,8 @@ You can specify selector operator:
57
57
  * $or
58
58
 
59
59
  ```ruby
60
- City.filter({name: 'city1', people: 1000}, '$and').count # => 0
61
- City.filter({name: 'city1', people: 1000}, '$or').count # => 1
60
+ City.filtrate({name: 'city1', people: 1000}, '$and').count # => 0
61
+ City.filtrate({name: 'city1', people: 1000}, '$or').count # => 1
62
62
  ```
63
63
 
64
64
  #### Range
@@ -66,7 +66,7 @@ City.filter({name: 'city1', people: 1000}, '$or').count # => 1
66
66
  Searches with more than one param is also available:
67
67
 
68
68
  ```ruby
69
- City.filter(people_range: [500, 1000]).count # => 1
69
+ City.filtrate(people_range: [500, 1000]).count # => 1
70
70
  ```
71
71
 
72
72
  #### Rails controller
@@ -74,7 +74,7 @@ City.filter(people_range: [500, 1000]).count # => 1
74
74
  ```ruby
75
75
  class CitiesController
76
76
  def index
77
- respond_with City.filter(filter_params)
77
+ respond_with City.filtrate(filter_params)
78
78
  end
79
79
 
80
80
  private
@@ -101,7 +101,7 @@ end
101
101
 
102
102
  City.create(name: 'Cíty1')
103
103
  City.create(name: 'Cíty2')
104
- City.filter({name: 'city1'}).count # => 1
104
+ City.filtrate({name: 'city1'}).count # => 1
105
105
  ```
106
106
 
107
107
  ## Contributing
@@ -7,7 +7,7 @@ module Mongoid
7
7
  ##
8
8
  # Applies params scopes to current scope
9
9
  #
10
- def filter(filtering_params, operator='$and')
10
+ def filtrate(filtering_params, operator='$and')
11
11
  return all unless filtering_params
12
12
  results = all
13
13
  selectors = []
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Filterable
3
- VERSION = '1.0.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -31,7 +31,7 @@ describe Mongoid::Filterable do
31
31
 
32
32
  context 'when use default operator' do
33
33
  it 'should create correct selector' do
34
- expect(City.filter(code: :code1).selector).to eq(
34
+ expect(City.filtrate(code: :code1).selector).to eq(
35
35
  'active' => true, '$and' => [{'code' => :code1}]
36
36
  )
37
37
  end
@@ -39,38 +39,38 @@ describe Mongoid::Filterable do
39
39
  it 'should filter by default filter' do
40
40
  City.create(code: :code1)
41
41
  City.create(code: :code2)
42
- expect(City.filter(code: :code1).count).to eq(1)
43
- expect(City.filter(code: :code1).first.code).to eq(:code1)
42
+ expect(City.filtrate(code: :code1).count).to eq(1)
43
+ expect(City.filtrate(code: :code1).first.code).to eq(:code1)
44
44
  end
45
45
 
46
46
  it 'should filter by match filter' do
47
47
  City.create(name: 'city1')
48
48
  City.create(name: 'city2')
49
- expect(City.filter(name: 'city').count).to eq(2)
50
- expect(City.filter(name: 'city1').count).to eq(1)
51
- expect(City.filter(name: 'city1').first.name).to eq('city1')
49
+ expect(City.filtrate(name: 'city').count).to eq(2)
50
+ expect(City.filtrate(name: 'city1').count).to eq(1)
51
+ expect(City.filtrate(name: 'city1').first.name).to eq('city1')
52
52
  end
53
53
 
54
54
  it 'should filter by custom filter' do
55
55
  City.create(people: 100)
56
56
  City.create(people: 1000)
57
- expect(City.filter(people: 500).count).to eq(1)
58
- expect(City.filter(people: 500).first.people).to eq(1000)
57
+ expect(City.filtrate(people: 500).count).to eq(1)
58
+ expect(City.filtrate(people: 500).first.people).to eq(1000)
59
59
  end
60
60
 
61
61
  it 'should filter by normalized filter' do
62
62
  City.create(country_normalized: 'spain')
63
63
  City.create(country_normalized: 'france')
64
- expect(City.filter(country: 'spain').count).to eq(1)
65
- expect(City.filter(country: 'spain').first.country_normalized).to eq('spain')
64
+ expect(City.filtrate(country: 'spain').count).to eq(1)
65
+ expect(City.filtrate(country: 'spain').first.country_normalized).to eq('spain')
66
66
  end
67
67
 
68
68
  it 'should respect previous selector' do
69
69
  City.create(name: 'city1', people: 100)
70
70
  City.create(name: 'city2', people: 1000)
71
71
  City.create(name: 'city3', people: 2000)
72
- expect(City.where(name: 'city2').filter(people: '500').count).to eq(1)
73
- expect(City.where(name: 'city2').filter(people: '500').first.name).to eq('city2')
72
+ expect(City.where(name: 'city2').filtrate(people: '500').count).to eq(1)
73
+ expect(City.where(name: 'city2').filtrate(people: '500').first.name).to eq('city2')
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ describe Mongoid::Filterable do
78
78
  it 'should filter using and query' do
79
79
  City.create(name: 'city1', people: 100)
80
80
  City.create(name: 'city2', people: 2000)
81
- expect(City.filter({name: 'city1', people: '2000'}, '$and').count).to eq(0)
81
+ expect(City.filtrate({name: 'city1', people: '2000'}, '$and').count).to eq(0)
82
82
  end
83
83
  end
84
84
 
@@ -86,7 +86,7 @@ describe Mongoid::Filterable do
86
86
  it 'should filter using or query' do
87
87
  City.create(name: 'city1', people: 100)
88
88
  City.create(name: 'city2', people: 2000)
89
- expect(City.filter({name: 'city1', people: '2000'}, '$or').count).to eq(1)
89
+ expect(City.filtrate({name: 'city1', people: '2000'}, '$or').count).to eq(1)
90
90
  end
91
91
  end
92
92
 
@@ -94,7 +94,7 @@ describe Mongoid::Filterable do
94
94
  it 'should ignore filter' do
95
95
  City.create(name: 'city1')
96
96
  City.create(name: 'city2')
97
- expect(City.filter(invalid: 'val').count).to eq(2)
97
+ expect(City.filtrate(invalid: 'val').count).to eq(2)
98
98
  end
99
99
  end
100
100
 
@@ -102,7 +102,7 @@ describe Mongoid::Filterable do
102
102
  it 'should ignore filter' do
103
103
  City.create(name: 'city1')
104
104
  City.create(name: 'city2')
105
- expect(City.filter(nil).count).to eq(2)
105
+ expect(City.filtrate(nil).count).to eq(2)
106
106
  end
107
107
  end
108
108
 
@@ -112,7 +112,7 @@ describe Mongoid::Filterable do
112
112
  City.create(people: 500)
113
113
  City.create(people: 1000)
114
114
  City.create(people: 1000)
115
- expect(City.filter(people_range: [500, 1000]).count).to eq(3)
115
+ expect(City.filtrate(people_range: [500, 1000]).count).to eq(3)
116
116
  end
117
117
 
118
118
  it 'does not break compatibility with filters receiving only one param as array' do
@@ -120,7 +120,7 @@ describe Mongoid::Filterable do
120
120
  City.create(people: 500)
121
121
  City.create(people: 1000)
122
122
  City.create(people: 1000)
123
- expect(City.filter(people_in: [500, 100]).count).to eq(2)
123
+ expect(City.filtrate(people_in: [500, 100]).count).to eq(2)
124
124
  end
125
125
  end
126
126
 
@@ -128,7 +128,7 @@ describe Mongoid::Filterable do
128
128
  it 'should apply filter' do
129
129
  City.create(people: 100)
130
130
  City.create(people: 500)
131
- expect(City.filter(people: nil).count).to eq(0)
131
+ expect(City.filtrate(people: nil).count).to eq(0)
132
132
  end
133
133
  end
134
134
 
@@ -136,7 +136,7 @@ describe Mongoid::Filterable do
136
136
  it 'should apply filter' do
137
137
  City.create(people: 100)
138
138
  City.create(people: 500)
139
- expect(City.filter(people: '').count).to eq(0)
139
+ expect(City.filtrate(people: '').count).to eq(0)
140
140
  end
141
141
  end
142
142
 
@@ -144,7 +144,7 @@ describe Mongoid::Filterable do
144
144
  it 'should filter using a query' do
145
145
  City.create(name: 'city1')
146
146
  City.create(name: 'city2', active: false)
147
- expect(City.unscoped.filter(active: false).count).to eq(1)
147
+ expect(City.unscoped.filtrate(active: false).count).to eq(1)
148
148
  end
149
149
  end
150
150
 
@@ -154,7 +154,7 @@ describe Mongoid::Filterable do
154
154
  City.create(name: '1', people: 500)
155
155
  City.create(name: '1', people: 1000)
156
156
  City.create(name: '1', people: 1000)
157
- expect(City.where(name: '2').filter(nil).count).to eq(1)
157
+ expect(City.where(name: '2').filtrate(nil).count).to eq(1)
158
158
  end
159
159
  end
160
160
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-filterable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Jurado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-14 00:00:00.000000000 Z
11
+ date: 2019-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.7.3
116
+ rubygems_version: 3.0.1
118
117
  signing_key:
119
118
  specification_version: 4
120
119
  summary: Easy way to add scopes to your models.