rubocoped

This commit is contained in:
HoneyryderChuck 2018-02-13 22:19:05 +00:00
parent e003657d92
commit 273cdd45b5
10 changed files with 22 additions and 19 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
require "rake/testtask"
require 'rubocop/rake_task'
require "rubocop/rake_task"
Rake::TestTask.new do |t|
t.libs = %w[lib test]
@ -9,10 +9,9 @@ Rake::TestTask.new do |t|
t.warning = false
end
desc 'Run rubocop'
desc "Run rubocop"
task :rubocop do
RuboCop::RakeTask.new
end
task :"test:ci" => [:test, :rubocop]
task :"test:ci" => %i[test rubocop]

View File

@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
gem.homepage = "https://gitlab.com/honeyryderchuck/httpx"
gem.licenses = ["Apache 2.0"]
gem.files = %w(LICENSE.txt README.md Rakefile) + Dir["doc/**/*.{rdoc,txt}"] + Dir["{lib}/**/*.{rb,RB}"]
gem.files = %w[LICENSE.txt README.md Rakefile] + Dir["doc/**/*.{rdoc,txt}"] + Dir["{lib}/**/*.{rb,RB}"]
gem.name = "httpx"
gem.require_paths = ["lib"]

View File

@ -13,7 +13,7 @@ module HTTPX
def_delegator :@buffer, :to_str
def_delegator :@buffer, :empty?
def_delegator :@buffer, :bytesize
def_delegator :@buffer, :slice!

View File

@ -25,7 +25,7 @@ module HTTPX
end
def plugin(*plugins)
klass = self.is_a?(Client) ? self.class : Client
klass = is_a?(Client) ? self.class : Client
klass = Class.new(klass)
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
klass.plugins(plugins).new

View File

@ -68,7 +68,11 @@ module HTTPX
end
def match?(uri)
ip = TCPSocket.getaddress(uri.host) rescue uri.host
ip = begin
TCPSocket.getaddress(uri.host)
rescue StandardError
uri.host
end
ip == @io.ip &&
uri.port == @io.port &&
@ -87,14 +91,14 @@ module HTTPX
pr = @parser
transition(:closed)
return true if hard
unless pr && pr.empty?
if pr && pr.empty?
pr.close
@parser = nil
else
transition(:idle)
@parser = pr
parser.reenqueue!
return false
else
pr.close
@parser = nil
end
true
end

View File

@ -104,7 +104,7 @@ module HTTPX
log(2) { "parsing complete" }
request = @requests.first
response = request.response
if !@parser_trailers && response.headers.key?("trailer")
@parser_trailers = true
# this is needed, because the parser can't accept further headers.

View File

@ -91,7 +91,7 @@ module HTTPX
end
def empty?
@requests.reject{ |r| r.verb == :connect }.empty? ||
@requests.reject { |r| r.verb == :connect }.empty? ||
@requests.all? { |request| !request.response.nil? }
end
end

View File

@ -14,7 +14,7 @@ module HTTPX
def mark_as_pushed!
@__pushed = true
end
end
end
module InstanceMethods
def initialize(opts = {})

View File

@ -2,7 +2,7 @@
module HTTPX
module Plugins
module Stream
module Stream
module InstanceMethods
def stream
headers("accept" => "text/event-stream",
@ -14,7 +14,7 @@ module HTTPX
def complete?
super ||
stream? &&
@stream_complete
@stream_complete
end
def stream?
@ -28,6 +28,6 @@ module HTTPX
end
end
end
register_plugin :stream, Stream
register_plugin :stream, Stream
end
end

View File

@ -82,7 +82,7 @@ class HTTPX::Selector
monitor = readable ? @readers[io] : Monitor.new(io, interests, self)
end
@writers[io] = monitor
@readers.delete(io) unless readable
@readers.delete(io) unless readable
end
monitor
end