History

Specs all passing

Paul Sernatinger committed 4 years ago

Commit 2da05d71 parent b3e55ed37 files · +198 −178Browse files

Showing the changes to lib (5 of 37 files). Show all

Unified · Split

5 files
  1. lib/app.rb +16 −1
  2. lib/docs/core/request.rb +1 −1
  3. lib/docs/core/requester.rb +8 −8
  4. lib/docs/core/scraper.rb +1 −1
  5. lib/tasks/updates.thor +1 −1
lib/app.rb+16−1
@@ -238,7 +238,22 @@ class App < Sinatra::Application · 237 unmodified lines
238238 end
239239
240240 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?
242257 end
243258 end
244259
lib/docs/core/request.rb+1−1
@@ -13,7 +13,7 @@ module Docs · 12 unmodified lines
1313 request.run
1414 end
1515
16− def initialize(url, options = {})
16+ def initialize(url, **options)
1717 super url.to_s, DEFAULT_OPTIONS.merge(options)
1818 end
1919
lib/docs/core/requester.rb+8−8
@@ -4,10 +4,10 @@ module Docs · 3 unmodified lines
44
55 attr_reader :request_options
66
7− def self.run(urls, options = {}, &block)
7+ def self.run(urls, **options, &block)
88 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?
1111 requester.on_response do # cheap hack to ensure root page is processed first
1212 if urls
1313 requester.request(urls)
@@ -19,16 +19,16 @@ module Docs · 5 unmodified lines
1919 requester
2020 end
2121
22− def initialize(options = {})
22+ def initialize(**options)
2323 @request_options = options.extract!(:request_options)[:request_options].try(:dup) || {}
2424 options[:max_concurrency] ||= 20
2525 options[:pipelining] = 0
2626 super
2727 end
2828
29− def request(urls, options = {}, &block)
29+ def request(urls, **options, &block)
3030 requests = [urls].flatten.map do |url|
31− build_and_queue_request(url, options, &block)
31+ build_and_queue_request(url, **options, &block)
3232 end
3333 requests.length == 1 ? requests.first : requests
3434 end
@@ -46,8 +46,8 @@ module Docs · 11 unmodified lines
4646
4747 private
4848
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))
5151 request.on_complete(&block) if block
5252 queue(request)
5353 request
lib/docs/core/scraper.rb+1−1
@@ -51,7 +51,7 @@ module Docs · 50 unmodified lines
5151 end
5252
5353 def initialize_stubs
54− self.class.stubs.each do |path, block|
54+ self.class.stubs.each do |path, &block|
5555 Typhoeus.stub(url_for(path)).and_return do
5656 Typhoeus::Response.new \
5757 effective_url: url_for(path),
lib/tasks/updates.thor+1−1
@@ -259,7 +259,7 @@ Maintainers can close this issue when all documentations are up-to-date. The iss · 258 unmodified lines
259259 # HTTP utilities
260260 #
261261
262− def github_get(endpoint, params = {})
262+ def github_get(endpoint, **params)
263263 github_request(endpoint, {method: :get, params: params})
264264 end
265265

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t