diff options
Diffstat (limited to 'tasks/ruby_ext.rake')
| -rw-r--r-- | tasks/ruby_ext.rake | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/tasks/ruby_ext.rake b/tasks/ruby_ext.rake index 08633b4da..22a8409d4 100644 --- a/tasks/ruby_ext.rake +++ b/tasks/ruby_ext.rake @@ -1,24 +1,58 @@ -def exefile(filename) - if ENV['OS'] == 'Windows_NT' - "#{filename}.exe" - else - filename +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 -def filename(name) - if ENV['OS'] == 'Windows_NT' - '"'+name.gsub('/', '\\')+'"' +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 + + # Compatible with 1.9 on 1.8 + def %(params) + if params.is_a?(Hash) + str = self.clone + params.each do |k, v| + str.gsub!("%{#{k}}", v) + end + str + else + sprintf(self, params) + end end - '"'+name+'"' end -def filenames(names) - [names].flatten.map { |n| filename(n) }.join(' ') +class Symbol + # Compatible with 1.9 on 1.8 + def to_proc + proc { |obj, *args| obj.send(self, *args) } + end end -class String - def relative_path_from(dir) - Pathname.new(self).relative_path_from(Pathname.new(dir)).to_s +$pp_show = true + +if $verbose.nil? + unless Rake.verbose.nil? + if Rake.verbose.class == TrueClass + # verbose message logging + $pp_show = false + else + $pp_show = true + Rake.verbose(false) + end + else + # could not identify rake version + $pp_show = false end +else + $pp_show = false if $verbose +end + +def _pp(msg) + puts msg if $pp_show end |
