filter_decrufter 0.0.4 → 0.0.5

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: fecce40a8c9791aef1700866251dc72175bfb7b2
4
- data.tar.gz: 6980da08ea0c95878f145ef12ff2ab14e8834dd6
3
+ metadata.gz: e6f033cc671a5c826ed0f7263fc969bf133ae999
4
+ data.tar.gz: 1b0541e2781f0cd93b70fea3043f09dfaf5e6afd
5
5
  SHA512:
6
- metadata.gz: a9bfb7bc2c13ce2cdc3156aeead413c9e63b70d1bf8486f143e81765bb0c52ba09f0735aea3cc26a79009847f720acf3ed2fcec54ea7ff5a21b239ae445e0217
7
- data.tar.gz: 49d8d4df671c32e541df18b3f53b6493ad0e5a3000d7ffa92fae57b58a584cb77a2d060ebd468837e012a3d2ed2b9eaec7759609fc72e5be8f84ac26a2980f77
6
+ metadata.gz: c90de28ef44365692237c502b0bdd1311c28cb69995efe6be3c516d4a8d6bb8367b8e27d7460bb92e46626c7f1f81e122f6c29d2b8cbfeb43f46d05375248e7b
7
+ data.tar.gz: 7cd8f3acedc1ee1f4496419318706b1f1023c2a58eb204e5a3d70bd4b5ec1264658b557e48243fd6f98b1cd324126c70364832519c3719daa7d386fb933ad024
@@ -1,3 +1,8 @@
1
+ ## 0.0.5 (2015-02-28)
2
+
3
+ * [FIXED] If a filter/action contains both an 'except' and an 'only' constraint and both referred to an unused action, FilterDecrufter will no longer display both as being 'only' constraints.
4
+ * [FIXED] No longer is an exception raised if a filter is defined with multiple methods, e.g., `before_action :foo, :bar, :only => :buz`
5
+
1
6
  ## 0.0.4 (2015-02-27)
2
7
 
3
8
  * [FIXED] Check for before|after|around_action for Rails 4.2
data/README.md CHANGED
@@ -25,6 +25,7 @@ Tested with Rails 3.2, 4.0, and 4.2.
25
25
 
26
26
  # Credits
27
27
 
28
+ * [John Moon](http://www.thinkandgrowentrepreneur.com/) - design discussions
29
+ * [Mike Foley](https://twitter.com/m1foley) - filter with multiple method bug report
28
30
  * [Sandeep Kumar](https://whatpeoplethink.wordpress.com/) - Rails 4.2 support
29
31
  * [Tom Copeland](http://thomasleecopeland.com) - author
30
- * [John Moon](http://www.thinkandgrowentrepreneur.com/) - design discussions
@@ -15,8 +15,8 @@ module FilterDecrufter
15
15
  action_methods.include?(action_name)
16
16
  end
17
17
 
18
- def populated_only_except_options
19
- options.select {|opt_name,opt_value| [:only,:except].include?(opt_name) && !opt_value.empty? }
18
+ def populated_options_for(name)
19
+ options.select {|opt_name,opt_value| opt_name == name && !opt_value.empty? }
20
20
  end
21
21
 
22
22
  private
@@ -46,16 +46,14 @@ module FilterDecrufter
46
46
 
47
47
  def find_problems
48
48
  hits.each do |hit|
49
- hit.populated_only_except_options.each do |k,v|
50
- [:only, :except].each do |constraint_name|
51
- check_constraint(constraint_name, hit) if hit.populated_only_except_options[constraint_name].present?
52
- end
49
+ [:only, :except].each do |constraint_name|
50
+ check_constraint(constraint_name, hit) if hit.populated_options_for(constraint_name)[constraint_name].present?
53
51
  end
54
52
  end
55
53
  end
56
54
 
57
55
  def check_constraint(name, hit)
58
- [hit.populated_only_except_options[name]].flatten.each do |action_syms|
56
+ [hit.populated_options_for(name)[name]].flatten.each do |action_syms|
59
57
  [action_syms].flatten.each do |action_name|
60
58
  if !hit.actions_include?(action_name)
61
59
  puts "#{hit.controller_class} #{hit.filter_type} '#{hit.filter_name}' has an :#{name} constraint with a non-existent action name '#{action_name}'"
@@ -92,8 +90,12 @@ module FilterDecrufter
92
90
 
93
91
  def patch_method(filter_sym)
94
92
  ApplicationController.define_singleton_method(filter_sym) do |*args, &blk|
95
- if args.many? && (args[1][:only].present? || args[1][:except].present?)
96
- Report.instance.add(FilterDecrufter::Hit.new(self, args[0], args[1], filter_sym))
93
+ filter_names = args.select {|a| a.kind_of?(Symbol) }
94
+ filter_options = args.detect {|a| a.kind_of?(Hash) }
95
+ if filter_options.present? && (filter_options[:only].present? || filter_options[:except].present?)
96
+ filter_names.each do |name|
97
+ Report.instance.add(FilterDecrufter::Hit.new(self, name, filter_options, filter_sym))
98
+ end
97
99
  end
98
100
  super(*args, &blk)
99
101
  end
@@ -1,3 +1,3 @@
1
1
  module FilterDecrufter
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filter_decrufter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Copeland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake