From 7372fefb0d53e15fda98452fddc318bd1750c6c9 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Fri, 17 Apr 2020 14:42:13 +0900 Subject: [PATCH 1/4] Use qualified name for calls to Kernel#load --- bin/rougify | 4 ++-- lib/rouge.rb | 4 ++-- lib/rouge/lexer.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/rougify b/bin/rougify index 1a7cc5be7d..13f2b10848 100755 --- a/bin/rougify +++ b/bin/rougify @@ -3,8 +3,8 @@ require 'pathname' ROOT_DIR = Pathname.new(__FILE__).dirname.parent -load ROOT_DIR.join('lib/rouge.rb') -load ROOT_DIR.join('lib/rouge/cli.rb') +Kernel::load ROOT_DIR.join('lib/rouge.rb') +Kernel::load ROOT_DIR.join('lib/rouge/cli.rb') Signal.trap('PIPE', 'SYSTEM_DEFAULT') if Signal.list.include? 'PIPE' begin diff --git a/lib/rouge.rb b/lib/rouge.rb index ad51242bf8..ace5ae236f 100644 --- a/lib/rouge.rb +++ b/lib/rouge.rb @@ -13,7 +13,7 @@ module Rouge class << self def reload! Object.send :remove_const, :Rouge - load __FILE__ + Kernel::load __FILE__ end # Highlight some text with a given lexer and formatter. @@ -40,7 +40,7 @@ def highlight(text, lexer, formatter, &b) # # @api private def load_file(path) - load File.join(LIB_DIR, "rouge/#{path}.rb") + Kernel::load File.join(LIB_DIR, "rouge/#{path}.rb") end # Load the lexers in the `lib/rouge/lexers` directory. diff --git a/lib/rouge/lexer.rb b/lib/rouge/lexer.rb index 8bcc17bf5e..c18cc408f7 100644 --- a/lib/rouge/lexer.rb +++ b/lib/rouge/lexer.rb @@ -511,7 +511,7 @@ module Lexers def self.load_lexer(relpath) return if @_loaded_lexers.key?(relpath) @_loaded_lexers[relpath] = true - load File.join(BASE_DIR, relpath) + Kernel::load File.join(BASE_DIR, relpath) end end end From 75766065bfa4aee63d5c0e56193ef9a1eef830d2 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sat, 18 Apr 2020 09:14:43 +0900 Subject: [PATCH 2/4] Use instance version of Object#send --- lib/rouge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouge.rb b/lib/rouge.rb index ace5ae236f..6f43a16ecb 100644 --- a/lib/rouge.rb +++ b/lib/rouge.rb @@ -12,7 +12,7 @@ module Rouge class << self def reload! - Object.send :remove_const, :Rouge + Object::send :remove_const, :Rouge Kernel::load __FILE__ end From 3dfcfaf4602b98d0cb7b6dd6c8bda663b5153d58 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sat, 18 Apr 2020 09:15:14 +0900 Subject: [PATCH 3/4] Use Rouge.reload! in visual testing app --- spec/visual/app.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/visual/app.rb b/spec/visual/app.rb index 7fd3cab313..a531b99891 100644 --- a/spec/visual/app.rb +++ b/spec/visual/app.rb @@ -18,8 +18,7 @@ class VisualTestApp < Sinatra::Application DEMOS = ROOT.join('lib/rouge/demos') def reload_source! - Object.send :remove_const, :Rouge - load ROUGE_LIB + Rouge.reload! end def query_string From fb3b5f5cef03b211123eb0099641b89ddbcc3c17 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Mon, 20 Apr 2020 11:50:08 +0900 Subject: [PATCH 4/4] Namespace load method calls in lexers --- lib/rouge/lexers/apache.rb | 2 +- lib/rouge/lexers/gherkin.rb | 2 +- lib/rouge/lexers/isbl.rb | 2 +- lib/rouge/lexers/lasso.rb | 2 +- lib/rouge/lexers/lua.rb | 2 +- lib/rouge/lexers/mathematica.rb | 2 +- lib/rouge/lexers/matlab.rb | 2 +- lib/rouge/lexers/php.rb | 2 +- lib/rouge/lexers/sqf.rb | 2 +- lib/rouge/lexers/viml.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/rouge/lexers/apache.rb b/lib/rouge/lexers/apache.rb index aba506f5a0..a9de03c585 100644 --- a/lib/rouge/lexers/apache.rb +++ b/lib/rouge/lexers/apache.rb @@ -13,7 +13,7 @@ class Apache < RegexLexer # self-modifying method that loads the keywords file def self.keywords - load File.join(Lexers::BASE_DIR, 'apache/keywords.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb') keywords end diff --git a/lib/rouge/lexers/gherkin.rb b/lib/rouge/lexers/gherkin.rb index 81605527b5..0b655b093d 100644 --- a/lib/rouge/lexers/gherkin.rb +++ b/lib/rouge/lexers/gherkin.rb @@ -19,7 +19,7 @@ def self.detect?(text) # self-modifying method that loads the keywords file def self.keywords - load File.join(Lexers::BASE_DIR, 'gherkin/keywords.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'gherkin/keywords.rb') keywords end diff --git a/lib/rouge/lexers/isbl.rb b/lib/rouge/lexers/isbl.rb index 216f395678..5c57d6d5ea 100644 --- a/lib/rouge/lexers/isbl.rb +++ b/lib/rouge/lexers/isbl.rb @@ -10,7 +10,7 @@ class ISBL < RegexLexer filenames '*.isbl' def self.builtins - load File.join(Lexers::BASE_DIR, 'isbl/builtins.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'isbl/builtins.rb') self.builtins end diff --git a/lib/rouge/lexers/lasso.rb b/lib/rouge/lexers/lasso.rb index 0f9f2d9676..b7c537c65e 100644 --- a/lib/rouge/lexers/lasso.rb +++ b/lib/rouge/lexers/lasso.rb @@ -36,7 +36,7 @@ def start_inline? # self-modifying method that loads the keywords file def self.keywords - load File.join(Lexers::BASE_DIR, 'lasso/keywords.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'lasso/keywords.rb') keywords end diff --git a/lib/rouge/lexers/lua.rb b/lib/rouge/lexers/lua.rb index 96541f8689..38d8955418 100644 --- a/lib/rouge/lexers/lua.rb +++ b/lib/rouge/lexers/lua.rb @@ -25,7 +25,7 @@ def self.detect?(text) end def self.builtins - load File.join(Lexers::BASE_DIR, 'lua/builtins.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'lua/builtins.rb') self.builtins end diff --git a/lib/rouge/lexers/mathematica.rb b/lib/rouge/lexers/mathematica.rb index 305921c65a..cb59c22205 100644 --- a/lib/rouge/lexers/mathematica.rb +++ b/lib/rouge/lexers/mathematica.rb @@ -56,7 +56,7 @@ def self.keywords # The list of built-in symbols comes from a wolfram server and is created automatically by rake def self.builtins - load File.join(Lexers::BASE_DIR, 'mathematica/builtins.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'mathematica/builtins.rb') self.builtins end diff --git a/lib/rouge/lexers/matlab.rb b/lib/rouge/lexers/matlab.rb index 46d9930126..c63458517b 100644 --- a/lib/rouge/lexers/matlab.rb +++ b/lib/rouge/lexers/matlab.rb @@ -20,7 +20,7 @@ def self.keywords # self-modifying method that loads the builtins file def self.builtins - load File.join(Lexers::BASE_DIR, 'matlab/builtins.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'matlab/builtins.rb') builtins end diff --git a/lib/rouge/lexers/php.rb b/lib/rouge/lexers/php.rb index 2c3d344dea..4ce17f6afa 100644 --- a/lib/rouge/lexers/php.rb +++ b/lib/rouge/lexers/php.rb @@ -29,7 +29,7 @@ def initialize(*) end def self.builtins - load File.join(Lexers::BASE_DIR, 'php/builtins.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'php/builtins.rb') self.builtins end diff --git a/lib/rouge/lexers/sqf.rb b/lib/rouge/lexers/sqf.rb index ef0294e384..417578c559 100644 --- a/lib/rouge/lexers/sqf.rb +++ b/lib/rouge/lexers/sqf.rb @@ -55,7 +55,7 @@ def self.diag_commands end def self.commands - load File.join(Lexers::BASE_DIR, "sqf/commands.rb") + Kernel::load File.join(Lexers::BASE_DIR, "sqf/commands.rb") @commands = self.commands end diff --git a/lib/rouge/lexers/viml.rb b/lib/rouge/lexers/viml.rb index ccab889676..161ce62646 100644 --- a/lib/rouge/lexers/viml.rb +++ b/lib/rouge/lexers/viml.rb @@ -14,7 +14,7 @@ class VimL < RegexLexer mimetypes 'text/x-vim' def self.keywords - load File.join(Lexers::BASE_DIR, 'viml/keywords.rb') + Kernel::load File.join(Lexers::BASE_DIR, 'viml/keywords.rb') self.keywords end