filterrific 4.0.1 → 5.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
  SHA1:
3
- metadata.gz: 3399bb18bfa5191cd87ee2b7d31c806a290aee45
4
- data.tar.gz: dd3f5b946c313509c89006122652d7c27cb28140
3
+ metadata.gz: b450ac700cb2087731e8d30c8c4e94bc7f90df26
4
+ data.tar.gz: fce6b4218644562383de7f9a9bfdf9d71fd75c5f
5
5
  SHA512:
6
- metadata.gz: 1ba9f0d838ce2c7880ecf34c30ab2c2cd04fcbbe36d58875eba52d5d88fee4abce66aac499270c4bcfc458b6ee25d70a880e86293db00e265ea376cc7239f544
7
- data.tar.gz: b22987d4aec16b97b018b93869d6987a90aac4e43086674941c761e8067816630504dd7ae858955deede691143061c0786c0d263b6f5f27769910631bf87d38d
6
+ metadata.gz: 2137ab79b5a0bdd7d40d07046208ec8f5b3d73ad7f883f2ea3d5516c00c5c1fb5eb17c811b30bb6f4001549eb5168ec3b38b7038bbca925d87c969591c423b81
7
+ data.tar.gz: 4397b2c6d32ff3acc39fe4d3ea31f9d6799583b65c55a75bf7bf1e3f759eeb2b7ecd90d5ec853cfe9dc859085f0955b13fcbab3bebfc423a7bda8a8d278339e3
@@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  Filterrific major versions match the Ruby on Rails major versions they work with.
9
9
 
10
- ## [4.0.1] - Apr. 6, 2018
10
+ ## [5.0.0] - Dec. 31, 2017
11
11
 
12
- * Updated Filterific JS initialization on page load.
12
+ * We're switching to a new versioning strategy for Filterrific: Filterrific major releases (the first number in the version) will be matched with the supported major version of Rails. Minor and path versions may diverge from Rails. That means for any version of Rails 5.x you will use the most current version of Filterrific 5.x.
13
13
 
14
14
  ## [4.0.0] - Dec. 31, 2017
15
15
 
data/README.md CHANGED
@@ -1,17 +1,24 @@
1
- Filterrific
2
- ===========
1
+ # Filterrific
3
2
 
4
3
  Filterrific is a Rails Engine plugin that makes it easy to filter,
5
4
  search, and sort your ActiveRecord lists:
6
5
 
6
+
7
+ ### Features
8
+
9
+ * Makes heavy use of ActiveRecord Scopes
10
+ * ActionController helpers to shuttle filter params from ActionView forms to ActiveRecord based models, and to return matching records back from ActiveRecord to ActionView.
11
+ * Form helpers to build powerful search and filter forms with ease.
12
+ * Javascript assets to auto-submit filter form on change via AJAX.
13
+ * Image asset to show a spinner in the Filterrific form when new records are being loaded via AJAX.
14
+ * API option to use Filterrific with Rails API mode. Just use `gem 'filterrific', require: 'filterrific_api'` in your Gemfile.
15
+
7
16
  ***
8
17
 
9
18
  ![A filterrific enhanced list](https://github.com/jhund/filterrific/blob/gh-pages/images/screenshot_s.png)
10
19
 
11
20
  ***
12
21
 
13
- Make sure to go to the fantastic [Filterrific documentation](http://filterrific.clearcove.ca)
14
- to find out more!
15
22
 
16
23
  ### Installation
17
24
 
@@ -22,18 +29,23 @@ or with bundler in your Gemfile:
22
29
  `gem 'filterrific'`
23
30
 
24
31
 
25
- ### Compatibility
32
+ ### Usage
26
33
 
27
- Every commit to Filterrific is automatically tested against the following scenarios:
34
+ Make sure to go to the fantastic [Filterrific documentation](http://filterrific.clearcove.ca)
35
+ to find out more!
28
36
 
29
- | Rails version | Ruby environments | Database adapters | Build status |
30
- |---------------|--------------------------------|------------------------------------|--------------|
31
- | Rails 5.x | MRI 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql2, postgresql |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-5.x)](https://travis-ci.org/jhund/filterrific_demo)|
32
- | Rails 4.x | MRI 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql2, postgresql |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-4.x)](https://travis-ci.org/jhund/filterrific_demo)|
33
37
 
34
- Filterrific up to version 2.1.x should work on Rails 3.2 and Ruby 1.9.3. I stopped testing it though as it became too cumbersome to manage gem dependencies.
38
+ ### Compatibility
39
+
40
+ Every commit to Filterrific is automatically tested against the following scenarios:
35
41
 
36
- Filterrific version 1.x should work on versions prior to Rails 3.2 and older Rubies, however the 1.x branch is not supported any more.
42
+ |Filterrific version | Rails version | Ruby environments | Database adapters | Build status |
43
+ |--------------------|---------------|--------------------------------|------------------------------------|--------------|
44
+ | 5.x | Rails 5.x | MRI 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql2, postgresql |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-5.x)](https://travis-ci.org/jhund/filterrific_demo)|
45
+ | 4.x | Rails 4.x | MRI 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql, mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-4.x)](https://travis-ci.org/jhund/filterrific_demo)|
46
+ | 3.x | Rails 3.2 | MRI 2.0.0, 2.1.7 | mysql, mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-3.x)](https://travis-ci.org/jhund/filterrific_demo)|
47
+ | 2.x | Rails 3.2 | MRI 1.9.3 | mysql, mysql2, postgresql, sqlite3 | [N/A]
48
+ | 1.x | < 3.2 | MRI <= 1.9.3 | mysql, mysql2, postgresql, sqlite3 | [N/A]
37
49
 
38
50
  ### Guidelines for submitting issues
39
51
 
@@ -94,6 +94,15 @@ Filterrific.init = function() {
94
94
  );
95
95
  };
96
96
 
97
- // Handle with and without Turbolinks
98
- jQuery(document).ready(Filterrific.init);
99
- jQuery(document).on('page:load', Filterrific.init);
97
+
98
+ // Initialize event observers on document ready and turbolinks page:load
99
+ jQuery(document).on('turbolinks:load', function() {
100
+ // Prevent double initilisation. With turbolinks 5 this function
101
+ // will be called twice: on 'ready' and 'turbolinks:load'
102
+ jQuery(document).off('ready page:load')
103
+ Filterrific.init();
104
+ });
105
+
106
+ jQuery(document).on('ready page:load', function() {
107
+ Filterrific.init();
108
+ });
@@ -9,7 +9,7 @@ For more info see: https://github.com/svenfuchs/gem-release#usage
9
9
  ## Steps for an update
10
10
 
11
11
  1. Update code and commit it.
12
- 2. Add entry to CHANGELOG and commit it.
12
+ 2. Add entry to CHANGELOG and commit it
13
13
  3. Bump the version with one of these commands:
14
14
  * `gem bump --version 1.1.1` # Bump the gem version to the given version number
15
15
  * `gem bump --version major` # 0.0.1 -> 1.0.0
@@ -2,7 +2,12 @@
2
2
 
3
3
  ## TODO
4
4
 
5
- * add check that no filter_name conflicts with existing methods on included ActiveRecord class (See https://github.com/jhund/filterrific/issues/17)
5
+ * [x] Go to deep_stringify_keys (in ActionControllerExtension#initialize_filterrific)
6
+ * [x] Lock Gemfile to correct version of Rails
7
+ * [x] Add Rails major version check to filterrific.rb
8
+ * [ ] In ParamSet#condition_filterrific_params: Why are we type casting integers?
9
+ * [ ] add check that no filter_name conflicts with existing methods on included ActiveRecord class (See https://github.com/jhund/filterrific/issues/17)
10
+ * [x] I think this is done: fix reset url, make controller method, helper method
6
11
 
7
12
  ## Travis
8
13
 
@@ -25,6 +30,7 @@ Ruby 1.8.7
25
30
  Ruby 1.9.3
26
31
  Ruby 2.0
27
32
  Ruby 2.1
33
+ Ruby 2.2 No No No No
28
34
 
29
35
  Each combination is also tested for postgres and mysql
30
36
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- if Rails::VERSION::MAJOR != 4
4
- raise "\n\nThis version of Filterrific only works with Rails 4.x.\nPlease see the Filterrific README for the correct version of Filterrific to use with your version of Rails!\n\n"
3
+ if Rails::VERSION::MAJOR != 5
4
+ raise "\n\nThis version of Filterrific only works with Rails 5.x.\nPlease see the Filterrific README for the correct version of Filterrific to use with your version of Rails!\n\n"
5
5
  end
6
6
 
7
7
  require 'filterrific/version'
@@ -27,10 +27,8 @@ module Filterrific
27
27
  # dynamic values.
28
28
  # @return [Filterrific::ParamSet]
29
29
  def initialize_filterrific(model_class, filterrific_params, opts = {})
30
- # We used #deep_stringify_keys, however that breaks on Rails 3.x, so we
31
- # went back to #stringify_keys which should be sufficient.
32
- f_params = (filterrific_params || {}).stringify_keys
33
- opts = opts.stringify_keys
30
+ f_params = (filterrific_params || {}).deep_stringify_keys
31
+ opts = opts.deep_stringify_keys
34
32
  pers_id = if false == opts['persistence_id']
35
33
  nil
36
34
  else
@@ -68,7 +66,7 @@ module Filterrific
68
66
  (persistence_id && session[persistence_id].presence) || # then try session persisted params if persistence_id is present
69
67
  opts['default_filter_params'] || # then use passed in opts
70
68
  model_class.filterrific_default_filter_params # finally use model_class defaults
71
- ).stringify_keys
69
+ ).deep_stringify_keys
72
70
  r.slice!(*opts['available_filters'].map(&:to_s)) if opts['available_filters']
73
71
  r
74
72
  end
@@ -54,11 +54,8 @@ module Filterrific
54
54
  ar_rel = if ActiveRecord::Relation === self
55
55
  # self is already an ActiveRecord::Relation, use as is
56
56
  self
57
- elsif Rails::VERSION::MAJOR <= 3
58
- # Active Record 3: send `:scoped` to class to get an ActiveRecord::Relation
59
- scoped
60
57
  else
61
- # Active Record 4 and later: Send `:all` to class to get an ActiveRecord::Relation
58
+ # Send `:all` to class to get an ActiveRecord::Relation
62
59
  all
63
60
  end
64
61
 
@@ -101,7 +98,7 @@ module Filterrific
101
98
  def assign_filterrific_default_filter_params(opts)
102
99
  self.filterrific_default_filter_params = (
103
100
  opts['default_filter_params'] || {}
104
- ).stringify_keys
101
+ ).deep_stringify_keys
105
102
  end
106
103
 
107
104
  def validate_filterrific_default_filter_params
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'filterrific/param_set'
4
+
5
+ require 'filterrific/action_controller_extension'
6
+ require 'filterrific/active_record_extension'
7
+
8
+ module Filterrific
9
+ class EngineApi < ::Rails::Engine
10
+
11
+ TODO: Since this is API only, I don't think we need an engine!
12
+ # It's an engine so that we can add javascript and image assets
13
+ # to the asset pipeline.
14
+
15
+ isolate_namespace Filterrific
16
+
17
+ ActiveSupport.on_load :action_controller do
18
+ include Filterrific::ActionControllerExtension
19
+ end
20
+
21
+ ActiveSupport.on_load :active_record do
22
+ extend Filterrific::ActiveRecordExtension
23
+ end
24
+
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Filterrific
4
- VERSION = "4.0.1"
4
+ VERSION = "5.0.0"
5
5
  end
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'filterrific/version'
4
+ require 'filterrific/engine_api'
5
+
6
+ module Filterrific
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filterrific
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Hund
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-07 00:00:00.000000000 Z
11
+ date: 2017-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Filterrific is a Rails Engine plugin that makes it easy to filter, search,
14
14
  and sort your ActiveRecord lists.
@@ -37,9 +37,11 @@ files:
37
37
  - lib/filterrific/action_view_extension.rb
38
38
  - lib/filterrific/active_record_extension.rb
39
39
  - lib/filterrific/engine.rb
40
+ - lib/filterrific/engine_api.rb
40
41
  - lib/filterrific/has_reset_filterrific_url_mixin.rb
41
42
  - lib/filterrific/param_set.rb
42
43
  - lib/filterrific/version.rb
44
+ - lib/filterrific_api.rb
43
45
  - spec/filterrific/action_controller_extension_spec.rb
44
46
  - spec/filterrific/action_view_extension_spec.rb
45
47
  - spec/filterrific/active_record_extension_spec.rb