|
|
行1: |
行1: |
− | == Ruby とは? ==
| + | #REDIRECT [[Wikipedia:Ruby]] |
− | | + | |
− | スクリプト言語の1つ。([[MacOSX|Mac OS X]] に標準搭載されている。)
| + | |
− | | + | |
− | * プログラミングの入門に薦める人も多い。
| + | |
− | <!--* 旧Mac OS では [[MacRuby]] が利用できます。-->
| + | |
− | * 詳しくは下記をなどを参照して下さい。
| + | |
− | ** [[Wikipedia:Ruby]]
| + | |
− | | + | |
− | == Mac OS X 特有の情報 ==
| + | |
− | | + | |
− | === gcc-4.2 ===
| + | |
− | | + | |
− | Ruby 1.8 および gem install などの際に [[gcc]]-4.2を必要とする(llvm-gcc-4.2ではなく)。
| + | |
− | | + | |
− | *MacOSX 10.7 では、gcc-4.2 を入手しなければならない。(MacOSX 10.6 では、Developer開発一式をインストールすれば、最初から入っている)
| + | |
− | | + | |
− | gem install の例
| + | |
− | $ ls -l `which cc`
| + | |
− | lrwxr-xr-x 1 root wheel 16 5 24 18:38 /usr/bin/cc -> /usr/bin/gcc-4.2
| + | |
− | $ sudo -E gem install hpricot
| + | |
− | Building native extensions. This could take a while...
| + | |
− | Successfully installed hpricot-0.8.6
| + | |
− | 1 gem installed
| + | |
− | $ gem list
| + | |
− | | + | |
− | === バグ ===
| + | |
− | | + | |
− | *Tiger (PPC) のrubyは、適切でないオプションで build されていてmigemoやrails等がうまく動作しないようです。
| + | |
− | **http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/40804
| + | |
− | **http://www.goodpic.com/mt/archives2/2005/09/ruby_on_rails_m_1.html
| + | |
− | | + | |
− | *SocketError発生(MacOSX 10.5.7 で確認)(`initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError) ..)
| + | |
− | **http://kimuraw.txt-nifty.com/d/2009/03/rbp72socket.html
| + | |
− | | + | |
− | === Ruby on Rails ===
| + | |
− | | + | |
− | 従って、Ruby on Rails を Mac OS X Tigerで動作させるためには、
| + | |
− | ruby を別途インストールする必要があります。
| + | |
− | | + | |
− | *http://www.goodpic.com/mt/archives2/2005/09/ruby_on_rails_m_1.html
| + | |
− | *http://weblog.rubyonrails.com/archives/2005/04/30/fixing-ruby-on-os-x-tiger/
| + | |
− | *http://wiki.rubyonrails.com/rails/pages/HowtoInstallOnOSXTiger
| + | |
− | | + | |
− | 開発環境としては、Locomotive が有名です。
| + | |
− | *[[find:Locomotive]]
| + | |
− | | + | |
− | 上記の情報は古い可能性があります。
| + | |
− | 2006-06-08 時点の情報が Apple のサイトに掲載されています。
| + | |
− | *http://developer.apple.com/tools/rubyonrails.html
| + | |
− | | + | |
− | なお、Mac OS X 10.5 (Leopard) には、Ruby on Rails が標準で搭載される予定だそうです。
| + | |
− | *http://journal.mycom.co.jp/news/2006/08/09/341.html
| + | |
− | | + | |
− | === Ruby/Tk ===
| + | |
− | | + | |
− | Mac OS X Tigerで動作するRuby/Tkは、Tcl/Tk Aquaがベースになってるので、ウィジェットの外観はAqua風になります。
| + | |
− | | + | |
− | === [[RubyCocoa]] ===
| + | |
− | | + | |
− | [[RubyCocoa]] は、Cocoa ベースのソフトウェアを Ruby で記述できるようにしたフレームワークです。
| + | |
− | WWDC06 において、Mac OS X 10.5 (Leopard) にバンドルされる予定であることが公表されました。
| + | |
− | | + | |
− | *[[RubyCocoa]]
| + | |
− | **http://rubycocoa.sourceforge.net/
| + | |
− | | + | |
− | 同様のソフトウェアとして、[[Python]] バインディングである [[PyObjC]] や [[Perl]] バインディングである [[CamelBones]] があります。⇒[[Perl]]
| + | |
− | | + | |
− | | + | |
− | === [[MacRuby]] ===
| + | |
− | [http://www.macruby.org/ MacRubyホームサイト]
| + | |
− | | + | |
− | * コンパイルもサポート(macrubycコマンド): MacOSX上のネイティブコード生成(MacRuby 0.5 beta 1 以降)
| + | |
− | | + | |
− | 動作例
| + | |
− | $ macirb --simple-prompt
| + | |
− | >> framework 'AppKit'
| + | |
− | >> voice = NSSpeechSynthesizer.alloc.initWithVoice(nil)
| + | |
− | >> voice.startSpeakingString("Hello, world.")
| + | |
− | | + | |
− | hotcocoaもインストールするには
| + | |
− | $ sudo -E macgem install hotcocoa
| + | |
− | Password:
| + | |
− | Successfully installed hotcocoa-0.6.0
| + | |
− | 1 gem installed
| + | |
− | | + | |
− | | + | |
− | ==== サンプル ====
| + | |
− | *エイリアスファイルを,それと同等のシンボリックリンクへ変更するスクリプト(エイリアスファイルの方は捨てる):
| + | |
− | #!/usr/bin/env macruby
| + | |
− | # コマンドの引数に「エイリアスファイル」を指定
| + | |
− | framework 'Foundation'
| + | |
− | begin
| + | |
− | raise if !File.exists?(file = ARGV[0])
| + | |
− | raise if `GetFileInfo -aA #{file}`.chomp != "1"
| + | |
− | a = NSURL.fileURLWithPath(file)
| + | |
− | b = NSURL.bookmarkDataWithContentsOfURL(a, error:nil)
| + | |
− | options = NSURLBookmarkResolutionWithoutUI | NSURLBookmarkResolutionWithoutMounting
| + | |
− | c = NSURL.URLByResolvingBookmarkData(b, options:options, relativeToURL:nil, bookmarkDataIsStale:nil, error:nil)
| + | |
− | origPath = c.path
| + | |
− | puts "alias file removed: "+ file
| + | |
− | system("rm " + file)
| + | |
− | system("ln -s " + origPath + " " + file)
| + | |
− | system("ls -ld " + file)
| + | |
− | rescue
| + | |
− | end
| + | |
− | | + | |
− | === モジュールのディレクトリ ===
| + | |
− | /Library/Ruby/Site/
| + | |
− | | + | |
− | * MacOSX では site_ruby という名前ではないとのこと.http://d.hatena.ne.jp/keigoi/20081203/1228311997
| + | |
− | | + | |
− | == 数値計算 ==
| + | |
− | *http://rb-gsl.rubyforge.org/
| + | |
− | | + | |
− | == 参考になるサイト ==
| + | |
− | | + | |
− | *[http://www.ruby-lang.org/ja/ Rubyホームページ]
| + | |
− | **[http://www.ruby-lang.org/ja/20020310.html Rubyチュートリアル]
| + | |
− | *[http://jp.rubyist.net/magazine/ Rubyist Magazine]
| + | |
− | **[http://jp.rubyist.net/magazine/?FirstStepRuby Ruby の歩き方]
| + | |
− | **[http://jp.rubyist.net/magazine/?0006-RLR Ruby Library Report 【第 5 回】 数値計算と可視化]
| + | |
− | *[http://dir.yahoo.co.jp/Computers_and_Internet/Programming_and_Development/Programming_Languages/Ruby/ Yahoo! Ruby カテゴリ]
| + | |
− | *[http://homepage1.nifty.com/~tetsu/ruby/ Ruby あれこれ]
| + | |
− | | + | |
− | *[http://www.mnet.ne.jp/~tnomura/algorithm.html Rubyでアルゴリズム]
| + | |
− | | + | |
− | [[Category:ソフトウェア]]
| + | |
− | [[Category:開発]]
| + | |
− | [[Category:プログラミング言語]]
| + | |
− | [[Category:Ruby]]
| + | |