From 1868fd453d70009fd4a895b09c236fb8fc653d6c Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Thu, 8 Aug 2019 22:12:25 +0900 Subject: Remove monkey patches for Ruby 1.9 or earlier --- lib/mruby-core-ext.rb | 39 --------------------------------------- 1 file changed, 39 deletions(-) (limited to 'lib/mruby-core-ext.rb') diff --git a/lib/mruby-core-ext.rb b/lib/mruby-core-ext.rb index 08e6f6148..8c985f147 100644 --- a/lib/mruby-core-ext.rb +++ b/lib/mruby-core-ext.rb @@ -16,45 +16,6 @@ class String def relative_path relative_path_from(Dir.pwd) end - - # Compatible with 1.9 on 1.8 - unless (sprintf("%{a}", :a => 1) rescue false) - def %(params) - if params.is_a?(Hash) - str = self.clone - params.each do |k, v| - str.gsub!("%{#{k}}") { v } - end - str - else - if params.is_a?(Array) - sprintf(self, *params) - else - sprintf(self, params) - end - end - end - end -end - -class Symbol - # Compatible with 1.9 on 1.8 - unless method_defined?(:to_proc) - def to_proc - proc { |obj, *args| obj.send(self, *args) } - end - end -end - -module Enumerable - # Compatible with 1.9 on 1.8 - unless method_defined?(:each_with_object) - def each_with_object(memo) - return to_enum :each_with_object, memo unless block_given? - each { |obj| yield obj, memo } - memo - end - end end $pp_show = true -- cgit v1.2.3 From 3110d84ed834cba90d9830ae23e89cd61bcae459 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Sun, 25 Aug 2019 09:48:07 +0900 Subject: Defer several build libraries loading until needed --- Rakefile | 2 -- lib/mruby-core-ext.rb | 2 ++ lib/mruby/build.rb | 4 ++++ lib/mruby/gem.rb | 5 ++--- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/mruby-core-ext.rb') diff --git a/Rakefile b/Rakefile index be42233db..079b1a41b 100644 --- a/Rakefile +++ b/Rakefile @@ -10,8 +10,6 @@ $LOAD_PATH << File.join(MRUBY_ROOT, "lib") # load build systems require "mruby-core-ext" require "mruby/build" -require "mruby/gem" -require "mruby/lockfile" # load configuration file MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb" diff --git a/lib/mruby-core-ext.rb b/lib/mruby-core-ext.rb index 8c985f147..7b78bfa91 100644 --- a/lib/mruby-core-ext.rb +++ b/lib/mruby-core-ext.rb @@ -1,3 +1,5 @@ +autoload :Pathname, 'pathname' + class Object class << self def attr_block(*syms) diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index ecc343360..dfce42bea 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -1,7 +1,11 @@ +require "mruby-core-ext" require "mruby/build/load_gems" require "mruby/build/command" module MRuby + autoload :Gem, "mruby/gem" + autoload :Lockfile, "mruby/lockfile" + class << self def targets @targets ||= {} diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb index 95c1d4bc3..6cb067b91 100644 --- a/lib/mruby/gem.rb +++ b/lib/mruby/gem.rb @@ -1,7 +1,6 @@ -require 'pathname' require 'forwardable' -require 'tsort' -require 'shellwords' +autoload :TSort, 'tsort' +autoload :Shellwords, 'shellwords' module MRuby module Gem -- cgit v1.2.3