format_restricter_rails 1.0.0 → 1.0.1

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: b4d7d23d624a097eadc3686966910b7289a5176c
4
- data.tar.gz: ede176de4c1a46d0d18698a09059f9fe52d05507
3
+ metadata.gz: 4972618603956be5371074aff97c5789b6aec167
4
+ data.tar.gz: 627c68d3c620600806fd4553cb310dfa67ed3845
5
5
  SHA512:
6
- metadata.gz: 40d3b502fb25e361bd161d1a2428f6cb889d1d61d41478760206f607ecb07b932162db92b563e0c22474d694c4f5a1498fded65419077bcaa86e5902eb95a186
7
- data.tar.gz: 663264cc3a72ebb7e3e64597aacf6d515c7dd253688c52b630ea5ef85a56e6236d2e107b30fe7cac0545d06eaf5097e4c668eebbff7f1bfcbe449976fcdbab91
6
+ metadata.gz: 35317de7978900af29f0452fa8eda71db806ab3a65b817fe931da560a692e98ee4649b7c77eaabae7be0c0f0d8f342b841c748d9bc32d389adfd8dae11cc31a0
7
+ data.tar.gz: aed2f149cbb0e918fa32a80a571867b93f66e9b58f724cb7b2b441e63975f38110f932b50251e4ac091f6c799702df1d1f53ae6b13be56934d43b1174dcd587c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.0.1 (May 11, 2016)
4
+
5
+ 1. (Fix) Formats not being blocked when when `only:` or `except:` are not specified (Issue #1)
6
+
3
7
  ## 1.0.0 (May 11, 2016)
4
8
 
5
9
  1. Initial Release
@@ -4,28 +4,24 @@ module FormatRestricterRails
4
4
  def self.included(base)
5
5
  base.extend(ClassMethods)
6
6
  base.instance_eval do
7
- private_class_method :normalize_option
7
+ private_class_method :register_before_action
8
8
  end
9
9
  end
10
10
 
11
11
  module ClassMethods
12
12
  def restrict_formats_to(*args)
13
13
  options = args.extract_options!
14
- except_list = normalize_option(options, :except)
15
- only_list = normalize_option(options, :only)
16
- allowed_formats = args
17
- before_action(only: only_list, except: except_list) do |controller|
18
- unless allowed_formats.include?(request.format.symbol)
14
+ allowed_formats = args.collect {|e| e.to_sym}
15
+ register_before_action(options, allowed_formats)
16
+ end
17
+
18
+ def register_before_action(options, allowed_formats)
19
+ before_action(options) do |controller|
20
+ unless allowed_formats.include?(request.format.symbol)
19
21
  render nothing: true, status: 406
20
22
  end
21
23
  end
22
24
  end
23
-
24
- def normalize_option(options, key)
25
- value = options.fetch(key, [])
26
- value = [value] unless value.is_a?(Array)
27
- value.collect {|e| e.to_sym}
28
- end
29
25
  end
30
26
  end
31
27
  end
@@ -1,3 +1,3 @@
1
1
  module FormatRestricterRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_restricter_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberts
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler