那么,如何让Textmate使用MacRuby,它是1.9.2的一个分支,而不是1.8.7的默认Ruby值呢?
发布于 2011-02-06 04:30:39
从昨晚开始我就一直在做这个…终于让它起作用了
如何在TextMate上运行MacRuby
由(johnrubythecat*)
*指的是约翰·罗比,“猫”,加里·格兰特在“抓住小偷”中扮演的小偷。
OS上的Ruby目前是1.8.7,但Ruby的最新版本是1.9.2 (快得多),MacRuby (比RubyCocoa好得多)是建立在1.9.2的基础上的
下面是使用ruby轻松构建mac桌面应用程序的说明
安装RVM
1)带git的install rvm
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) http://rvm.beginrescueend.com/1.2) .bash_profile或.bashrc中的源命令(以便可以找到rvm bin ):
source $HOME/.rvm/scripts/rvm
安装MACRUBY
2)使用rvm安装MacRuby
rvm notes # to see available rubies
rvm install macruby-0.8 # for exmpl
3)然后,rvm --default macruby-0.8
(或者至少是rvm use macrmacruby-0.8)
配置文本配对
4)使用此脚本更新Textmate包,以确保您是最新的;请参阅:
--- #!/usr/bin/env bash
mkdir -p /Library/Application\ Support/TextMate/
sudo chown -R $(whoami) /Library/Application\ Support/TextMate
cd /Library/Application\ Support/TextMate/
if [[ -d Bundles/.svn ]] ; then
cd Bundles && svn up
else
if [[ -d Bundles ]] ; then
mv Bundles Bundles.old
fi
svn co http://svn.textmate.org/trunk/Bundles
fi
exit 05)生成TextMate的Ruby包装器
rvm wrapper macruby-0.8 textmate
包装器是在$HOME/.rvm/bin中的;它被称为textmate_ruby
6)转到TextMate首选项中的外壳变量,并将TM_RUBY设置为
/Users/homedirname/.rvm/bin/textmate_ruby
这样就可以了。
运行你的应用
7)这个脚本运行了一个很棒的-opens a Cocoa窗口
framework 'AppKit'
class AppDelegate
def applicationDidFinishLaunching(notification)
voice_type = "com.apple.speech.synthesis.voice.GoodNews"
@voice = NSSpeechSynthesizer.alloc.initWithVoice(voice_type)
end
def windowWillClose(notification)
puts "Bye!"
exit
end
def say_hello(sender)
@voice.startSpeakingString("Hello World!")
puts "Hello World!"
end
end
app = NSApplication.sharedApplication
app.delegate = AppDelegate.new
window = NSWindow.alloc.initWithContentRect([200, 300, 300, 100],
styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask,
backing:NSBackingStoreBuffered,
defer:false)
window.title = 'MacRuby: The Definitive Guide'
window.level = NSModalPanelWindowLevel
window.delegate = app.delegate
button = NSButton.alloc.initWithFrame([80, 10, 120, 80])
button.bezelStyle = 4
button.title = 'Hello World!'
button.target = app.delegate
button.action = 'say_hello:'
window.contentView.addSubview(button)
window.display
window.orderFrontRegardless
app.run这是一个讨论如何将MacRuby与XCode集成的视频。
http://thinkcode.tv/catalog/introduction-macruby/
价格是8.99,但我推荐我自己买的东西。它的MacRuby已经过时了(0.6),但是它展示了在XCode中使用MacRuby的细节,包括设置XIB和建立连接、创建应用程序委托、将Textmate设置为您的外部编辑器。
非常有用。推荐。
发布于 2011-02-06 05:28:52
更简单的答案:
将MacRuby
TM_RUBY的变量设置为/usr/local/bin/macruby.,然后添加
- Alternatively, edit the `PATH` variable to include `/usr/local/bin/` and just set `TM_RUBY` to `macruby`.
如果您已通过RVM安装了MacRuby,则改为:
rvm wrapper macruby-0.8 macruby # creates ~/.rvm/bin/macruby
TM_RUBY to /Users/yourusername/.rvm/bin/macruby (必须是绝对路径)。- Alternatively, edit the `PATH` variable to include `/Users/yourusername/.rvm/bin` and just set `TM_RUBY` to `macruby`.
如果从UI中看不出来,您可以在TextMate中使用TM_RUBY旁边的复选框来启用或禁用它。
https://stackoverflow.com/questions/4909335
复制相似问题