From 47d99462f11af8520e585350dac3cd91f24a8df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rodrigues?= Date: Mon, 17 Apr 2023 12:13:05 +0200 Subject: [PATCH 1/2] Replace FIle.exists? by File.exist? for ruby 3 compat --- Rakefile | 2 +- features/steps/common.rb | 8 ++++---- lib/sandbox/installer.rb | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index c484a94..42e07b5 100644 --- a/Rakefile +++ b/Rakefile @@ -57,7 +57,7 @@ Dir[ "#{File.dirname(__FILE__)}/tasks/*.rake" ].sort.each { |ext| load ext } # rdoc.rdoc_files.add( files ) # rdoc.main = "README" # page to start on # rdoc.title = "sandbox" -# # rdoc.template = File.exists?( t="/Users/chris/ruby/projects/err/rock/template.rb" ) ? t : "/var/www/rock/template.rb" +# # rdoc.template = File.exist?( t="/Users/chris/ruby/projects/err/rock/template.rb" ) ? t : "/var/www/rock/template.rb" # rdoc.rdoc_dir = 'doc' # rdoc output folder # rdoc.options << '--inline-source' # end \ No newline at end of file diff --git a/features/steps/common.rb b/features/steps/common.rb index 91cd261..2f1a878 100644 --- a/features/steps/common.rb +++ b/features/steps/common.rb @@ -70,13 +70,13 @@ def setup_active_project_folder project_name Then %r{^folder '(.*)' is created} do |folder| in_project_folder do - File.exists?(folder).should be_true + File.exist?(folder).should be_true end end Then %r{^file '(.*)' (is|is not) created} do |file, is| in_project_folder do - File.exists?(file).should(is == 'is' ? be_true : be_false) + File.exist?(file).should(is == 'is' ? be_true : be_false) end end @@ -87,8 +87,8 @@ def setup_active_project_folder project_name end Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file| - File.exists?(gem_file).should be_true - File.exists?(project_file).should be_true + File.exist?(gem_file).should be_true + File.exist?(project_file).should be_true gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}") project_file_contents = File.read(File.join(@active_project_folder, project_file)) project_file_contents.should == gem_file_contents diff --git a/lib/sandbox/installer.rb b/lib/sandbox/installer.rb index 36bf981..a876d6e 100644 --- a/lib/sandbox/installer.rb +++ b/lib/sandbox/installer.rb @@ -131,7 +131,7 @@ def restore_sandbox_env def resolve_target( path ) # should consider replacing with 'pathname' => Pathname.new( path ) path = fix_path( path ) - if File.exists?( path ) + if File.exist?( path ) raise Sandbox::Error, "target '#{path}' exists" end @@ -153,7 +153,7 @@ def check_path!( path ) else raise Sandbox::Error, "path '#{path}' has a permission problem" end - elsif File.exists?( path ) + elsif File.exist?( path ) raise Sandbox::Error, "path '#{path}' is not a directory" end false From 58108898d764cedab7af77143d387facb5d359c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rodrigues?= Date: Mon, 17 Apr 2023 12:18:54 +0200 Subject: [PATCH 2/2] Use require_relative --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 42e07b5..2857bd9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'rubygems' require 'rake' -require 'lib/sandbox' unless defined? Sandbox +require_relative 'lib/sandbox' unless defined? Sandbox begin require 'echoe'