From d73dad745a735744b0c80bc063242b63469604dd Mon Sep 17 00:00:00 2001 From: kimihito Date: Fri, 16 May 2025 22:43:53 +0900 Subject: [PATCH 1/4] Bump Ruby version to 3.2.8 --- .ruby-version | 2 +- Gemfile | 2 +- Gemfile.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ruby-version b/.ruby-version index 9cec7165a..f092941a7 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.6 +3.2.8 diff --git a/Gemfile b/Gemfile index 6e3c72806..777786543 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '3.1.6' +ruby '3.2.8' gem 'bootsnap' gem 'pg' diff --git a/Gemfile.lock b/Gemfile.lock index 2415b5684..0afd2fd68 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -567,7 +567,7 @@ DEPENDENCIES web-console RUBY VERSION - ruby 3.1.6p260 + ruby 3.2.8p263 BUNDLED WITH 2.5.19 From 0aaeb06a76790ea11576f8e386f4c0ecf32fb422 Mon Sep 17 00:00:00 2001 From: kimihito Date: Fri, 16 May 2025 23:00:23 +0900 Subject: [PATCH 2/4] Fix File.exists? to File.exist? for compatibility with Ruby 3.2 --- app/controllers/docs_controller.rb | 6 +++--- app/models/podcast.rb | 2 +- spec/models/podcast_spec.rb | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/docs_controller.rb b/app/controllers/docs_controller.rb index e2a1d4b4d..7df4cd126 100644 --- a/app/controllers/docs_controller.rb +++ b/app/controllers/docs_controller.rb @@ -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. diff --git a/app/models/podcast.rb b/app/models/podcast.rb index d4add910f..058ea87f9 100644 --- a/app/models/podcast.rb +++ b/app/models/podcast.rb @@ -21,7 +21,7 @@ def path def exists?(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 diff --git a/spec/models/podcast_spec.rb b/spec/models/podcast_spec.rb index ec462a001..e5f664dd1 100644 --- a/spec/models/podcast_spec.rb +++ b/spec/models/podcast_spec.rb @@ -19,11 +19,11 @@ 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) end @@ -35,11 +35,11 @@ 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) end From e8dcdf5a962f5f3ff94b2045e907bd40a5ad5a0b Mon Sep 17 00:00:00 2001 From: kimihito Date: Sat, 17 May 2025 14:42:14 +0900 Subject: [PATCH 3/4] Change method name from exists? to exist? to match `File#exist?` --- app/controllers/docs_controller.rb | 2 +- app/models/document.rb | 8 ++++---- app/models/podcast.rb | 4 ++-- app/views/podcasts/_navigation.html.erb | 4 ++-- spec/features/podcasts_spec.rb | 6 +++--- spec/models/podcast_spec.rb | 16 ++++++++-------- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/docs_controller.rb b/app/controllers/docs_controller.rb index 7df4cd126..9cd3b25ab 100644 --- a/app/controllers/docs_controller.rb +++ b/app/controllers/docs_controller.rb @@ -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 diff --git a/app/models/document.rb b/app/models/document.rb index 2bac3899c..513fb4d82 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -55,13 +55,13 @@ 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 @@ -69,7 +69,7 @@ def title 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 @@ -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 diff --git a/app/models/podcast.rb b/app/models/podcast.rb index 058ea87f9..ca6c09126 100644 --- a/app/models/podcast.rb +++ b/app/models/podcast.rb @@ -18,7 +18,7 @@ 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.exist?("#{DIR_PATH}/#{id + offset}.md") @@ -30,6 +30,6 @@ def cover end def content - exists? ? File.read(path) : '' + exist? ? File.read(path) : '' end end diff --git a/app/views/podcasts/_navigation.html.erb b/app/views/podcasts/_navigation.html.erb index 7cd656a23..7115660a1 100644 --- a/app/views/podcasts/_navigation.html.erb +++ b/app/views/podcasts/_navigation.html.erb @@ -1,6 +1,6 @@