Files
mruby-mruby/lib/mruby-core-ext.rb
T
KOBAYASHI Shuji bb98fd78c3 Use Rake.verbose instead of $verbose and $pp_show in build scripts
The incompatibility that the commands of `FileUtils` origin output verbose
by default due to the changes in d8a5163b and 26e6e75b is also fixed.
2019-12-28 17:03:37 +09:00

30 lines
677 B
Ruby

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