From 56a60fa7b70c92f6155c0798af2ef0b12dc36adb Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Fri, 20 Nov 2020 16:58:08 +0900 Subject: Move `lib/mruby-core-ext.rb` to `lib/mruby/core_ext.rb` for consistency --- Rakefile | 2 +- lib/mruby-core-ext.rb | 29 ----------------------------- lib/mruby/build.rb | 2 +- lib/mruby/core_ext.rb | 29 +++++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 lib/mruby-core-ext.rb create mode 100644 lib/mruby/core_ext.rb diff --git a/Rakefile b/Rakefile index 8432bb83c..db6cbf91a 100644 --- a/Rakefile +++ b/Rakefile @@ -10,7 +10,7 @@ Rake.verbose(false) if Rake.verbose == Rake::DSL::DEFAULT $LOAD_PATH << File.join(MRUBY_ROOT, "lib") # load build systems -require "mruby-core-ext" +require "mruby/core_ext" require "mruby/build" # load configuration file diff --git a/lib/mruby-core-ext.rb b/lib/mruby-core-ext.rb deleted file mode 100644 index 433f1bb1a..000000000 --- a/lib/mruby-core-ext.rb +++ /dev/null @@ -1,29 +0,0 @@ -autoload :Pathname, 'pathname' - -class Object - class << self - def attr_block(*syms) - syms.flatten.each do |sym| - class_eval "def #{sym}(&block);block.call(@#{sym}) if block_given?;@#{sym};end" - end - end - end -end - -class String - def relative_path_from(dir) - Pathname.new(File.expand_path(self)).relative_path_from(Pathname.new(File.expand_path(dir))).to_s - end - - def relative_path - relative_path_from(Dir.pwd) - end -end - -def _pp(cmd, src, tgt=nil, options={}) - return if Rake.verbose - - width = 5 - template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s" - puts template % [cmd, src, tgt ? "-> #{tgt}" : nil] -end diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 4ae3a6c53..59b5cd583 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -1,4 +1,4 @@ -require "mruby-core-ext" +require "mruby/core_ext" require "mruby/build/load_gems" require "mruby/build/command" diff --git a/lib/mruby/core_ext.rb b/lib/mruby/core_ext.rb new file mode 100644 index 000000000..433f1bb1a --- /dev/null +++ b/lib/mruby/core_ext.rb @@ -0,0 +1,29 @@ +autoload :Pathname, 'pathname' + +class Object + class << self + def attr_block(*syms) + syms.flatten.each do |sym| + class_eval "def #{sym}(&block);block.call(@#{sym}) if block_given?;@#{sym};end" + end + end + end +end + +class String + def relative_path_from(dir) + Pathname.new(File.expand_path(self)).relative_path_from(Pathname.new(File.expand_path(dir))).to_s + end + + def relative_path + relative_path_from(Dir.pwd) + end +end + +def _pp(cmd, src, tgt=nil, options={}) + return if Rake.verbose + + width = 5 + template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s" + puts template % [cmd, src, tgt ? "-> #{tgt}" : nil] +end -- cgit v1.2.3