In math, a unary operation is an operation with a single input. In Ruby, a unary operator is an operator which only takes a single ‘argument’ in the form of a receiver. For example, the – on -5 or ! on !true. In contrast, a binary operator, such as in 2 + 3, deals with two arguments. Here, 2 and 3 (which become one receiver and one argument in a method call to +). Ruby only has a handful of unary
MacRubyとControlTowerのおかげで、Cocoa APIにアクセスできるHTTPサーバが簡単に用意できるようになりました。 曲をかけたり、Macをスリープさせたり、メールを送信したりすることが、別の部屋からiPadのブラウザでできちゃいます!! ためしに Macをスリープさせる機能 システムボリュームを変更する機能 iTunesを起動させる機能 を搭載してみました。 githubにソースをアップしたので、遊んでみたい方は以下のようなコマンドを入力してください。 $ sudo macgem install control_tower $ sudo macgem install system_control $ git clone git://github.com/Watson1978/system_control.git $ cd system_control/example
I was working on a piece of code using MacRuby, Webkit and JavaScript. Calling JS from MacRuby is really straight forward but calling Ruby from JS is a but tricky. There is actually a known bug in MacRuby which was giving me a hard time. The bug should be fixed in 0.8 if everything goes according to plan. In the mean time here is a quick run down: The JS bridge only works when using WebKit so we n
Abstract The Mac OSX operating system, since Mac OSX 10.6.4, has exposed features in the C header “sandbox.h”, and the dynamic library “system.dylib” that make creating a sandbox environment for a given process extremely easy. MacRuby exposes these features through a Ruby class called “Sandbox”. The Sandbox class was introduced in MacRuby 0.7. Profiles The characteristics of a sandbox are deter
Mac OS Xのコア技術を用いたRuby実装「MacRuby」の開発チームは、5カ月ぶりのバージョンアップとなる最新版「MacRuby 0.7」をリリースした。同プロジェクトのWebサイトより入手できる。対応OSはMac OS X 10.6。Cocoa対応、並列実行と性能、Rubyとの互換性などが強化されている。 Cocoa対応については、前バージョンで加わったCocoaレイヤーを強化し、Object C/Cのコードを呼び出すAPIにRubyProcオブジェクトをパスできるようになったほか、サンドボックス機能が強化され、ランタイムのメモリ/ディスク容量が小さくなっている。性能面では、各スレッドのキャッシュを利用するようディスパッチャーを書き直すことで、効率性を改善。MacRubyカーネルやベーシックインタープリタも強化され、全体の安定性が増した。Ruby互換性の面では、今バージョンでは初
After 5 months of development, we are happy to announce the immediate availability of MacRuby 0.7. This release does not bring any significant features but consolidates the existing functionality of MacRuby by improving its Ruby compatibility, concurrency, Cocoa support, and overall stability and performance. You can download it from here. Please note that this package only runs on Snow Leopard (1
MacRuby 0.7のブランチが切られ、リリースを待つのみとなり、またベンチマークを取ってみました。前回の計測から、バージョンアップしたRuby実装のベンチマーク結果を追加しました。追加したものは ruby 1.9.2-p0, MacRuby 0.7, JRuby 1.5.3, Rubinius 1.1.0です。 MacRuby 0.7はSVNリポジトリからブランチを取得、ビルドして計測しました。 $ svn co http://svn.macosforge.org/repository/ruby/MacRuby/branches/0.7/ macruby-0.7 環境 PC: Mac mini CPU: Intel Core 2 Duo 1.83 GHz RAM: 1GB DDR2 SDRAM 667 MHz OS: Mac OS X 10.6.4 使用したRuby ruby 1.9.
MacRuby 0.7からWEBrickがそこそこ動くようになります。まだクリティカルな案件には使えないかもしれませんが、ファイルを配布するときに簡易的なサーバとして使えるかと思います。どうせならBonjourを使って、サーバのアドレスとポート番号を通知してあげれると、勉強会などちょっとした機会に便利に使えるかも。 framework "Foundation" require "webrick" PORT = 8080 SERVER_NAME = "webrick" s = WEBrick::HTTPServer.new( :Port => PORT, :DocumentRoot => File.join(Dir::pwd, ".") ) trap("INT") { s.shutdown } # Bonjour netservice = NSNetService.alloc.initWit
Way back in the announcement for MacRuby 0.5, we cryptically mentioned that we had gotten a web server to run a basic Sinatra app. While that statement was true, the server we had wasn’t even really alpha worthy. At that point, it was more about proof of concept. If you have been watching the subversion repository you might have noticed that a new top-level project appeared about 4 months ago. If
MacRuby 0.7からSandboxという機能が追加されます。Sandboxという名前からわかるように、ネットワークアクセスなどを制限する機能になります。Macが元々もっている機能を利用してSandboxがMacRuby上に実装されています。 使い方は簡単で、あらかじめSandbox.no_network.apply!というように呼び出しておくだけです。Rubyのメソッド、CocoaのAPI、双方に制限がかかります。 framework "Cocoa" require "socket" Sandbox.no_network.apply! begin p Socket.gethostbyaddr("apple.com") rescue => e p e end begin p NSHost.hostWithName("apple.com").address rescue => e p e
Cocoa APIを使用していると、引数にポインタ変数を渡さなければいけないときがあります。多くはNSError* error;のような変数が必要になるケースでしょうか。 Rubyにはポインタ変数を扱うことができるクラスが存在しないため、MacRubyではPointerクラスが追加されています。 // ObjC NSError* error; # MacRuby error = Pointer.new('@') error = Pointer.new(:object) 作成したPointerインスタンスの値はerror[0]と参照することができます。Cocoa APIにもerror[0]を渡します。Cocoa APIにはerrorをそのまま渡せばMacRubyが良きに計らってくれるみたい。参考:Probing Cocoa With MacRuby Probing Cocoa With Ma
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く