How to get Textmate to use MacRuby?

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

+3
source share
2 answers

Worked on it from last night ... finally got it to work

How to run MacRuby in TextMate

By (johnrubythecat *)

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

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

, ruby ​​

RVM

1) rvm git

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

1.2) .bash_profile .bashrc( bin rvm):
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 script, , ; :


--- #!/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) Ruby TextMate
rvm wrapper macruby-0.8 textmate

$HOME/.rvm/bin; textmate_ruby

6) TextMate TM_RUBY
/Users/homedirname/.rvm/bin/textmate_ruby

7) script - 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), MacRuby XCode, XIB , , Textmate .

. .

+5

:

  • MacRuby

  • TextMate- > Preferences- > Advanced- > Shell Variables TM_RUBY /usr/local/bin/macruby.

    • PATH, /usr/local/bin/, TM_RUBY macruby.

MacRuby RVM, :

  • :
    rvm wrapper macruby-0.8 macruby # ~/.rvm/bin/macruby

  • TM_RUBY /Users/yourusername/.rvm/bin/macruby ( ).

    • PATH, /Users/yourusername/.rvm/bin, TM_RUBY macruby.

, TM_RUBY, TextMate.

+5

Source: https://habr.com/ru/post/1790225/


All Articles