mongoid-filterable 0.3.1 → 0.4.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
- SHA1:
3
- metadata.gz: 87d7798ec085fc87bdc881c9b1e558ba586ca6b4
4
- data.tar.gz: 312d99250344d91691699abf7df77da2e92c6fbe
2
+ SHA256:
3
+ metadata.gz: e6168dc7e61425d57051a385ad08c7061e0690b68895a1a06791dbbe5ba6e3f0
4
+ data.tar.gz: 51b6a89e1f0454f62d4b502d920b0e7b76d03d5f61d2fbb7ea613b9d09772968
5
5
  SHA512:
6
- metadata.gz: 1779d49149024d0414944056fca200d6dbe09107c253f219fba32db7f1bd7e0eeb41498e1539e2a8d87f2eea159f42b5812e8980ed0bf511610d871094d11b7a
7
- data.tar.gz: 3f105856c09b016d5805589f7f6cc551b072ad4b2d89adcd1ae83729830012f9e78256ec122b7421755c1ea0125f996f0bb26d65512aca179ff82f587b2b9073
6
+ metadata.gz: 9e1d37765dd64fa1c3322045a5632a757ad217e7c243524696f026d70db8cc988d4f9825fd54e146dfba6b14d7534c80204e4c82abe27fe4a129f7edd17d94fe
7
+ data.tar.gz: a6167fb4ecbd8b2e6342ba87ab703388a231b7dff891e26cbef84f2a22bc6c7e9b78683838b2b3e7987c8264f7014c409fbda03dcee4732668e69570a5b61662
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.1
6
+
7
+ gemfile:
8
+ - Gemfile
9
+ - gemfiles/mongoid-6.0.gemfile
10
+ - gemfiles/mongoid-7.0.gemfile
11
+
12
+ services:
13
+ - mongodb
14
+
15
+ addons:
16
+ apt:
17
+ sources:
18
+ - mongodb-3.4-precise
19
+ packages:
20
+ - mongodb-org-server
data/Gemfile CHANGED
@@ -2,4 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mongoid-normalize-strings.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
5
7
  gem 'mongoid', "~> 5.0"
data/README.md CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Compatibility
20
20
 
21
- Mongoid Filterable supports Mongoid versions 3, 4, 5, and now 6.
21
+ Mongoid Filterable supports Mongoid versions 3, 4, 5, 6 and now 7.
22
22
 
23
23
  ## Usage
24
24
 
@@ -34,7 +34,7 @@ class City
34
34
 
35
35
  filter_by(:name)
36
36
  filter_by(:people, ->(value) { where(:people.gt => value) })
37
- filter_by(:people_range, (lambda do |range_start, range_end|
37
+ filter_by(:people_range, (lambda do |range_start, range_end|
38
38
  where(:people.lte => range_end,
39
39
  :people.gte => range_start)
40
40
  end))
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mongoid-normalize-strings.gemspec
4
+ gemspec path: '../'
5
+
6
+ gem 'rake'
7
+ gem 'mongoid', "~> 6.0"
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mongoid-normalize-strings.gemspec
4
+ gemspec path: '../'
5
+
6
+ gem 'rake'
7
+ gem 'mongoid', "~> 7.0"
@@ -14,7 +14,7 @@ module Mongoid
14
14
  criteria = unscoped
15
15
 
16
16
  filtering_params.each do |key, value|
17
- if value.present? && respond_to?("filter_with_#{key}")
17
+ if !value.nil? && respond_to?("filter_with_#{key}")
18
18
  if value.is_a?(Array) && scopes["filter_with_#{key}".to_sym][:scope].arity > 1
19
19
  selectors.push criteria.public_send("filter_with_#{key}", *value).selector
20
20
  else
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Filterable
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -13,6 +13,7 @@ describe Mongoid::Filterable do
13
13
  field :people, type: Integer
14
14
  field :country_normalized
15
15
 
16
+ filter_by(:active)
16
17
  filter_by(:name)
17
18
  filter_by(:code)
18
19
  filter_by(:people, ->(value) { where(:people.gt => value) })
@@ -25,7 +26,7 @@ describe Mongoid::Filterable do
25
26
  end
26
27
 
27
28
  before do
28
- City.destroy_all
29
+ City.unscoped.destroy_all
29
30
  end
30
31
 
31
32
  context 'when use default operator' do
@@ -123,6 +124,14 @@ describe Mongoid::Filterable do
123
124
  end
124
125
  end
125
126
 
127
+ context 'when value is a Boolean' do
128
+ it 'should filter using a query' do
129
+ City.create(name: 'city1')
130
+ City.create(name: 'city2', active: false)
131
+ expect(City.unscoped.filter(active: false).count).to eq(1)
132
+ end
133
+ end
134
+
126
135
  context 'when filter is applied on a scope' do
127
136
  it 'previous scope is maintained' do
128
137
  City.create(name: '2', people: 100)
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: 0.3.1
4
+ version: 0.4.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: 2017-11-20 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,10 +74,13 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".travis.yml"
77
78
  - Gemfile
78
79
  - LICENSE.txt
79
80
  - README.md
80
81
  - Rakefile
82
+ - gemfiles/mongoid-6.0.gemfile
83
+ - gemfiles/mongoid-7.0.gemfile
81
84
  - lib/mongoid-filterable.rb
82
85
  - lib/mongoid-filterable/filterable.rb
83
86
  - lib/mongoid-filterable/version.rb
@@ -105,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
108
  version: '0'
106
109
  requirements: []
107
110
  rubyforge_project:
108
- rubygems_version: 2.5.2
111
+ rubygems_version: 2.7.6
109
112
  signing_key:
110
113
  specification_version: 4
111
114
  summary: Easy way to add scopes to your models.