Skip to content

Commit

Permalink
Merge pull request #14 from splaplapla/ruby3-2
Browse files Browse the repository at this point in the history
Support ruby3.2
  • Loading branch information
jiikko authored Apr 16, 2023
2 parents 454a989 + 69b7699 commit bec9b31
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
ruby-version: ['2.5', '3.0', '3.1']
ruby-version: ['2.5', '3.0', '3.1', '3.2']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.0
FROM ruby:3.2

WORKDIR /pbmenv

Expand Down
12 changes: 6 additions & 6 deletions lib/pbmenv/services/create_version_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(version: , use_option: , enable_pbm_cloud: )

def execute!
pathname = VersionPathname.new(version)
if File.exists?(pathname.version_path)
if File.exist?(pathname.version_path)
raise AlreadyCreatedError
end

Expand All @@ -33,7 +33,7 @@ def execute!
Helper.system_and_puts "rm -rf #{pathname.version_path}"
raise
ensure
if Dir.exists?(pathname.src_pbm_path)
if Dir.exist?(pathname.src_pbm_path)
Helper.system_and_puts "rm -rf #{pathname.src_pbm_path}"
end
end
Expand All @@ -53,7 +53,7 @@ def build_app_file
Helper.system_and_puts "mkdir -p #{pathname.version_path}"
Helper.system_and_puts "cp -r #{pathname.src_project_template_systemd_units} #{pathname.version_path}/"

if File.exists?(pathname.src_pbm_project_template_app_rb_erb_path)
if File.exist?(pathname.src_pbm_project_template_app_rb_erb_path)
pathname.project_template_file_paths(include_app_erb: true).each do |project_template_file_path|
Helper.system_and_puts "cp #{project_template_file_path} #{pathname.version_path}/"
end
Expand All @@ -80,7 +80,7 @@ def build_app_file
end

def create_if_miss_shared_dir
return if File.exists?(VersionPathname.shared)
return if File.exist?(VersionPathname.shared)

Helper.system_and_puts <<~SHELL
mkdir -p #{VersionPathname.shared}
Expand All @@ -89,7 +89,7 @@ def create_if_miss_shared_dir

def create_if_miss_device_id_file
device_id_path_in_shared = VersionPathname.device_id_path_in_shared
return if File.exists?(device_id_path_in_shared)
return if File.exist?(device_id_path_in_shared)

File.write(device_id_path_in_shared, "d_#{SecureRandom.uuid}")
end
Expand All @@ -103,7 +103,7 @@ def link_device_id_file(version: )

def create_if_miss_current_dir(version: )
# 初回だけinstall時にcurrentを作成する
if !File.exists?(VersionPathname.current) || use_option
if !File.exist?(VersionPathname.current) || use_option
UseVersionService.new(version: version).execute!
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pbmenv/services/destroy_version_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(version: )
def execute!
version_pathname = VersionPathname.new(version)

unless File.exists?(version_pathname.version_path)
unless File.exist?(version_pathname.version_path)
raise VersionNotFoundError
end
Helper.system_and_puts "rm -rf #{version_pathname.version_path}"
Expand Down
2 changes: 1 addition & 1 deletion lib/pbmenv/services/download_src_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def execute!
end

if Helper.system_and_puts(shell)
unless File.exists?(pathname.src_pbm_project_template_path)
unless File.exist?(pathname.src_pbm_project_template_path)
raise NotSupportVersionError, "This version is not support by pbmenv"
end
else
Expand Down
2 changes: 1 addition & 1 deletion lib/pbmenv/services/use_version_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def execute!
def throw_error_if_has_not_version
version_pathname = VersionPathname.new(version)

if !File.exists?(version_pathname.version_path_without_v) && !File.exists?(version_pathname.version_path)
if !File.exist?(version_pathname.version_path_without_v) && !File.exist?(version_pathname.version_path)
raise UseVersionService::VersionNotFoundError
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/pbmenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ def purge_pbm_dir
latest_version = Pbmenv.available_versions.detect { |x| x == target_version }
version_path = "/usr/share/pbm/v#{latest_version}"
expect(Pbmenv.current_directory.readlink).to eq("/usr/share/pbm/v#{target_version}")
expect(Dir.exists?(version_path)).to eq(true)
expect(File.exists?("#{version_path}/app.rb")).to eq(true)
expect(File.exists?("#{version_path}/README.md")).to eq(true)
expect(File.exists?("#{version_path}/setting.yml")).to eq(true)
expect(Dir.exists?("/usr/share/pbm/shared")).to eq(true)
expect(Dir.exist?(version_path)).to eq(true)
expect(File.exist?("#{version_path}/app.rb")).to eq(true)
expect(File.exist?("#{version_path}/README.md")).to eq(true)
expect(File.exist?("#{version_path}/setting.yml")).to eq(true)
expect(Dir.exist?("/usr/share/pbm/shared")).to eq(true)
expect(File.read("/usr/share/pbm/shared/device_id")).to be_a(String)
end
end
Expand All @@ -134,11 +134,11 @@ def purge_pbm_dir
latest_version = Pbmenv.available_versions.first
version_path = "/usr/share/pbm/v#{latest_version}"
expect(Pbmenv.current_directory.readlink).to match(%r!/usr/share/pbm/v[\d.]+!)
expect(Dir.exists?(version_path)).to eq(true)
expect(File.exists?("#{version_path}/app.rb")).to eq(true)
expect(File.exists?("#{version_path}/README.md")).to eq(true)
expect(File.exists?("#{version_path}/setting.yml")).to eq(true)
expect(Dir.exists?("/usr/share/pbm/shared")).to eq(true)
expect(Dir.exist?(version_path)).to eq(true)
expect(File.exist?("#{version_path}/app.rb")).to eq(true)
expect(File.exist?("#{version_path}/README.md")).to eq(true)
expect(File.exist?("#{version_path}/setting.yml")).to eq(true)
expect(Dir.exist?("/usr/share/pbm/shared")).to eq(true)
expect(File.read("/usr/share/pbm/shared/device_id")).to be_a(String)
end
end
Expand Down Expand Up @@ -265,7 +265,7 @@ def purge_pbm_dir
it "URLの行がアンコメントアウトされていること" do
subject
a_pbm_path = "/usr/share/pbm/v#{target_version}"
expect(File.exists?("#{a_pbm_path}/app.rb.erb")).to eq(false)
expect(File.exist?("#{a_pbm_path}/app.rb.erb")).to eq(false)
# 特定行をアンコメントしていること
expect(File.read("#{a_pbm_path}/app.rb")).to match(%r!^ config.api_servers = \['https://pbm-cloud.herokuapp.com'\]$!)
end
Expand All @@ -279,7 +279,7 @@ def purge_pbm_dir
it "URLの行がコメントアウトされていること" do
subject
a_pbm_path = "/usr/share/pbm/v#{target_version}"
expect(File.exists?("#{a_pbm_path}/app.rb.erb")).to eq(false)
expect(File.exist?("#{a_pbm_path}/app.rb.erb")).to eq(false)
# 特定行をコメントアウトしていること
expect(File.read("#{a_pbm_path}/app.rb")).to match(%r!^ # config.api_servers = \['https://pbm-cloud.herokuapp.com'\]$!)
end
Expand Down
14 changes: 7 additions & 7 deletions spec/support/correct_pbm_dir_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
it '/usr/share/pbm/v#{target_version}/ にファイルを作成すること' do
subject
a_pbm_path = "/usr/share/pbm/v#{target_version}"
expect(Dir.exists?("/usr/share/pbm/v#{target_version}")).to eq(true)
expect(File.exists?("/usr/share/pbm/v#{target_version}/app.rb")).to eq(true)
expect(File.exists?("#{a_pbm_path}/README.md")).to eq(true)
expect(File.exists?("#{a_pbm_path}/setting.yml")).to eq(true)
expect(File.exists?("#{a_pbm_path}/systemd_units/pbm.service")).to eq(true)
expect(Dir.exist?("/usr/share/pbm/v#{target_version}")).to eq(true)
expect(File.exist?("/usr/share/pbm/v#{target_version}/app.rb")).to eq(true)
expect(File.exist?("#{a_pbm_path}/README.md")).to eq(true)
expect(File.exist?("#{a_pbm_path}/setting.yml")).to eq(true)
expect(File.exist?("#{a_pbm_path}/systemd_units/pbm.service")).to eq(true)
end

it '/usr/share/pbm/v#{target_version}/device_idを作成すること' do
Expand All @@ -22,13 +22,13 @@
it '解凍したファイルを削除していること' do
subject
target_version = decompress_procon_pbm_man_versions.first
expect(Dir.exists?("procon_bypass_man-#{target_version}")).to eq(false)
expect(Dir.exist?("procon_bypass_man-#{target_version}")).to eq(false)
end

it 'uninstallしたらディレクトリを消す' do
subject
Pbmenv.uninstall(target_version)
expect(Dir.exists?(target_version)).to eq(false)
expect(Dir.exist?(target_version)).to eq(false)
end

it 'もう一度installしてもエラーにならない' do
Expand Down

0 comments on commit bec9b31

Please sign in to comment.