summaryrefslogtreecommitdiffhomepage
path: root/tasks/ruby_ext.rake
diff options
context:
space:
mode:
authorYuichiro MASUI <[email protected]>2013-01-20 22:48:42 +0900
committerYuichiro MASUI <[email protected]>2013-01-20 22:48:42 +0900
commitced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95 (patch)
treed49c0d0f0b6139ad4c79c3e4b417d65941e97a4f /tasks/ruby_ext.rake
parent583983385b81c21f82704b116eab52d606a609f4 (diff)
downloadmruby-ced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95.tar.gz
mruby-ced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95.zip
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