summaryrefslogtreecommitdiffhomepage
path: root/tasks/ruby_ext.rake
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-01-20 14:41:50 -0800
committerYukihiro "Matz" Matsumoto <[email protected]>2013-01-20 14:41:50 -0800
commit8e86ff2283d427b5cb2a02607e1aab998cb5090c (patch)
treebd40d166673b2290053f1742660d573d5586a974 /tasks/ruby_ext.rake
parentcc16bd7c0d70b326ddcf8de8a511116dae9fc30d (diff)
parentced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95 (diff)
downloadmruby-8e86ff2283d427b5cb2a02607e1aab998cb5090c.tar.gz
mruby-8e86ff2283d427b5cb2a02607e1aab998cb5090c.zip
Merge pull request #755 from masuidrive/imprive_build_scripts
Improved build scripts and config files
Diffstat (limited to 'tasks/ruby_ext.rake')
-rw-r--r--tasks/ruby_ext.rake43
1 files changed, 27 insertions, 16 deletions
diff --git a/tasks/ruby_ext.rake b/tasks/ruby_ext.rake
index 08633b4da..ebd499063 100644
--- a/tasks/ruby_ext.rake
+++ b/tasks/ruby_ext.rake
@@ -1,24 +1,35 @@
-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(' ')
end
-class String
- def relative_path_from(dir)
- Pathname.new(self).relative_path_from(Pathname.new(dir)).to_s
+class Symbol
+ # Compatible with 1.9 on 1.8
+ def to_proc
+ proc { |obj, *args| obj.send(self, *args) }
end
end