charcoal 2.6.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/charcoal/controller_filter.rb +5 -5
- data/lib/charcoal/cross_origin.rb +4 -4
- data/lib/charcoal/cross_origin_controller.rb +5 -5
- data/lib/charcoal/jsonp.rb +3 -3
- data/lib/charcoal/utilities.rb +6 -8
- data/lib/charcoal/version.rb +1 -1
- data/lib/charcoal.rb +6 -7
- metadata +8 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0f5357949ef43147b8d283f08389d33a34d88fb5aabfd426458a60b6506dcb
|
4
|
+
data.tar.gz: 6fafd57d4ae6a1236236b6dc7c0bd07c9e6f74d18942bf4d28c1eb3fcdfd615a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8918346db83b8e769a129920b6947287c01b197e677b654f2edc87c0f4add6631d57bb33f72878f0057d9fa73366c0368fb4b9bd48ff83caf7d9d2399ad063e9
|
7
|
+
data.tar.gz: 8989c33065aa23601ea61f472f9eea88b6c0b8d45033eec36a7bc80dcfe992c14a52753aa5f6f7486a62a3ed418de07e67ba130bc3c3b6edaa490cf62ea0c5f3
|
@@ -15,10 +15,10 @@ module Charcoal
|
|
15
15
|
methods = args.map(&:to_sym)
|
16
16
|
methods = [:all] if methods.empty?
|
17
17
|
|
18
|
-
if options[:unless]
|
19
|
-
|
18
|
+
directive = if options[:unless]
|
19
|
+
lambda { |c| !parse_directive(options[:unless]).call(c) }
|
20
20
|
else
|
21
|
-
|
21
|
+
parse_directive(options[:if] || true)
|
22
22
|
end
|
23
23
|
|
24
24
|
methods.each do |method|
|
@@ -34,9 +34,9 @@ module Charcoal
|
|
34
34
|
return directive if directive.respond_to?(:call)
|
35
35
|
|
36
36
|
if directive.respond_to?(:to_sym) && method_defined?(directive.to_sym)
|
37
|
-
lambda {|c| c.send(directive.to_sym)}
|
37
|
+
lambda { |c| c.send(directive.to_sym) }
|
38
38
|
else
|
39
|
-
lambda {|c| directive}
|
39
|
+
lambda { |c| directive }
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "charcoal/controller_filter"
|
2
2
|
|
3
3
|
module Charcoal
|
4
4
|
module CrossOrigin
|
5
5
|
def self.included(klass)
|
6
6
|
klass.extend(ClassMethods)
|
7
7
|
if klass.respond_to?(:around_action)
|
8
|
-
klass.around_action :set_cors_headers_filter, :
|
8
|
+
klass.around_action :set_cors_headers_filter, if: :cors_allowed?
|
9
9
|
else
|
10
|
-
klass.around_filter :set_cors_headers_filter, :
|
10
|
+
klass.around_filter :set_cors_headers_filter, if: :cors_allowed?
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ module Charcoal
|
|
15
15
|
include ControllerFilter
|
16
16
|
|
17
17
|
def cors_allowed
|
18
|
-
@cors_allowed ||= Hash.new(lambda {|_| false})
|
18
|
+
@cors_allowed ||= Hash.new(lambda { |_| false })
|
19
19
|
end
|
20
20
|
|
21
21
|
allow :cors do |method, directive|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# This controller handles CORS preflight requests
|
2
2
|
# See https://developer.mozilla.org/En/HTTP_access_control for documentation
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
4
|
+
require "action_controller/metal"
|
5
|
+
require "active_support/version"
|
6
|
+
require "charcoal/utilities"
|
7
7
|
|
8
8
|
class Charcoal::CrossOriginController < ActionController::Metal
|
9
9
|
include AbstractController::Callbacks
|
@@ -25,10 +25,10 @@ class Charcoal::CrossOriginController < ActionController::Metal
|
|
25
25
|
set_cors_headers
|
26
26
|
headers["Access-Control-Allow-Methods"] = allowed_methods.join(",").upcase
|
27
27
|
headers["Access-Control-Max-Age"] = Charcoal.configuration["max-age"].to_s
|
28
|
-
headers[
|
28
|
+
headers["Access-Control-Allow-Headers"] = Charcoal.configuration["allow-headers"].join(",")
|
29
29
|
end
|
30
30
|
|
31
|
-
head :ok, :
|
31
|
+
head :ok, content_type: "text/plain"
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
data/lib/charcoal/jsonp.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "charcoal/controller_filter"
|
2
2
|
|
3
3
|
module Charcoal
|
4
4
|
module JSONP
|
@@ -15,7 +15,7 @@ module Charcoal
|
|
15
15
|
include ControllerFilter
|
16
16
|
|
17
17
|
def jsonp_allowed
|
18
|
-
@jsonp_allowed ||= Hash.new(lambda {|_| false})
|
18
|
+
@jsonp_allowed ||= Hash.new(lambda { |_| false })
|
19
19
|
end
|
20
20
|
|
21
21
|
allow :jsonp do |method, directive|
|
@@ -41,7 +41,7 @@ module Charcoal
|
|
41
41
|
def add_jsonp_callback
|
42
42
|
yield
|
43
43
|
|
44
|
-
if response.status.to_s.starts_with?(
|
44
|
+
if response.status.to_s.starts_with?("200") && jsonp_request?
|
45
45
|
response.content_type = "application/javascript"
|
46
46
|
response.body = "#{params[:callback]}(#{response.body})"
|
47
47
|
end
|
data/lib/charcoal/utilities.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "action_controller"
|
2
2
|
|
3
3
|
module Charcoal::Utilities
|
4
4
|
Routing = defined?(ActionDispatch) ? ActionDispatch::Routing : ActionController::Routing
|
@@ -15,7 +15,7 @@ module Charcoal::Utilities
|
|
15
15
|
Routing::HTTP_METHODS.select do |verb|
|
16
16
|
next if verb == :options
|
17
17
|
|
18
|
-
route = find_route(request.path, request.env.merge(:
|
18
|
+
route = find_route(request.path, request.env.merge(method: verb))
|
19
19
|
|
20
20
|
if route
|
21
21
|
controller = route[:controller].camelize
|
@@ -28,7 +28,7 @@ module Charcoal::Utilities
|
|
28
28
|
instance.response = response
|
29
29
|
|
30
30
|
method_name = "#{protocol}_allowed"
|
31
|
-
controller.respond_to?(method_name.to_sym) && controller.send(method_name +
|
31
|
+
controller.respond_to?(method_name.to_sym) && controller.send(method_name + "?", instance, action)
|
32
32
|
else
|
33
33
|
false
|
34
34
|
end
|
@@ -40,13 +40,11 @@ module Charcoal::Utilities
|
|
40
40
|
|
41
41
|
railties = Rails.application.railties
|
42
42
|
railties = railties.respond_to?(:all) ? railties.all : railties._all
|
43
|
-
routes += railties.select {|tie| tie.is_a?(Rails::Engine)}.map(&:routes)
|
43
|
+
routes += railties.select { |tie| tie.is_a?(Rails::Engine) }.map(&:routes)
|
44
44
|
|
45
45
|
routes.each do |route_set|
|
46
|
-
|
47
|
-
|
48
|
-
rescue ActionController::RoutingError
|
49
|
-
end
|
46
|
+
return route_set.recognize_path(path, env)
|
47
|
+
rescue ActionController::RoutingError
|
50
48
|
end
|
51
49
|
|
52
50
|
nil
|
data/lib/charcoal/version.rb
CHANGED
data/lib/charcoal.rb
CHANGED
@@ -2,17 +2,16 @@ module Charcoal
|
|
2
2
|
def self.configuration
|
3
3
|
@configuration ||= {
|
4
4
|
"credentials" => true,
|
5
|
-
"expose-headers" => %w
|
6
|
-
"allow-headers" => %w
|
5
|
+
"expose-headers" => %w[],
|
6
|
+
"allow-headers" => %w[X-Requested-With X-Prototype-Version],
|
7
7
|
"max-age" => 86400,
|
8
8
|
"allow-origin" => "*"
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
|
-
autoload :ControllerFilter,
|
13
|
-
autoload :CrossOrigin,
|
14
|
-
autoload :JSONP,
|
12
|
+
autoload :ControllerFilter, "charcoal/controller_filter"
|
13
|
+
autoload :CrossOrigin, "charcoal/cross_origin"
|
14
|
+
autoload :JSONP, "charcoal/jsonp"
|
15
15
|
|
16
|
-
autoload :CrossOriginController,
|
16
|
+
autoload :CrossOriginController, "charcoal/cross_origin_controller"
|
17
17
|
end
|
18
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charcoal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Davidovitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,40 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '7.1'
|
19
|
+
version: '6.1'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '7.1'
|
26
|
+
version: '6.1'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: actionpack
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '7.1'
|
33
|
+
version: '6.1'
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
38
|
- - ">="
|
48
39
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '7.1'
|
40
|
+
version: '6.1'
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: rake
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,20 +52,6 @@ dependencies:
|
|
64
52
|
- - ">="
|
65
53
|
- !ruby/object:Gem::Version
|
66
54
|
version: '0'
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: bump
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0'
|
81
55
|
- !ruby/object:Gem::Dependency
|
82
56
|
name: yard
|
83
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,14 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
105
|
requirements:
|
132
106
|
- - ">="
|
133
107
|
- !ruby/object:Gem::Version
|
134
|
-
version: '
|
108
|
+
version: '3.1'
|
135
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
110
|
requirements:
|
137
111
|
- - ">="
|
138
112
|
- !ruby/object:Gem::Version
|
139
113
|
version: '0'
|
140
114
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.5.11
|
142
116
|
signing_key:
|
143
117
|
specification_version: 4
|
144
118
|
summary: Cross-Origin helper for Rails
|