Skip to content

Commit

Permalink
Ruby 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
swrobel committed Feb 16, 2022
1 parent f43fa45 commit 5d6d6a9
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7
3.1
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gem 'webpacker', '~> 5.0'

group :development, :test do
gem 'dotenv-rails'
# disabled until a fix is available for Rails 6.1 compat gem 'pgreset'
gem 'pgreset'
end

group :development do
Expand All @@ -31,7 +31,7 @@ group :development do
gem 'guard-rubocop', require: false
gem 'guard-shell', require: false
gem 'invoker'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'listen', '~> 3.3'
gem 'rack-toolbar', github: 'swrobel/rack-toolbar', branch: 'rails-pages' # Insert arbitrary code into Rails pages
gem 'rubocop'
gem 'rubocop-performance'
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ GEM
rubydns (~> 0.8.5)
thor (>= 0.19, < 2)
uuid (~> 2.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.14.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down Expand Up @@ -172,6 +171,7 @@ GEM
parser (3.1.0.0)
ast (~> 2.4.1)
pg (1.3.2)
pgreset (0.3)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -246,7 +246,6 @@ GEM
rubocop (>= 1.7.0, < 2.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
ruby_dep (1.5.0)
rubydns (0.8.5)
eventmachine (~> 1.0.0)
safely_block (0.3.0)
Expand Down Expand Up @@ -314,11 +313,12 @@ DEPENDENCIES
guard-shell
hiredis
invoker
listen (>= 3.0.5, < 3.2)
listen (~> 3.3)
memery
newrelic_rpm
oj
pg
pgreset
puma
rack-brotli
rack-toolbar!
Expand All @@ -337,7 +337,7 @@ DEPENDENCIES
webpacker (~> 5.0)

RUBY VERSION
ruby 2.7.5p203
ruby 3.1.0p0

BUNDLED WITH
2.2.21
2.2.33
8 changes: 4 additions & 4 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
web: bin/rails server -p $PORT
buoy: bin/buoys_daemon
forecast: bin/forecasts_daemon
release: bin/rails db:migrate db:seed database_views:refresh cache:prune
web: RUBY_YJIT_ENABLE=1 bin/rails server -p $PORT
buoy: RUBY_YJIT_ENABLE=1 bin/buoys_daemon
forecast: RUBY_YJIT_ENABLE=1 bin/forecasts_daemon
release: RUBY_YJIT_ENABLE=1 bin/rails db:migrate db:seed database_views:refresh cache:prune
4 changes: 2 additions & 2 deletions app/models/api_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def get(retries: 0)
if response.success?
# Remove invalid UTF-8 chars from response, ex: Surfline v1 'S�o Jo�o'
response.body.delete!("^\u{0000}-\u{007F}")
self.attributes = { response: service_class.parse(response.body), success: true, response_time: response.total_time, retries: retries }
self.attributes = { response: service_class.parse(response.body), success: true, response_time: response.total_time, retries: }
save!
send(service_parse_method)
else
self.attributes = { response: { message: response.status_message, headers: response.headers, status: response.code }, success: false, response_time: response.total_time, retries: retries }
self.attributes = { response: { message: response.status_message, headers: response.headers, status: response.code }, success: false, response_time: response.total_time, retries: }
SurflineV2.expire_access_token if service == 'SurflineV2' && [401, 403].include?(response.code) # Unauthorized
get(retries: retries + 1)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/api_requests/buoy_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def parse_buoy_report
batch: batch_id,
request: id,
ndbc: ndbc_id,
line: line,
line:,
})
}
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/api_requests/surfline_v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def parse_surfline_v1
end

forecasts.each do |surfline_v1_id, timestamps|
next unless (forecasted_spot = Spot.find_by(surfline_v1_id: surfline_v1_id))
next unless (forecasted_spot = Spot.find_by(surfline_v1_id:))

timestamps.each do |timestamp, values|
# Adjust for DST-related shifts in timestamps so they're all multiples of 3
timestamp -= (timestamp.utc.hour % 3).hours
record = service_class.unscoped.where(spot_id: forecasted_spot.id, timestamp: timestamp).first_or_initialize
record = service_class.unscoped.where(spot_id: forecasted_spot.id, timestamp:).first_or_initialize
record.api_request = self
values.each do |attribute, value|
record[attribute] = value
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/api_requests/surfline_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def parse_surfline_v2_wave
end

# Wind request needs to be made after wave request is completed
ApiRequest.new(batch: batch, requestable: requestable, service: service, hydra: hydra, options: options.merge(type: 'wind'), typhoeus_opts: typhoeus_opts).get
ApiRequest.new(batch:, requestable:, service:, hydra:, options: options.merge(type: 'wind'), typhoeus_opts:).get
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/spots/surfline_v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def surfline_v1_api_url(get_all_spots:, use_nearshore:)
end

def surfline_nearshore_api_url(get_all_spots: true)
surfline_v1_api_url(get_all_spots: get_all_spots, use_nearshore: true)
surfline_v1_api_url(get_all_spots:, use_nearshore: true)
end

def surfline_lola_api_url(get_all_spots: true)
surfline_v1_api_url(get_all_spots: get_all_spots, use_nearshore: false)
surfline_v1_api_url(get_all_spots:, use_nearshore: false)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/spots/surfline_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def surfline_v2_api_url(type:, use_lotus:)
end

def surfline_v2_lola_api_url(type: 'wave')
surfline_v2_api_url(type: type, use_lotus: false)
surfline_v2_api_url(type:, use_lotus: false)
end

def surfline_v2_lotus_api_url(type: 'wave')
surfline_v2_api_url(type: type, use_lotus: true)
surfline_v2_api_url(type:, use_lotus: true)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/surfline_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def access_token
'Authorization' => AUTH_STRING,
'Content-Type' => 'application/json',
}
response = Typhoeus.post("#{SurflineV2.base_api_url}/trusted/token?isShortLived=false", headers: headers, body: body)
response = Typhoeus.post("#{SurflineV2.base_api_url}/trusted/token?isShortLived=false", headers:, body:)
raise "Surfline v2 access token refresh error: #{response.body}" unless response.success?

logger.info 'Surfline v2 access token refreshed!'
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
config.hosts << 'surf.localhost'

dev_server = Webpacker.config.dev_server
WEBPACK_SCRIPT_TAG ||= "<script src='#{"http#{dev_server[:https] && 's'}"}://#{dev_server[:host]}:#{dev_server[:port]}/webpack-dev-server.js'></script>"
WEBPACK_SCRIPT_TAG ||= "<script src='#{"http#{dev_server[:https] && 's'}"}://#{dev_server[:host]}:#{dev_server[:port]}/webpack-dev-server.js'></script>".freeze
config.middleware.insert_before ActionDispatch::ShowExceptions, Rack::Toolbar,
snippet: WEBPACK_SCRIPT_TAG,
insertion_point: '</head>',
Expand Down
2 changes: 1 addition & 1 deletion config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

after_worker_boot do
title = 'MetaSurf server started'
defined?(TerminalNotifier) && TerminalNotifier::Guard.success('', title: title)
defined?(TerminalNotifier) && TerminalNotifier::Guard.success('', title:)
defined?(Libnotify) && Libnotify.show(summary: title)
# Trick Webpack into reloading browser
`touch config/locales/en.yml`
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/buoys.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace :buoys do
hydra = Typhoeus::Hydra.new(max_concurrency: @batch.concurrency)

Buoy.all.each do |buoy|
ApiRequest.new(batch: @batch, requestable: buoy, service: BuoyReport, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: buoy, service: BuoyReport, hydra:).get
end

hydra.run
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/msw.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace :msw do
hydra = Typhoeus::Hydra.new(max_concurrency: @batch.concurrency)

Spot.where.not(msw_id: nil).each do |spot|
ApiRequest.new(batch: @batch, requestable: spot, service: Msw, hydra: hydra, typhoeus_opts: { cookie: "MSW_session=#{ENV['MSW_SESSION_ID']}" }).get
ApiRequest.new(batch: @batch, requestable: spot, service: Msw, hydra:, typhoeus_opts: { cookie: "MSW_session=#{ENV['MSW_SESSION_ID']}" }).get
end

hydra.run
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/spitcast_v1.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace :spitcast_v1 do
hydra = Typhoeus::Hydra.new(max_concurrency: @batch.concurrency)

Spot.where.not(spitcast_id: nil).each do |spot|
ApiRequest.new(batch: @batch, requestable: spot, service: SpitcastV1, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: spot, service: SpitcastV1, hydra:).get
end

hydra.run
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/spitcast_v2.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace :spitcast_v2 do
hydra = Typhoeus::Hydra.new(max_concurrency: @batch.concurrency, pipelining: 2)

Spot.where.not(spitcast_id: nil).each do |spot|
ApiRequest.new(batch: @batch, requestable: spot, service: SpitcastV2, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: spot, service: SpitcastV2, hydra:).get
end

hydra.run
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/surfline_v1.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace :surfline_v1 do
hydra = Typhoeus::Hydra.new(max_concurrency: @batch.concurrency)

Spot.where.not(surfline_v1_id: nil).each do |spot|
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineNearshore, options: { get_all_spots: false }, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineLola, options: { get_all_spots: false }, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineNearshore, options: { get_all_spots: false }, hydra:).get
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineLola, options: { get_all_spots: false }, hydra:).get
end

hydra.run
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/surfline_v2.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace :surfline_v2 do
hydra = Typhoeus::Hydra.new(max_concurrency: @batch.concurrency)

Spot.where.not(surfline_v2_id: nil).each do |spot|
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineV2Lola, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineV2Lotus, hydra: hydra).get
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineV2Lola, hydra:).get
ApiRequest.new(batch: @batch, requestable: spot, service: SurflineV2Lotus, hydra:).get
end

hydra.run
Expand Down

0 comments on commit 5d6d6a9

Please sign in to comment.