Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news. Monkey-patching is so 2010. We're in the future, and with Github and Bundler there is now rarely a need to monkey-patch Ruby code in your applications. Monkey-patching is the dangerous-yet-frequently-useful technique of re-opening existing classes to change or add to their behavior. For example, if I have always felt that
問題 世の中にはシンタックスハイライトを行うツールが既に多数存在しています。例えば以下のようなものがあります: GNU Source-highlight (コマンドラインツール)SHJS (JavaScriptでの実装; クライアントサイドで動的にハイライトする)SyntaxHighlighter (SHJSと同様) メジャーな言語やフォーマットなら標準でシンタックスハイライトの設定が同梱されていますが、 ニッチな言語やフォーマットだとまずそのような設定は存在しません。 それならば独自に設定を書けばいいのですが、 大抵のツールでは構文の定義方法が特定のパーツに該当する正規表現を並べるだけなので、 言語によっては構文の妥当な記述が不可能な場合もあります。 となると独自に実装せざるを得ません。 例えば Vim の :help ドキュメントを良い感じに Web ブラウザ上で見るためのツール を作
Ruby用拡張ライブラリをCで作る Helloクラス Rubyのソースにしてみればおそろしく簡単な下記のソースを、今回はCで記述し てみることにする。 class Hello def hello print "Hello, Ruby World.\n" end end 完成品のソース(hello_rb.c) #include <stdio.h> #include <ruby.h> VALUE hello(void); Init_Hello(){ VALUE cHello; cHello = rb_define_class("Hello", rb_cObject); rb_define_method(cHello, "hello", hello, 0); } VALUE hello(void){ printf("Hello, Ruby World.\n"); return Qnil; } ソ
What is it? SOCKSify Ruby redirects any TCP connection initiated by a Ruby script through a SOCKS5 proxy. It serves as a small drop-in alternative to tsocks, except that it handles Ruby programs only and doesn't leak DNS queries. How does it work? Modifications to class TCPSocket: Alias initialize as initialize_tcp The new initialize calls the old method to establish a TCP connection to the SOCKS
Pry is a powerful alternative to the standard IRB shell for Ruby. It features syntax highlighting, a flexible plugin architecture, runtime invocation and source and documentation browsing. Quickstart Install Pry: $ gem install pry $ pry Try it out: (Displaying source for FileUtils.rm) pry(main)> cd FileUtils pry(FileUtils):1> show-method rm From: /opt/ruby/lib/ruby/1.9.1/fileutils.rb @ line 556: N
What Is YARD? YARD is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions. Above is a highlight of the some of YARD's notable features. And of course YARD comes with muc
It used to be a jarring experience to setup a new machine for development, but progress has paved the dirt road into a silky smooth autobahn. These are the tools we use today: Homebrew: Remember how painful it used to be to get imagemagick installed? Now it takes about a minute. “brew install imagemagick”. Same story for git and other Linux dependencies. rbenv/ruby-build: We have some apps running
Ruby目次 Rakefileの簡単な書き方 名前空間 - Rakefileが増えてきたら ブロック引数 - D・R・Y! D・R・Y! タスクの動的生成 ありがとう参考先------------------------------------------------------------ Rakeというのはrubyで処理内容を定義できるビルドツール。currentDirectoryのRakefileというタスクを定義したファイルを読み込んで色々タスクを実行してくれます。引数でファイル名を指定できるけど、基本的にはRakefileがデフォルトなのでそれに従った方がいいです。 $ rake タスク名> # 指定のタスクを実行。 $ rake パラメータキー>=値> タスク名> # パラメータ指定ありで、指定のタスクを実行。 $ rake -h # 使い方を表示。 $ rake -T # 定
ruby-talk の 381425 で 「どのメソッドが呼び出されているのか調べる方法を知りたい」 という内容の質問がありました。 私も知らなかったのですが、Method オブジェクトを使えば簡単に知ることができるそうです。 というわけで、メソッドがどこで定義されているのかを調べる方法を書いておきます。 メソッドを定義しているクラスまたはモジュールへの参照を取得する あるメソッドがどのクラス (またはモジュール) で定義されているかを知りたければ、そのメソッドに対応する Method オブジェクトを取得し、Method#owner メソッド を呼び出します。 それだけで、メソッドを定義しているクラス (またはモジュール) への参照を取得できます。 ちなみに、ある名前のメソッドに対応する Method オブジェクトを取得するには、Kernel#method メソッド を使用します。 'あい
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く