Skip to content

Commit 91583f7

Browse files
committed
Satisfy rubocop
1 parent 26137cc commit 91583f7

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

Gemfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@ source "https://rubygems.org"
22

33
gemspec
44

5-
RUBOCOP_PLATFORMS = [:ruby_20, :ruby_21, :ruby_22]
6-
75
ruby_version = RUBY_VERSION.to_f
8-
if ruby_version < 2.0 # 1.9.3 and 1.8.7
9-
RUBOCOP_PLATFORMS = [:ruby_20, :ruby_21]
10-
end
6+
rubocop_platform = [:ruby_20, :ruby_21, :ruby_22]
7+
rubocop_platform = [:ruby_20, :ruby_21] if ruby_version < 2.0
118

129
group :test do
1310
gem "rspec"
1411
gem "rack-test"
1512
gem "webmock"
16-
gem "rubocop", :platform => RUBOCOP_PLATFORMS
13+
gem "rubocop", :platform => rubocop_platform
1714

18-
if ruby_version < 1.9 # 1.8.7
19-
gem "addressable", "< 2.4"
20-
end
15+
gem "addressable", "< 2.4" if ruby_version < 1.9
2116
end
2217

2318
group :development, :test do

lib/rack_reverse_proxy/middleware.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def reverse_proxy_options(options)
3232

3333
def reverse_proxy(rule, url = nil, opts = {})
3434
if rule.is_a?(String) && url.is_a?(String) && URI(url).class == URI::Generic
35-
fail Errors::GenericURI.new, url
35+
raise Errors::GenericURI.new, url
3636
end
3737
@rules << Rule.new(rule, url, opts)
3838
end

lib/rack_reverse_proxy/response_builder.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module RackReverseProxy
2+
# ResponseBuilder knows target response building process
23
class ResponseBuilder
34
def initialize(target_request, uri, options)
4-
@target_request, @uri, @options =
5-
target_request, uri, options
5+
@target_request = target_request
6+
@uri = uri
7+
@options = options
68
end
79

810
def fetch
@@ -42,7 +44,7 @@ def handle_verify_mode
4244
end
4345

4446
def verify_mode?
45-
!!options[:verify_mode]
47+
options.key?(:verify_mode)
4648
end
4749

4850
def target_response

lib/rack_reverse_proxy/roundtrip.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module RackReverseProxy
77
# RoundTrip represents one request-response made by rack-reverse-proxy
88
# middleware.
99
class RoundTrip
10-
def initialize(app, env, global_options, rules, response_builder_klass=ResponseBuilder)
10+
def initialize(app, env, global_options, rules, response_builder_klass = ResponseBuilder)
1111
@app = app
1212
@env = env
1313
@global_options = global_options
@@ -92,7 +92,7 @@ def host_header
9292
def set_forwarded_host
9393
return unless options[:x_forwarded_host]
9494
target_request_headers["X-Forwarded-Host"] = source_request.host
95-
target_request_headers["X-Forwarded-Port"] = "#{source_request.port}"
95+
target_request_headers["X-Forwarded-Port"] = source_request.port.to_s
9696
end
9797

9898
def initialize_http_header
@@ -253,7 +253,7 @@ def matches
253253

254254
def non_ambiguous_match
255255
return unless ambiguous_match?
256-
fail Errors::AmbiguousMatch.new(path, matches)
256+
raise Errors::AmbiguousMatch.new(path, matches)
257257
end
258258

259259
def ambiguous_match?

lib/rack_reverse_proxy/rule.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def build_matcher(spec)
4848
return /^#{spec}/ if spec.is_a?(String)
4949
return spec if spec.respond_to?(:match)
5050
return spec if spec.respond_to?(:call)
51-
fail ArgumentError, "Invalid Rule for reverse_proxy"
51+
raise ArgumentError, "Invalid Rule for reverse_proxy"
5252
end
5353

5454
# Candidate represents a request being matched

lib/rack_reverse_proxy/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#:nodoc:
22
module RackReverseProxy
3-
VERSION = "0.9.1"
3+
VERSION = "0.9.1".freeze
44
end

spec/rack/reverse_proxy_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def app
460460
#:nodoc:
461461
class Matcher
462462
def self.match(path)
463-
return unless path.match(%r{^/(test|users)})
463+
return unless path =~ %r{^/(test|users)}
464464
Matcher.new
465465
end
466466

@@ -504,7 +504,7 @@ def initialize(rackreq)
504504
end
505505

506506
def self.match(path, _headers, rackreq)
507-
return nil unless path.match(%r{^/(test|users)})
507+
return nil unless path =~ %r{^/(test|users)}
508508
RequestMatcher.new(rackreq)
509509
end
510510

0 commit comments

Comments
 (0)