Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- "~> 7.0.0"
- "~> 7.1.0"
- "~> 7.2.0"
- "~> 8.0.0"
addressable-version:
- "~> 2.4.0"
- "~> 2.5.0"
Expand Down
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Style/Copyright:
Style/DisableCopsWithinSourceCodeDirective:
AutoCorrect: false
AllowedCops:
- Lint/DuplicateMethods
- Lint/RescueException
- Rails/ApplicationRecord
- Rails/RakeEnvironment
Expand Down
19 changes: 12 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ end
group :development, :test do
gem "sprockets-rails"

# Specify the version for resolving a `LoadError`.
# cf. https://github.com/kg8m/tanshuku/actions/runs/8965867396
#
# LoadError:
# Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4),
# already activated sqlite3-2.0.1-x86_64-linux-gnu. Make sure all dependencies are added to Gemfile.
gem "sqlite3", "~> 1.7"
case Gem::Version.new(ENV.fetch("RAILS_VERSION", "8.0")[/[\d.]+/])
when "7.0"..."8.0"
# Specify the version for resolving a `LoadError`.
# cf. https://github.com/kg8m/tanshuku/actions/runs/8965867396
#
# LoadError:
# Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4),
# already activated sqlite3-2.0.1-x86_64-linux-gnu. Make sure all dependencies are added to Gemfile.
gem "sqlite3", "~> 1.7"
else
gem "sqlite3"
end
end

group :development do
Expand Down
127 changes: 64 additions & 63 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,65 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
actioncable (8.0.0)
actionpack (= 8.0.0)
activesupport (= 8.0.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
actionmailbox (8.0.0)
actionpack (= 8.0.0)
activejob (= 8.0.0)
activerecord (= 8.0.0)
activestorage (= 8.0.0)
activesupport (= 8.0.0)
mail (>= 2.8.0)
actionmailer (7.2.2)
actionpack (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activesupport (= 7.2.2)
actionmailer (8.0.0)
actionpack (= 8.0.0)
actionview (= 8.0.0)
activejob (= 8.0.0)
activesupport (= 8.0.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.2)
actionview (= 7.2.2)
activesupport (= 7.2.2)
actionpack (8.0.0)
actionview (= 8.0.0)
activesupport (= 8.0.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (7.2.2)
actionpack (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
actiontext (8.0.0)
actionpack (= 8.0.0)
activerecord (= 8.0.0)
activestorage (= 8.0.0)
activesupport (= 8.0.0)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.2)
activesupport (= 7.2.2)
actionview (8.0.0)
activesupport (= 8.0.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.2.2)
activesupport (= 7.2.2)
activejob (8.0.0)
activesupport (= 8.0.0)
globalid (>= 0.3.6)
activemodel (7.2.2)
activesupport (= 7.2.2)
activerecord (7.2.2)
activemodel (= 7.2.2)
activesupport (= 7.2.2)
activemodel (8.0.0)
activesupport (= 8.0.0)
activerecord (8.0.0)
activemodel (= 8.0.0)
activesupport (= 8.0.0)
timeout (>= 0.4.0)
activestorage (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activesupport (= 7.2.2)
activestorage (8.0.0)
actionpack (= 8.0.0)
activejob (= 8.0.0)
activerecord (= 8.0.0)
activesupport (= 8.0.0)
marcel (~> 1.0)
activesupport (7.2.2)
activesupport (8.0.0)
base64
benchmark (>= 0.3)
bigdecimal
Expand All @@ -79,6 +78,7 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
Expand Down Expand Up @@ -127,7 +127,7 @@ GEM
marcel (1.0.4)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.1)
minitest (5.25.2)
net-imap (0.5.1)
date
net-protocol
Expand Down Expand Up @@ -164,30 +164,30 @@ GEM
rackup (1.0.1)
rack (< 3)
webrick
rails (7.2.2)
actioncable (= 7.2.2)
actionmailbox (= 7.2.2)
actionmailer (= 7.2.2)
actionpack (= 7.2.2)
actiontext (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activemodel (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
rails (8.0.0)
actioncable (= 8.0.0)
actionmailbox (= 8.0.0)
actionmailer (= 8.0.0)
actionpack (= 8.0.0)
actiontext (= 8.0.0)
actionview (= 8.0.0)
activejob (= 8.0.0)
activemodel (= 8.0.0)
activerecord (= 8.0.0)
activestorage (= 8.0.0)
activesupport (= 8.0.0)
bundler (>= 1.15.0)
railties (= 7.2.2)
railties (= 8.0.0)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
railties (8.0.0)
actionpack (= 8.0.0)
activesupport (= 8.0.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand All @@ -200,7 +200,7 @@ GEM
ffi (~> 1.0)
rbs (3.6.1)
logger
rdoc (6.7.0)
rdoc (6.8.1)
psych (>= 4.0.0)
regexp_parser (2.9.2)
reline (0.5.11)
Expand Down Expand Up @@ -269,11 +269,11 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.7.3)
sqlite3 (2.3.0)
mini_portile2 (~> 2.8.0)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
sqlite3 (2.3.0-arm64-darwin)
sqlite3 (2.3.0-x86_64-darwin)
sqlite3 (2.3.0-x86_64-linux-gnu)
steep (1.8.3)
activesupport (>= 5.1)
concurrent-ruby (>= 1.1.10)
Expand Down Expand Up @@ -302,13 +302,14 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
useragent (0.16.10)
webrick (1.9.0)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
yard (0.9.37)
zeitwerk (2.6.18)
zeitwerk (2.7.1)

PLATFORMS
arm64-darwin
Expand All @@ -333,7 +334,7 @@ DEPENDENCIES
rubocop-thread_safety
rubocop-yard
sprockets-rails
sqlite3 (~> 1.7)
sqlite3
steep
tanshuku!
thin
Expand Down
23 changes: 23 additions & 0 deletions app/models/tanshuku/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def self.report_exception(exception:, original_url:)
# @param url_options [Hash] An option for Rails’ +url_for+.
#
# @return [String] A shortened URL.
#
# @note
# In Rails 8.0 or later, this method loads the routes before calling +url_for+ as Tanshuku depends on them.
# cf. https://github.com/rails/rails/pull/52353
def shortened_url(url_options = {})
url_options = url_options.symbolize_keys
url_options[:controller] = "tanshuku/urls"
Expand All @@ -175,6 +179,25 @@ def shortened_url(url_options = {})

Tanshuku::Engine.routes.url_for(url_options)
end

case Gem::Version.new(Rails.version)
when "7.0"..."8.0"
# Don’t define `#shortened_url` in this branch because YARD doesn’t recognize the method.
else
# Overwrite the `#shortened_url` in Rails 8.0 or later.
# rubocop:disable Lint/DuplicateMethods
def shortened_url(url_options = {})
Rails.application.reload_routes_unless_loaded

url_options = url_options.symbolize_keys
url_options[:controller] = "tanshuku/urls"
url_options[:action] = :show
url_options[:key] = key

Tanshuku::Engine.routes.url_for(url_options)
end
# rubocop:enable Lint/DuplicateMethods
end
end
# rubocop:enable Rails/ApplicationRecord
end
1 change: 1 addition & 0 deletions spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: Remove this file when support for Rails 7.2 is dropped.
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link tanshuku_manifest.js
1 change: 1 addition & 0 deletions spec/dummy/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: Remove this file when support for Rails 7.2 is dropped.
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: Remove this file when support for Rails 7.2 is dropped.
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
# allow_browser versions: :modern
end
26 changes: 24 additions & 2 deletions spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<title><%= content_for(:title) || "Dummy" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= stylesheet_link_tag "application" %>
<%= yield :head %>

<% case Gem::Version.new(Rails.version) %>
<% when "7.0"..."8.0" %>
<link rel="manifest" href="/manifest.json">
<% else %>
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
<% end %>

<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">

<% case Gem::Version.new(Rails.version) %>
<% when "7.0"..."8.0" %>
<%= stylesheet_link_tag "application" %>
<% else %>
<%# Includes all stylesheet files in app/assets/stylesheets %>
<%= stylesheet_link_tag :app %>
<% end %>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
Expand Down
22 changes: 22 additions & 0 deletions spec/dummy/app/views/pwa/manifest.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Dummy",
"icons": [
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/",
"description": "Dummy.",
"theme_color": "red",
"background_color": "red"
}
Loading