[前][次][番号順一覧][スレッド一覧]

ruby-changes:69378

From: David <ko1@a...>
Date: Sun, 24 Oct 2021 08:49:24 +0900 (JST)
Subject: [ruby-changes:69378] d04d6bbc6c (master): [ruby/psych] Prefer `require_relative` for internal requires

https://git.ruby-lang.org/ruby.git/commit/?id=d04d6bbc6c

From d04d6bbc6cf14a4e3ca292095a00c1956e63d9fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 6 Oct 2021 11:51:33 +0200
Subject: [ruby/psych] Prefer `require_relative` for internal requires

https://github.com/ruby/psych/commit/a0f55ee85a
---
 ext/psych/lib/psych.rb                          | 34 ++++++++++++-------------
 ext/psych/lib/psych/class_loader.rb             |  4 +--
 ext/psych/lib/psych/core_ext.rb                 |  2 +-
 ext/psych/lib/psych/handlers/document_stream.rb |  2 +-
 ext/psych/lib/psych/handlers/recorder.rb        |  2 +-
 ext/psych/lib/psych/json/stream.rb              |  4 +--
 ext/psych/lib/psych/json/tree_builder.rb        |  2 +-
 ext/psych/lib/psych/nodes.rb                    | 14 +++++-----
 ext/psych/lib/psych/nodes/node.rb               |  4 +--
 ext/psych/lib/psych/syntax_error.rb             |  2 +-
 ext/psych/lib/psych/tree_builder.rb             |  2 +-
 ext/psych/lib/psych/visitors.rb                 | 12 ++++-----
 ext/psych/lib/psych/visitors/json_tree.rb       |  2 +-
 ext/psych/lib/psych/visitors/to_ruby.rb         |  6 ++---
 ext/psych/lib/psych/visitors/yaml_tree.rb       |  6 ++---
 15 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index ecf3b3927e..383078788f 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -1,8 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L1
 # frozen_string_literal: true
-require 'psych/versions'
+require_relative 'psych/versions'
 case RUBY_ENGINE
 when 'jruby'
-  require 'psych_jars'
+  require_relative 'psych_jars'
   if JRuby::Util.respond_to?(:load_ext)
     JRuby::Util.load_ext('org.jruby.ext.psych.PsychLibrary')
   else
@@ -12,21 +12,21 @@ when 'jruby' https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L12
 else
   require 'psych.so'
 end
-require 'psych/nodes'
-require 'psych/streaming'
-require 'psych/visitors'
-require 'psych/handler'
-require 'psych/tree_builder'
-require 'psych/parser'
-require 'psych/omap'
-require 'psych/set'
-require 'psych/coder'
-require 'psych/core_ext'
-require 'psych/stream'
-require 'psych/json/tree_builder'
-require 'psych/json/stream'
-require 'psych/handlers/document_stream'
-require 'psych/class_loader'
+require_relative 'psych/nodes'
+require_relative 'psych/streaming'
+require_relative 'psych/visitors'
+require_relative 'psych/handler'
+require_relative 'psych/tree_builder'
+require_relative 'psych/parser'
+require_relative 'psych/omap'
+require_relative 'psych/set'
+require_relative 'psych/coder'
+require_relative 'psych/core_ext'
+require_relative 'psych/stream'
+require_relative 'psych/json/tree_builder'
+require_relative 'psych/json/stream'
+require_relative 'psych/handlers/document_stream'
+require_relative 'psych/class_loader'
 
 ###
 # = Overview
diff --git a/ext/psych/lib/psych/class_loader.rb b/ext/psych/lib/psych/class_loader.rb
index 088373cd66..c2e4ea4c93 100644
--- a/ext/psych/lib/psych/class_loader.rb
+++ b/ext/psych/lib/psych/class_loader.rb
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/class_loader.rb#L1
 # frozen_string_literal: true
-require 'psych/omap'
-require 'psych/set'
+require_relative 'omap'
+require_relative 'set'
 
 module Psych
   class ClassLoader # :nodoc:
diff --git a/ext/psych/lib/psych/core_ext.rb b/ext/psych/lib/psych/core_ext.rb
index 81055cc501..0721a133c3 100644
--- a/ext/psych/lib/psych/core_ext.rb
+++ b/ext/psych/lib/psych/core_ext.rb
@@ -15,5 +15,5 @@ class Object https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/core_ext.rb#L15
 end
 
 if defined?(::IRB)
-  require 'psych/y'
+  require_relative 'y'
 end
diff --git a/ext/psych/lib/psych/handlers/document_stream.rb b/ext/psych/lib/psych/handlers/document_stream.rb
index 67da794093..b77115d074 100644
--- a/ext/psych/lib/psych/handlers/document_stream.rb
+++ b/ext/psych/lib/psych/handlers/document_stream.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/handlers/document_stream.rb#L1
 # frozen_string_literal: true
-require 'psych/tree_builder'
+require_relative '../tree_builder'
 
 module Psych
   module Handlers
diff --git a/ext/psych/lib/psych/handlers/recorder.rb b/ext/psych/lib/psych/handlers/recorder.rb
index a8fc7b1144..c98724cb76 100644
--- a/ext/psych/lib/psych/handlers/recorder.rb
+++ b/ext/psych/lib/psych/handlers/recorder.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/handlers/recorder.rb#L1
 # frozen_string_literal: true
-require 'psych/handler'
+require_relative '../handler'
 
 module Psych
   module Handlers
diff --git a/ext/psych/lib/psych/json/stream.rb b/ext/psych/lib/psych/json/stream.rb
index 2ebd3d7a66..24dd4b9baf 100644
--- a/ext/psych/lib/psych/json/stream.rb
+++ b/ext/psych/lib/psych/json/stream.rb
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/json/stream.rb#L1
 # frozen_string_literal: true
-require 'psych/json/ruby_events'
-require 'psych/json/yaml_events'
+require_relative 'ruby_events'
+require_relative 'yaml_events'
 
 module Psych
   module JSON
diff --git a/ext/psych/lib/psych/json/tree_builder.rb b/ext/psych/lib/psych/json/tree_builder.rb
index 5c2ee8ca25..9a45f6b94c 100644
--- a/ext/psych/lib/psych/json/tree_builder.rb
+++ b/ext/psych/lib/psych/json/tree_builder.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/json/tree_builder.rb#L1
 # frozen_string_literal: true
-require 'psych/json/yaml_events'
+require_relative 'yaml_events'
 
 module Psych
   module JSON
diff --git a/ext/psych/lib/psych/nodes.rb b/ext/psych/lib/psych/nodes.rb
index 5842c2e3e5..2fa52e0055 100644
--- a/ext/psych/lib/psych/nodes.rb
+++ b/ext/psych/lib/psych/nodes.rb
@@ -1,11 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/nodes.rb#L1
 # frozen_string_literal: true
-require 'psych/nodes/node'
-require 'psych/nodes/stream'
-require 'psych/nodes/document'
-require 'psych/nodes/sequence'
-require 'psych/nodes/scalar'
-require 'psych/nodes/mapping'
-require 'psych/nodes/alias'
+require_relative 'nodes/node'
+require_relative 'nodes/stream'
+require_relative 'nodes/document'
+require_relative 'nodes/sequence'
+require_relative 'nodes/scalar'
+require_relative 'nodes/mapping'
+require_relative 'nodes/alias'
 
 module Psych
   ###
diff --git a/ext/psych/lib/psych/nodes/node.rb b/ext/psych/lib/psych/nodes/node.rb
index 05cb08dac0..1f841625ca 100644
--- a/ext/psych/lib/psych/nodes/node.rb
+++ b/ext/psych/lib/psych/nodes/node.rb
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/nodes/node.rb#L1
 # frozen_string_literal: true
 require 'stringio'
-require 'psych/class_loader'
-require 'psych/scalar_scanner'
+require_relative '../class_loader'
+require_relative '../scalar_scanner'
 
 module Psych
   module Nodes
diff --git a/ext/psych/lib/psych/syntax_error.rb b/ext/psych/lib/psych/syntax_error.rb
index 1598e6ff36..a4c9c4a376 100644
--- a/ext/psych/lib/psych/syntax_error.rb
+++ b/ext/psych/lib/psych/syntax_error.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/syntax_error.rb#L1
 # frozen_string_literal: true
-require 'psych/exception'
+require_relative 'exception'
 
 module Psych
   class SyntaxError < Psych::Exception
diff --git a/ext/psych/lib/psych/tree_builder.rb b/ext/psych/lib/psych/tree_builder.rb
index 47a1695643..414ca02bf7 100644
--- a/ext/psych/lib/psych/tree_builder.rb
+++ b/ext/psych/lib/psych/tree_builder.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/tree_builder.rb#L1
 # frozen_string_literal: true
-require 'psych/handler'
+require_relative 'handler'
 
 module Psych
   ###
diff --git a/ext/psych/lib/psych/visitors.rb b/ext/psych/lib/psych/visitors.rb
index e2b084daee..508290d862 100644
--- a/ext/psych/lib/psych/visitors.rb
+++ b/ext/psych/lib/psych/visitors.rb
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors.rb#L1
 # frozen_string_literal: true
-require 'psych/visitors/visitor'
-require 'psych/visitors/to_ruby'
-require 'psych/visitors/emitter'
-require 'psych/visitors/yaml_tree'
-require 'psych/visitors/json_tree'
-require 'psych/visitors/depth_first'
+require_relative 'visitors/visitor'
+require_relative 'visitors/to_ruby'
+require_relative 'visitors/emitter'
+require_relative 'visitors/yaml_tree'
+require_relative 'visitors/json_tree'
+require_relative 'visitors/depth_first'
diff --git a/ext/psych/lib/psych/visitors/json_tree.rb b/ext/psych/lib/psych/visitors/json_tree.rb
index 9912cb1362..979fc100bd 100644
--- a/ext/psych/lib/psych/visitors/json_tree.rb
+++ b/ext/psych/lib/psych/visitors/json_tree.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/json_tree.rb#L1
 # frozen_string_literal: true
-require 'psych/json/ruby_events'
+require_relative '../json/ruby_events'
 
 module Psych
   module Visitors
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 4de7f80d33..4c1f561070 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L1
 # frozen_string_literal: true
-require 'psych/scalar_scanner'
-require 'psych/class_loader'
-require 'psych/exception'
+require_relative '../scalar_scanner'
+require_relative '../class_loader'
+require_relative '../exception'
 
 unless defined?(Regexp::NOENCODING)
   Regexp::NOENCODING = 32
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 2eee4d3457..316a3a9496 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/yaml_tree.rb#L1
 # frozen_string_literal: true
-require 'psych/tree_builder'
-requ (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]