Showing the changes to lib (5 of 37 files). Show all
Unified · Split
| @@ -238,7 +238,22 @@ class App < Sinatra::Application · 237 unmodified lines | ||
| 238 | 238 | end |
| 239 | 239 | |
| 240 | 240 | def supports_js_redirection? |
| 241 | − browser.modern? && !memoized_cookies.empty? | |
| 241 | + modern_browser?(browser) && !memoized_cookies.empty? | |
| 242 | + end | |
| 243 | + | |
| 244 | + # https://github.com/fnando/browser#detecting-modern-browsers | |
| 245 | + # https://github.com/fnando/browser/blob/v2.6.1/lib/browser/browser.rb | |
| 246 | + # This restores the old browser gem `#modern?` functionality as it was in 2.6.1 | |
| 247 | + # It's possible this isn't even really needed any longer, these versions are quite old now | |
| 248 | + def modern_browser?(browser) | |
| 249 | + [ | |
| 250 | + browser.webkit?, | |
| 251 | + browser.firefox? && browser.version.to_i >= 17, | |
| 252 | + browser.ie? && browser.version.to_i >= 9 && !browser.compatibility_view?, | |
| 253 | + browser.edge? && !browser.compatibility_view?, | |
| 254 | + browser.opera? && browser.version.to_i >= 12, | |
| 255 | + browser.firefox? && browser.device.tablet? && browser.platform.android? && b.version.to_i >= 14 | |
| 256 | + ].any? | |
| 242 | 257 | end |
| 243 | 258 | end |
| 244 | 259 | |
| @@ -13,7 +13,7 @@ module Docs · 12 unmodified lines | ||
| 13 | 13 | request.run |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | − def initialize(url, options = {}) | |
| 16 | + def initialize(url, **options) | |
| 17 | 17 | super url.to_s, DEFAULT_OPTIONS.merge(options) |
| 18 | 18 | end |
| 19 | 19 | |
| @@ -4,10 +4,10 @@ module Docs · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | attr_reader :request_options |
| 6 | 6 | |
| 7 | − def self.run(urls, options = {}, &block) | |
| 7 | + def self.run(urls, **options, &block) | |
| 8 | 8 | urls = urls.dup |
| 9 | − requester = new(options) | |
| 10 | − requester.on_response(&block) if block | |
| 9 | + requester = new(**options) | |
| 10 | + requester.on_response(&block) if block_given? | |
| 11 | 11 | requester.on_response do # cheap hack to ensure root page is processed first |
| 12 | 12 | if urls |
| 13 | 13 | requester.request(urls) |
| @@ -19,16 +19,16 @@ module Docs · 5 unmodified lines | ||
| 19 | 19 | requester |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | − def initialize(options = {}) | |
| 22 | + def initialize(**options) | |
| 23 | 23 | @request_options = options.extract!(:request_options)[:request_options].try(:dup) || {} |
| 24 | 24 | options[:max_concurrency] ||= 20 |
| 25 | 25 | options[:pipelining] = 0 |
| 26 | 26 | super |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | − def request(urls, options = {}, &block) | |
| 29 | + def request(urls, **options, &block) | |
| 30 | 30 | requests = [urls].flatten.map do |url| |
| 31 | − build_and_queue_request(url, options, &block) | |
| 31 | + build_and_queue_request(url, **options, &block) | |
| 32 | 32 | end |
| 33 | 33 | requests.length == 1 ? requests.first : requests |
| 34 | 34 | end |
| @@ -46,8 +46,8 @@ module Docs · 11 unmodified lines | ||
| 46 | 46 | |
| 47 | 47 | private |
| 48 | 48 | |
| 49 | − def build_and_queue_request(url, options, &block) | |
| 50 | − request = Request.new(url, request_options.merge(options)) | |
| 49 | + def build_and_queue_request(url, **options, &block) | |
| 50 | + request = Request.new(url, **request_options.merge(options)) | |
| 51 | 51 | request.on_complete(&block) if block |
| 52 | 52 | queue(request) |
| 53 | 53 | request |
| @@ -51,7 +51,7 @@ module Docs · 50 unmodified lines | ||
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | def initialize_stubs |
| 54 | − self.class.stubs.each do |path, block| | |
| 54 | + self.class.stubs.each do |path, &block| | |
| 55 | 55 | Typhoeus.stub(url_for(path)).and_return do |
| 56 | 56 | Typhoeus::Response.new \ |
| 57 | 57 | effective_url: url_for(path), |
| @@ -259,7 +259,7 @@ Maintainers can close this issue when all documentations are up-to-date. The iss · 258 unmodified lines | ||
| 259 | 259 | # HTTP utilities |
| 260 | 260 | # |
| 261 | 261 | |
| 262 | − def github_get(endpoint, params = {}) | |
| 262 | + def github_get(endpoint, **params) | |
| 263 | 263 | github_request(endpoint, {method: :get, params: params}) |
| 264 | 264 | end |
| 265 | 265 | |