diff --git a/Gemfile b/Gemfile index 46d504f2..a39d7a67 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ group :development do gem "factory_bot", "~> 4.8.2" gem "rspec", "~> 3.7.0" - gem "rubocop", "~> 0.52.1" + gem "rubocop", "~> 0.54.0" gem "webmock", "~> 3.3.0" end diff --git a/Gemfile.lock b/Gemfile.lock index 0a5e2685..2f37fdd2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GEM tzinfo (~> 1.1) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) - ast (2.3.0) + ast (2.4.0) concurrent-ruby (1.0.5) crack (0.4.3) safe_yaml (~> 1.0.0) @@ -51,8 +51,8 @@ GEM opus-ruby (1.0.1) ffi parallel (1.12.1) - parser (2.4.0.2) - ast (~> 2.3) + parser (2.5.0.5) + ast (~> 2.4.0) powerpack (0.1.1) prius (2.0.0) public_suffix (3.0.1) @@ -79,9 +79,9 @@ GEM rspec-support (3.7.0) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.52.1) + rubocop (0.54.0) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) + parser (>= 2.5) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) @@ -125,7 +125,7 @@ DEPENDENCIES rake rspec (~> 3.7.0) rspec_junit_formatter (= 0.3.0) - rubocop (~> 0.52.1) + rubocop (~> 0.54.0) rufus-scheduler (~> 3.4.2) sentry-raven (~> 2.7.2) songkick-transport (~> 1.11.0) diff --git a/app/tfl/data/update.rb b/app/tfl/data/update.rb index 9d2aa7f9..2d6a9047 100755 --- a/app/tfl/data/update.rb +++ b/app/tfl/data/update.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require "open-uri" +require "net/http" require "json" # rubocop:disable Metrics/LineLength @@ -19,19 +19,18 @@ ].freeze # rubocop:enable Metrics/LineLength -DOWNLOADS.each do |download| - url, output, type = *download - +DOWNLOADS.each do |url, output, type| $stdout.puts "Downloading #{url} => #{output}" case type when :json - open(output, "w") do |file| - file << JSON.pretty_generate(JSON.parse(open(url).read)) << "\n" + File.open(output, "w") do |file| + content = Net::HTTP.get(URI(url)) + file << JSON.pretty_generate(JSON.parse(content)) << "\n" end when :xml - stream = open(url) - IO.copy_stream(stream, output) + content = Net::HTTP.get(URI(url)) + File.write(output, content) else raise ArgumentError, "Invalid type" end diff --git a/app/tfl/scraping/press_releases_feed.rb b/app/tfl/scraping/press_releases_feed.rb index fe19b479..2bd1559a 100644 --- a/app/tfl/scraping/press_releases_feed.rb +++ b/app/tfl/scraping/press_releases_feed.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "open-uri" +require "net/http" require "nokogiri" module Tfl @@ -31,7 +31,7 @@ def update!(raw_html: nil) private def download_content - open(PRESS_RELEASES_URL).read + Net::HTTP.get(URI(PRESS_RELEASES_URL)) end def parse_content(content) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b18e444c..6c35a37f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path("../../app", __FILE__) +$LOAD_PATH.unshift File.expand_path("../app", __dir__) ENV["DISCORD_CLIENT_ID"] = "12345678901234567" ENV["DISCORD_TOKEN"] = "t0k3nt0k3nt0k3nt0k3nt0k3n.1234hrx0rz1234token"