Skip to content

Rubyのバージョンを3.2.8にする #1684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2025
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
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.6
3.2.8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.1.6
FROM ruby:3.2.8

ENV LANG C.UTF-8

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'
ruby '3.1.6'
ruby '3.2.8'

gem 'bootsnap'
gem 'pg'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ DEPENDENCIES
web-console

RUBY VERSION
ruby 3.1.6p260
ruby 3.2.8p263

BUNDLED WITH
2.5.19
8 changes: 4 additions & 4 deletions app/controllers/docs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def kata

def show
@doc = Document.new(params[:id])
redirect_to root_url unless @doc.exists?
redirect_to root_url unless @doc.exist?

if @doc.content.include? "NUM_OF_"
@doc.content.gsub! "{{ NUM_OF_JAPAN_DOJOS }}", Dojo.active_dojos_count.to_s
Expand All @@ -32,9 +32,9 @@ def show
if @meta_image.end_with? '.webp'
# .webp -> .jpg
# .webp -> .png
@meta_image.gsub!('.webp', '.jpg') if File.exists? "public/#{@meta_image[0..-6]}.jpg"
@meta_image.gsub!('.webp', '.jpeg') if File.exists? "public/#{@meta_image[0..-6]}.jpeg"
@meta_image.gsub!('.webp', '.png') if File.exists? "public/#{@meta_image[0..-6]}.png"
@meta_image.gsub!('.webp', '.jpg') if File.exist? "public/#{@meta_image[0..-6]}.jpg"
@meta_image.gsub!('.webp', '.jpeg') if File.exist? "public/#{@meta_image[0..-6]}.jpeg"
@meta_image.gsub!('.webp', '.png') if File.exist? "public/#{@meta_image[0..-6]}.png"
end

# Add here if you want to optimize meta description.
Expand Down
8 changes: 4 additions & 4 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ def url
"#{URL_PATH}/#{self.filename}"
end

def exists?
def exist?
return false if path.include? "\u0000"
Document.all.map(&:filename).include?(filename)
end

def title
return '' unless self.exists?
return '' unless self.exist?
@title ||=
ActionController::Base.helpers.strip_tags(
Kramdown::Document.new(self.get_first_paragraph, input: 'GFM').to_html
).strip
end

def description
return '' unless self.exists?
return '' unless self.exist?
@desc ||=
ActionController::Base.helpers.strip_tags(
Kramdown::Document.new(self.get_second_paragraph, input: 'GFM').to_html
Expand All @@ -80,7 +80,7 @@ def description=(text)
end

def content
@content ||= self.exists? ? File.read(self.path) : ''
@content ||= self.exist? ? File.read(self.path) : ''
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/models/podcast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def path
"#{DIR_PATH}/#{id}.md"
end

def exists?(offset: 0)
def exist?(offset: 0)
return false if self.path.include?("\u0000")
return false if (self.id + offset).zero?
File.exists?("#{DIR_PATH}/#{id + offset}.md")
File.exist?("#{DIR_PATH}/#{id + offset}.md")
end

def cover
Expand All @@ -30,6 +30,6 @@ def cover
end

def content
exists? ? File.read(path) : ''
exist? ? File.read(path) : ''
end
end
4 changes: 2 additions & 2 deletions app/views/podcasts/_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div style="display: table; font-weight: bolder; width: 100%; padding: 10px 10px; background-color:#3870c4;">
<p class="nav prev">
<% if @episode.exists?(offset: -1) %>
<% if @episode.exist?(offset: -1) %>
<%= link_to podcast_path(@episode.id - 1), title: '前のエピソードを見る' do %>
&laquo; prev
<% end %>
Expand All @@ -12,7 +12,7 @@
<%= link_to '目次に戻る'.html_safe, podcasts_path %>
</p>
<p class="nav next">
<% if @episode.exists?(offset: +1) %>
<% if @episode.exist?(offset: +1) %>
<%= link_to podcast_path(@episode.id + 1), title: '次のエピソードを見る' do %>
next &raquo;
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions spec/features/podcasts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

scenario 'Charter should be exist' do
@podcast = create(:podcast)
allow(@podcast).to receive(:exists?) { true }
allow(@podcast).to receive(:exists?).with(offset: -1) { false }
allow(@podcast).to receive(:exist?) { true }
allow(@podcast).to receive(:exist?).with(offset: -1) { false }
allow(@podcast).to receive(:content) { "title\n収録日: 2019/05/10\n..." }
allow(Podcast).to receive(:find_by).with(id: @podcast.id.to_s) { @podcast }

Expand All @@ -25,7 +25,7 @@

scenario 'Load doc file with absolute path' do
@podcast = create(:podcast)
allow(@podcast).to receive(:exists?) { true }
allow(@podcast).to receive(:exist?) { true }
allow(@podcast).to receive(:content) { "title\n収録日: 2019/05/10\n..." }
allow(Podcast).to receive(:find_by).with(id: @podcast.id.to_s) { @podcast }

Expand Down
24 changes: 12 additions & 12 deletions spec/models/podcast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,42 @@
expect(@podcast.path).to eq("public/podcasts/#{@podcast.id}.md")
end

describe 'exists?(offset: 0)' do
describe 'exist?(offset: 0)' do
it '\u0000 を含む ⇒ false' do
allow(@podcast).to receive(:path) { "public/podcasts/\u0000" }

expect(@podcast.exists?).to eq(false)
expect(@podcast.exist?).to eq(false)
end

context 'offset 省略' do
before :each do
allow(File).to receive(:exists?) { false }
allow(File).to receive(:exist?) { false }
end

it 'ファイルあり ⇒ true' do
allow(File).to receive(:exists?).with("public/podcasts/#{@podcast.id}.md") { true }
allow(File).to receive(:exist?).with("public/podcasts/#{@podcast.id}.md") { true }

expect(@podcast.exists?).to eq(true)
expect(@podcast.exist?).to eq(true)
end

it 'ファイルなし ⇒ false' do
expect(@podcast.exists?).to eq(false)
expect(@podcast.exist?).to eq(false)
end
end

context 'offset 指定' do
before :each do
allow(File).to receive(:exists?) { false }
allow(File).to receive(:exist?) { false }
end

it 'ファイルあり ⇒ true' do
allow(File).to receive(:exists?).with("public/podcasts/#{@podcast.id + 1}.md") { true }
allow(File).to receive(:exist?).with("public/podcasts/#{@podcast.id + 1}.md") { true }

expect(@podcast.exists?(offset: 1)).to eq(true)
expect(@podcast.exist?(offset: 1)).to eq(true)
end

it 'ファイルなし ⇒ false' do
expect(@podcast.exists?(offset: 1)).to eq(false)
expect(@podcast.exist?(offset: 1)).to eq(false)
end
end
end
Expand All @@ -57,13 +57,13 @@
end

it 'ファイル存在 ⇒ ファイルから読み込み' do
allow(@podcast).to receive(:exists?) { true }
allow(@podcast).to receive(:exist?) { true }

expect(@podcast.content).to eq(@content_body)
end

it 'ファイルなし ⇒ 空文字列' do
allow(@podcast).to receive(:exists?) { false }
allow(@podcast).to receive(:exist?) { false }

expect(@podcast.content).to eq('')
end
Expand Down