如何让 Textmate 使用 MacRuby?

发布于 2024-10-15 19:19:42 字数 71 浏览 6 评论 0原文

那么,如何让 Textmate 使用 MacRuby(1.9.2 的一个分支),而不是 OSX 1.8.7 中默认的 Ruby?

So, how do I get Textmate to use MacRuby, a branch of 1.9.2, instead of the default Ruby in OSX, 1.8.7?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三生一梦 2024-10-22 19:19:42

更简单的答案:

  1. 安装MacRuby

  2. 转到 TextMate->Preferences->Advanced->Shell Variables 并添加一个名为 TM_RUBY 的变量,设置为/usr/local/bin/macruby

    • 或者,编辑 PATH 变量以包含 /usr/local/bin/ 并将 TM_RUBY 设置为 macruby.


如果您已通过 RVM 安装了 MacRuby,则:

  1. 生成稳定的包装器:
    rvm 包装器 macruby-0.8 macruby # 创建 ~/.rvm/bin/macruby

  2. TM_RUBY 设置为 /Users/yourusername/.rvm/bin/macruby(必须是绝对路径)。

    • 或者,编辑 PATH 变量以包含 /Users/yourusername/.rvm/bin 并将 TM_RUBY 设置为 macruby

如果从 UI 中看不出来,您可以使用 TM_RUBY 旁边的复选框来启用或禁用它在 TextMate 中的使用。

Simpler answers:

  1. Install MacRuby

  2. Go to TextMate->Preferences->Advanced->Shell Variables and add a variable named TM_RUBY set to /usr/local/bin/macruby.

    • Alternatively, edit the PATH variable to include /usr/local/bin/ and just set TM_RUBY to macruby.

If you have installed MacRuby through RVM, then instead:

  1. Generate stable wrapper:
    rvm wrapper macruby-0.8 macruby # creates ~/.rvm/bin/macruby

  2. Set TM_RUBY to /Users/yourusername/.rvm/bin/macruby (must be the absolute path).

    • Alternatively, edit the PATH variable to include /Users/yourusername/.rvm/bin and just set TM_RUBY to macruby.

In case it wasn't obvious from the UI, you can use the checkbox next to TM_RUBY to enable or disable its use in TextMate.

友谊不毕业 2024-10-22 19:19:42

从昨晚开始就一直在研究这个......终于让它工作了

如何让 MacRuby 在 TextMate 上运行

作者(johnrubythecat*)

《抓小偷 Ruby》中扮演的小偷

*参考 john robie,“猫”,由 cary grant 在OS X 上的 目前是1.8.7
但 Ruby 的最新版本是 1.9.2(快得多)
MacRuby(比 RubyCocoa 好得多)是基于 1.9.2

所以这里是轻松构建 mac 的说明使用 ruby​​ 的桌面应用程序

安装 RVM

1) 使用 git

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) http://rvm.beginrescueend.com/

1.2) 安装 rvm .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 使用 macrmacruby-0.8

配置 TEXTMATE

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 0

5) 为 TextMate 生成 Ruby 包装器
rvm 包装器 macruby-0.8 textmate

包装器位于 $HOME/.rvm/bin 中;它称为 textmate_ruby

6) 转到 TextMate 首选项中的 shell 变量,并将 TM_RUBY 设置为
/Users/homedirname/.rvm/bin/textmate_ruby

应该可以

运行您的应用程序

7) 这个脚本运行得很好 - 打开一个 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 设置为外部编辑器。

很有用。受到推崇的。

Been working on this since last night…finally got it to work

How to Get MacRuby Running on TextMate

By (johnrubythecat*)

*reference to john robie, "the cat", thief played by cary grant in To Catch A Thief

Ruby on OS X is currently 1.8.7
But latest version of Ruby is 1.9.2 (MUCH faster)
And MacRuby (much better than RubyCocoa) is built on 1.9.2

So here are instructions for easily building mac desktop apps using ruby

INSTALL RVM

1) install rvm with git

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) http://rvm.beginrescueend.com/

1.2) source command in .bash_profile or .bashrc (so rvm bin can be found):
source $HOME/.rvm/scripts/rvm

INSTALL MACRUBY

2) Use rvm to install MacRuby

rvm notes # to see available rubies
rvm install macruby-0.8 # for exmpl

3) then, rvm --default macruby-0.8
(or at least rvm use macrmacruby-0.8)

CONFIGURE TEXTMATE

4) update Textmate bundles with this script, just to make sure you're up to date; see:


--- #!/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 0

5) Generate Ruby wrapper wrapper for TextMate
rvm wrapper macruby-0.8 textmate

wrapper is in $HOME/.rvm/bin; it's called textmate_ruby

6) go to shell variables in TextMate preferences and set TM_RUBY to
/Users/homedirname/.rvm/bin/textmate_ruby

that should do it

RUN YOUR APP

7) this script ran great —opens a Cocoa window

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

And here is a video discussing how to integrate MacRuby with XCode.

http://thinkcode.tv/catalog/introduction-macruby/

It's 8.99, but I am recommending something I purchased myself. It's MacRuby is out of date (0.6), but it shows the nuts and bolts of using MacRuby in XCode, including setting up the XIB and making connections, creating the application delegate, setting up Textmate as your external editor.

Quite useful. Recommended.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文