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
2 changes: 1 addition & 1 deletion lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative "bundler/rubygems_ext"
require_relative "bundler/vendored_fileutils"
require "pathname"
autoload :Pathname, "pathname" unless defined?(Pathname)
require "rbconfig"

require_relative "bundler/errors"
Expand Down
6 changes: 2 additions & 4 deletions lib/bundler/cli/gem.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "pathname"

module Bundler
class CLI
Bundler.require_thor_actions
Expand All @@ -26,7 +24,7 @@ def initialize(options, gem_name, thor)
thor.destination_root = nil

@name = @gem_name
@target = SharedHelpers.pwd.join(gem_name)
@target = Pathname.new(SharedHelpers.pwd).join(gem_name)

@extension = options[:ext]

Expand Down Expand Up @@ -278,7 +276,7 @@ def run
private

def resolve_name(name)
SharedHelpers.pwd.join(name).basename.to_s
Pathname.new(SharedHelpers.pwd).join(name).basename.to_s
end

def ask_and_set(key, prompt, explanation)
Expand Down
1 change: 0 additions & 1 deletion lib/bundler/compact_index_client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require "pathname"
require "set"

module Bundler
Expand Down
4 changes: 1 addition & 3 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require_relative "rubygems_integration"
require_relative "current_ruby"

autoload :Pathname, "pathname"

module Bundler
autoload :WINDOWS, File.expand_path("constants", __dir__)
autoload :FREEBSD, File.expand_path("constants", __dir__)
Expand Down Expand Up @@ -57,7 +55,7 @@ def chdir(dir, &blk)

def pwd
Bundler.rubygems.ext_lock.synchronize do
Pathname.pwd
Dir.pwd
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(options)
@path = Pathname.new(options["path"])
expanded_path = expand(@path)
@path = if @path.relative?
expanded_path.relative_path_from(root_path.expand_path)
expanded_path.relative_path_from(File.expand_path(root_path))
else
expanded_path
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_relative "group"

require "digest/sha2"
require "pathname"
require "pathname" unless defined?(Pathname)

class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
Expand Down
4 changes: 1 addition & 3 deletions lib/prism/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,8 @@ def dump_options_version(version)
1
when /\A3\.4(\.\d+)?\z/
2
when /\A3\.5(\.\d+)?\z/
when /\A3\.5(\.\d+)?\z/, /\A4\.0(\.\d+)?\z/
3
when /\A4\.0(\.\d+)?\z/
4
else
if current
raise CurrentVersionError, RUBY_VERSION
Expand Down
2 changes: 2 additions & 0 deletions lib/prism/prism.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Gem::Specification.new do |spec|
"lib/prism/translation/parser33.rb",
"lib/prism/translation/parser34.rb",
"lib/prism/translation/parser35.rb",
"lib/prism/translation/parser40.rb",
"lib/prism/translation/parser/builder.rb",
"lib/prism/translation/parser/compiler.rb",
"lib/prism/translation/parser/lexer.rb",
Expand All @@ -123,6 +124,7 @@ Gem::Specification.new do |spec|
"rbi/prism/translation/parser33.rbi",
"rbi/prism/translation/parser34.rbi",
"rbi/prism/translation/parser35.rbi",
"rbi/prism/translation/parser40.rbi",
"rbi/prism/translation/ripper.rbi",
"rbi/prism/visitor.rbi",
"sig/prism.rbs",
Expand Down
1 change: 1 addition & 0 deletions lib/prism/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Translation # steep:ignore
autoload :Parser33, "prism/translation/parser33"
autoload :Parser34, "prism/translation/parser34"
autoload :Parser35, "prism/translation/parser35"
autoload :Parser40, "prism/translation/parser40"
autoload :Ripper, "prism/translation/ripper"
autoload :RubyParser, "prism/translation/ruby_parser"
end
Expand Down
6 changes: 3 additions & 3 deletions lib/prism/translation/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def initialize(builder = Prism::Translation::Parser::Builder.new, parser: Prism)
end

def version # :nodoc:
35
40
end

# The default encoding for Ruby files is UTF-8.
Expand Down Expand Up @@ -356,8 +356,8 @@ def convert_for_prism(version)
"3.3.1"
when 34
"3.4.0"
when 35
"3.5.0"
when 35, 40
"4.0.0"
else
"latest"
end
Expand Down
7 changes: 1 addition & 6 deletions lib/prism/translation/parser35.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

module Prism
module Translation
# This class is the entry-point for Ruby 3.5 of `Prism::Translation::Parser`.
class Parser35 < Parser
def version # :nodoc:
35
end
end
Parser35 = Parser40 # :nodoc:
end
end
13 changes: 13 additions & 0 deletions lib/prism/translation/parser40.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true
# :markup: markdown

module Prism
module Translation
# This class is the entry-point for Ruby 4.0 of `Prism::Translation::Parser`.
class Parser40 < Parser
def version # :nodoc:
40
end
end
end
end
4 changes: 2 additions & 2 deletions lib/prism/translation/parser_current.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module Translation
ParserCurrent = Parser33
when /^3\.4\./
ParserCurrent = Parser34
when /^3\.5\./
ParserCurrent = Parser35
when /^3\.5\./, /^4\.0\./
ParserCurrent = Parser40
else
# Keep this in sync with released Ruby.
parser = Parser34
Expand Down
20 changes: 5 additions & 15 deletions prism/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,26 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
return true;
}

if (strncmp(version, "3.5", 3) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_3_5;
return true;
}

if (strncmp(version, "4.0", 3) == 0) {
if (strncmp(version, "3.5", 3) == 0 || strncmp(version, "4.0", 3) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
return true;
}

return false;
}

if (length >= 4) {
if (strncmp(version, "3.3.", 4) == 0 && is_number(version + 4, length - 4)) {
if (length >= 4 && is_number(version + 4, length - 4)) {
if (strncmp(version, "3.3.", 4) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_3_3;
return true;
}

if (strncmp(version, "3.4.", 4) == 0 && is_number(version + 4, length - 4)) {
if (strncmp(version, "3.4.", 4) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
return true;
}

if (strncmp(version, "3.5.", 4) == 0 && is_number(version + 4, length - 4)) {
options->version = PM_OPTIONS_VERSION_CRUBY_3_5;
return true;
}

if (strncmp(version, "4.0.", 4) == 0 && is_number(version + 4, length - 4)) {
if (strncmp(version, "3.5.", 4) == 0 || strncmp(version, "4.0.", 4) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions prism/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ typedef enum {
/** The vendored version of prism in CRuby 3.4.x. */
PM_OPTIONS_VERSION_CRUBY_3_4 = 2,

/** The vendored version of prism in CRuby 3.5.x. */
/** The vendored version of prism in CRuby 4.0.x. */
PM_OPTIONS_VERSION_CRUBY_3_5 = 3,

/** The vendored version of prism in CRuby 4.0.x. */
PM_OPTIONS_VERSION_CRUBY_4_0 = 4,
PM_OPTIONS_VERSION_CRUBY_4_0 = 3,

/** The current version of prism. */
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_0
Expand Down
8 changes: 4 additions & 4 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -10864,11 +10864,11 @@ parser_lex(pm_parser_t *parser) {
}


// If we are parsing as CRuby 3.5 or later and we
// If we are parsing as CRuby 4.0 or later and we
// hit a '&&' or a '||' then we will lex the ignored
// newline.
if (
(parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5) &&
(parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) &&
following && (
(peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '&') ||
(peek_at(parser, following) == '|' && peek_at(parser, following + 1) == '|') ||
Expand Down Expand Up @@ -10915,7 +10915,7 @@ parser_lex(pm_parser_t *parser) {
LEX(PM_TOKEN_AMPERSAND_DOT);
}

if (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5) {
if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) {
// If we hit an && then we are in a logical chain
// and we need to return the logical operator.
if (peek_at(parser, next_content) == '&' && peek_at(parser, next_content + 1) == '&') {
Expand Down Expand Up @@ -19625,7 +19625,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
statements = (pm_node_t *) pm_statements_node_create(parser);

bool allow_command_call;
if (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5) {
if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) {
allow_command_call = accepts_command_call;
} else {
// Allow `def foo = puts "Hello"` but not `private def foo = puts "Hello"`
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
let(:pwd_stub) { nil }

it "returns the current absolute path" do
expect(subject.pwd).to eq(source_root)
expect(subject.pwd).to eq(source_root.to_s)
end
end

Expand Down
10 changes: 5 additions & 5 deletions spec/bundler/cache/gems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@

it "re-caches during install" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
FileUtils.rm_rf cached_gem("myrack-1.0.0")
bundle :install
expect(out).to include("Updating files in vendor/cache")
expect(cached_gem("myrack-1.0.0")).to exist
Expand Down Expand Up @@ -307,7 +307,7 @@
it "doesn't remove gems cached gems that don't match their remote counterparts, but also refuses to install and prints an error" do
setup_main_repo
cached_myrack = cached_gem("myrack-1.0.0")
cached_myrack.rmtree
FileUtils.rm_rf cached_myrack
build_gem "myrack", "1.0.0",
path: cached_myrack.parent,
rubygems_version: "1.3.2"
Expand Down Expand Up @@ -338,7 +338,7 @@

it "raises an error when a cached gem is altered and produces a different checksum than the remote gem" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
FileUtils.rm_rf cached_gem("myrack-1.0.0")
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")

checksums = checksums_section do |c|
Expand All @@ -362,14 +362,14 @@
expect(err).to include("1. remove the gem at #{cached_gem("myrack-1.0.0")}")

expect(cached_gem("myrack-1.0.0")).to exist
cached_gem("myrack-1.0.0").rmtree
FileUtils.rm_rf cached_gem("myrack-1.0.0")
bundle :install
expect(cached_gem("myrack-1.0.0")).to exist
end

it "installs a modified gem with a non-matching checksum when the API implementation does not provide checksums" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
FileUtils.rm_rf cached_gem("myrack-1.0.0")
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")
pristine_system_gems

Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gemfile/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@

it "handles directories in bin/" do
build_lib "foo"
lib_path("foo-1.0").join("foo.gemspec").rmtree
FileUtils.rm_rf lib_path("foo-1.0").join("foo.gemspec")
lib_path("foo-1.0").join("bin/performance").mkpath

install_gemfile <<-G
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gems/compact_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def start

bundle :install, artifice: "compact_index_forbidden"
ensure
home(".gemrc").rmtree
FileUtils.rm_rf home(".gemrc")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gems/dependency_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def start

bundle "install", artifice: "endpoint_marshal_fail"
ensure
home(".gemrc").rmtree
FileUtils.rm_rf home(".gemrc")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/bundler/install/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
bundle :install, dir: dir
expect(out).to include("installed into `./vendor/bundle`")

dir.rmtree
FileUtils.rm_rf dir
end

it "prints a message to let the user know where gems where installed" do
Expand Down Expand Up @@ -181,7 +181,7 @@ def set_bundle_path(type, location)
expect(vendored_gems("extensions")).to be_directory
expect(the_bundle).to include_gems "very_simple_binary 1.0", source: "remote1"

vendored_gems("extensions").rmtree
FileUtils.rm_rf vendored_gems("extensions")

run "require 'very_simple_binary_c'", raise_on_error: false
expect(err).to include("Bundler::GemNotFound")
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/runtime/load_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
begin
expect { Bundler.load }.to raise_error(Bundler::GemfileNotFound)
ensure
bundler_gemfile.rmtree if @remove_bundler_gemfile
FileUtils.rm_rf bundler_gemfile if @remove_bundler_gemfile
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def _build(options = {})
FileUtils.mv bundler_path, options[:path]
end
ensure
build_path.rmtree
FileUtils.rm_rf build_path
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/support/path.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "pathname"
require "pathname" unless defined?(Pathname)
require "rbconfig"

require_relative "env"
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/update/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
gem "foo", :git => "#{lib_path("foo-1.0")}"
G

lib_path("foo-1.0").join(".git").rmtree
FileUtils.rm_rf lib_path("foo-1.0").join(".git")

bundle :update, all: true, raise_on_error: false
expect(err).to include(lib_path("foo-1.0").to_s).
Expand Down
Loading