Remove and stop syncing IRB documentation (#12416)
Follow-up to #12325 Since we're not generating IRB documentation, we don't need to sync its `doc/` folder and keep the previous content.
This commit is contained in:
parent
ba82399558
commit
f1096c6ad4
Notes:
git
2025-01-02 14:32:47 +00:00
Merged-By: tompng <tomoyapenguin@gmail.com>
@ -1,189 +0,0 @@
|
|||||||
## Indexes
|
|
||||||
|
|
||||||
### Index of Command-Line Options
|
|
||||||
|
|
||||||
These are the \IRB command-line options, with links to explanatory text:
|
|
||||||
|
|
||||||
- `-d`: Set `$DEBUG` and {$VERBOSE}[rdoc-ref:IRB@Verbosity]
|
|
||||||
to `true`.
|
|
||||||
- `-E _ex_[:_in_]`: Set initial external (ex) and internal (in)
|
|
||||||
{encodings}[rdoc-ref:IRB@Encodings] (same as `ruby -E`).
|
|
||||||
- `-f`: Don't initialize from {configuration file}[rdoc-ref:IRB@Configuration+File].
|
|
||||||
- `-I _dirpath_`: Specify {$LOAD_PATH directory}[rdoc-ref:IRB@Load+Modules]
|
|
||||||
(same as `ruby -I`).
|
|
||||||
- `-r _load-module_`: Require {load-module}[rdoc-ref:IRB@Load+Modules]
|
|
||||||
(same as `ruby -r`).
|
|
||||||
- `-U`: Set external and internal {encodings}[rdoc-ref:IRB@Encodings] to UTF-8.
|
|
||||||
- `-w`: Suppress {warnings}[rdoc-ref:IRB@Warnings] (same as `ruby -w`).
|
|
||||||
- `-W[_level_]`: Set {warning level}[rdoc-ref:IRB@Warnings];
|
|
||||||
0=silence, 1=medium, 2=verbose (same as `ruby -W`).
|
|
||||||
- `--autocomplete`: Use {auto-completion}[rdoc-ref:IRB@Automatic+Completion].
|
|
||||||
- `--back-trace-limit _n_`: Set a {backtrace limit}[rdoc-ref:IRB@Tracer];
|
|
||||||
display at most the top `n` and bottom `n` entries.
|
|
||||||
- `--colorize`: Use {color-highlighting}[rdoc-ref:IRB@Color+Highlighting]
|
|
||||||
for input and output.
|
|
||||||
- `--context-mode _n_`: Select method to create Binding object
|
|
||||||
for new {workspace}[rdoc-ref:IRB@Commands]; `n` in range `0..4`.
|
|
||||||
- `--echo`: Print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
return values.
|
|
||||||
- `--extra-doc-dir _dirpath_`:
|
|
||||||
Add a {documentation directory}[rdoc-ref:IRB@RI+Documentation+Directories]
|
|
||||||
for the documentation dialog.
|
|
||||||
- `--inf-ruby-mode`: Set prompt mode to {:INF_RUBY}[rdoc-ref:IRB@Pre-Defined+Prompts]
|
|
||||||
(appropriate for `inf-ruby-mode` on Emacs);
|
|
||||||
suppresses --multiline and --singleline.
|
|
||||||
- `--inspect`: Use method `inspect` for printing ({echoing}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
return values.
|
|
||||||
- `--multiline`: Use the multiline editor as the {input method}[rdoc-ref:IRB@Input+Method].
|
|
||||||
- `--noautocomplete`: Don't use {auto-completion}[rdoc-ref:IRB@Automatic+Completion].
|
|
||||||
- `--nocolorize`: Don't use {color-highlighting}[rdoc-ref:IRB@Color+Highlighting]
|
|
||||||
for input and output.
|
|
||||||
- `--noecho`: Don't print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
return values.
|
|
||||||
- `--noecho-on-assignment`: Don't print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
result on assignment.
|
|
||||||
- `--noinspect`: Don't se method `inspect` for printing ({echoing}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
return values.
|
|
||||||
- `--nomultiline`: Don't use the multiline editor as the {input method}[rdoc-ref:IRB@Input+Method].
|
|
||||||
- `--noprompt`: Don't print {prompts}[rdoc-ref:IRB@Prompt+and+Return+Formats].
|
|
||||||
- `--noscript`: Treat the first command-line argument as a normal
|
|
||||||
{command-line argument}[rdoc-ref:IRB@Initialization+Script],
|
|
||||||
and include it in `ARGV`.
|
|
||||||
- `--nosingleline`: Don't use the singleline editor as the {input method}[rdoc-ref:IRB@Input+Method].
|
|
||||||
- `--noverbose`: Don't print {verbose}[rdoc-ref:IRB@Verbosity] details.
|
|
||||||
- `--prompt _mode_`, `--prompt-mode _mode_`:
|
|
||||||
Set {prompt and return formats}[rdoc-ref:IRB@Prompt+and+Return+Formats];
|
|
||||||
`mode` may be a {pre-defined prompt}[rdoc-ref:IRB@Pre-Defined+Prompts]
|
|
||||||
or the name of a {custom prompt}[rdoc-ref:IRB@Custom+Prompts].
|
|
||||||
- `--script`: Treat the first command-line argument as the path to an
|
|
||||||
{initialization script}[rdoc-ref:IRB@Initialization+Script],
|
|
||||||
and omit it from `ARGV`.
|
|
||||||
- `--simple-prompt`, `--sample-book-mode`:
|
|
||||||
Set prompt mode to {:SIMPLE}[rdoc-ref:IRB@Pre-Defined+Prompts].
|
|
||||||
- `--singleline`: Use the singleline editor as the {input method}[rdoc-ref:IRB@Input+Method].
|
|
||||||
- `--tracer`: Use {Tracer}[rdoc-ref:IRB@Tracer] to print a stack trace for each input command.
|
|
||||||
- `--truncate-echo-on-assignment`: Print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
truncated result on assignment.
|
|
||||||
- `--verbose`Print {verbose}[rdoc-ref:IRB@Verbosity] details.
|
|
||||||
- `-v`, `--version`: Print the {IRB version}[rdoc-ref:IRB@Version].
|
|
||||||
- `-h`, `--help`: Print the {IRB help text}[rdoc-ref:IRB@Help].
|
|
||||||
- `--`: Separate options from {arguments}[rdoc-ref:IRB@Command-Line+Arguments]
|
|
||||||
on the command-line.
|
|
||||||
|
|
||||||
### Index of \IRB.conf Entries
|
|
||||||
|
|
||||||
These are the keys for hash \IRB.conf entries, with links to explanatory text;
|
|
||||||
for each entry that is pre-defined, the initial value is given:
|
|
||||||
|
|
||||||
- `:AP_NAME`: \IRB {application name}[rdoc-ref:IRB@Application+Name];
|
|
||||||
initial value: `'irb'`.
|
|
||||||
- `:AT_EXIT`: Array of hooks to call
|
|
||||||
{at exit}[rdoc-ref:IRB@IRB];
|
|
||||||
initial value: `[]`.
|
|
||||||
- `:AUTO_INDENT`: Whether {automatic indentation}[rdoc-ref:IRB@Automatic+Indentation]
|
|
||||||
is enabled; initial value: `true`.
|
|
||||||
- `:BACK_TRACE_LIMIT`: Sets the {back trace limit}[rdoc-ref:IRB@Tracer];
|
|
||||||
initial value: `16`.
|
|
||||||
- `:COMMAND_ALIASES`: Defines input {command aliases}[rdoc-ref:IRB@Command+Aliases];
|
|
||||||
initial value:
|
|
||||||
|
|
||||||
{
|
|
||||||
"$": :show_source,
|
|
||||||
"@": :whereami,
|
|
||||||
}
|
|
||||||
|
|
||||||
- `:CONTEXT_MODE`: Sets the {context mode}[rdoc-ref:IRB@Context+Mode],
|
|
||||||
the type of binding to be used when evaluating statements;
|
|
||||||
initial value: `4`.
|
|
||||||
- `:ECHO`: Whether to print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
return values;
|
|
||||||
initial value: `nil`, which would set `conf.echo` to `true`.
|
|
||||||
- `:ECHO_ON_ASSIGNMENT`: Whether to print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
|
|
||||||
return values on assignment;
|
|
||||||
initial value: `nil`, which would set `conf.echo_on_assignment` to `:truncate`.
|
|
||||||
- `:EVAL_HISTORY`: How much {evaluation history}[rdoc-ref:IRB@Evaluation+History]
|
|
||||||
is to be stored; initial value: `nil`.
|
|
||||||
- `:EXTRA_DOC_DIRS`: \Array of
|
|
||||||
{RI documentation directories}[rdoc-ref:IRB@RI+Documentation+Directories]
|
|
||||||
to be parsed for the documentation dialog;
|
|
||||||
initial value: `[]`.
|
|
||||||
- `:IGNORE_EOF`: Whether to ignore {end-of-file}[rdoc-ref:IRB@End-of-File];
|
|
||||||
initial value: `false`.
|
|
||||||
- `:IGNORE_SIGINT`: Whether to ignore {SIGINT}[rdoc-ref:IRB@SIGINT];
|
|
||||||
initial value: `true`.
|
|
||||||
- `:INSPECT_MODE`: Whether to use method `inspect` for printing
|
|
||||||
({echoing}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29]) return values;
|
|
||||||
initial value: `true`.
|
|
||||||
- `:IRB_LIB_PATH`: The path to the {IRB library directory}[rdoc-ref:IRB@IRB+Library+Directory]; initial value:
|
|
||||||
|
|
||||||
- `"<i>RUBY_DIR</i>/lib/ruby/gems/<i>RUBY_VER_NUM</i>/gems/irb-<i>IRB_VER_NUM</i>/lib/irb"`,
|
|
||||||
|
|
||||||
where:
|
|
||||||
|
|
||||||
- <i>RUBY_DIR</i> is the Ruby installation dirpath.
|
|
||||||
- <i>RUBY_VER_NUM</i> is the Ruby version number.
|
|
||||||
- <i>IRB_VER_NUM</i> is the \IRB version number.
|
|
||||||
|
|
||||||
- `:IRB_NAME`: {IRB name}[rdoc-ref:IRB@IRB+Name];
|
|
||||||
initial value: `'irb'`.
|
|
||||||
- `:IRB_RC`: {Configuration monitor}[rdoc-ref:IRB@Configuration+Monitor];
|
|
||||||
initial value: `nil`.
|
|
||||||
- `:LC_MESSAGES`: {Locale}[rdoc-ref:IRB@Locale];
|
|
||||||
initial value: IRB::Locale object.
|
|
||||||
- `:LOAD_MODULES`: deprecated.
|
|
||||||
- `:MAIN_CONTEXT`: The {context}[rdoc-ref:IRB@Session+Context] for the main \IRB session;
|
|
||||||
initial value: IRB::Context object.
|
|
||||||
- `:MEASURE`: Whether to
|
|
||||||
{measure performance}[rdoc-ref:IRB@Performance+Measurement];
|
|
||||||
initial value: `false`.
|
|
||||||
- `:MEASURE_CALLBACKS`: Callback methods for
|
|
||||||
{performance measurement}[rdoc-ref:IRB@Performance+Measurement];
|
|
||||||
initial value: `[]`.
|
|
||||||
- `:MEASURE_PROC`: Procs for
|
|
||||||
{performance measurement}[rdoc-ref:IRB@Performance+Measurement];
|
|
||||||
initial value:
|
|
||||||
|
|
||||||
{
|
|
||||||
:TIME=>#<Proc:0x0000556e271c6598 /var/lib/gems/3.0.0/gems/irb-1.8.3/lib/irb/init.rb:106>,
|
|
||||||
:STACKPROF=>#<Proc:0x0000556e271c6548 /var/lib/gems/3.0.0/gems/irb-1.8.3/lib/irb/init.rb:116>
|
|
||||||
}
|
|
||||||
|
|
||||||
- `:PROMPT`: \Hash of {defined prompts}[rdoc-ref:IRB@Prompt+and+Return+Formats];
|
|
||||||
initial value:
|
|
||||||
|
|
||||||
{
|
|
||||||
:NULL=>{:PROMPT_I=>nil, :PROMPT_S=>nil, :PROMPT_C=>nil, :RETURN=>"%s\n"},
|
|
||||||
:DEFAULT=>{:PROMPT_I=>"%N(%m):%03n> ", :PROMPT_S=>"%N(%m):%03n%l ", :PROMPT_C=>"%N(%m):%03n* ", :RETURN=>"=> %s\n"},
|
|
||||||
:CLASSIC=>{:PROMPT_I=>"%N(%m):%03n:%i> ", :PROMPT_S=>"%N(%m):%03n:%i%l ", :PROMPT_C=>"%N(%m):%03n:%i* ", :RETURN=>"%s\n"},
|
|
||||||
:SIMPLE=>{:PROMPT_I=>">> ", :PROMPT_S=>"%l> ", :PROMPT_C=>"?> ", :RETURN=>"=> %s\n"},
|
|
||||||
:INF_RUBY=>{:PROMPT_I=>"%N(%m):%03n> ", :PROMPT_S=>nil, :PROMPT_C=>nil, :RETURN=>"%s\n", :AUTO_INDENT=>true},
|
|
||||||
:XMP=>{:PROMPT_I=>nil, :PROMPT_S=>nil, :PROMPT_C=>nil, :RETURN=>" ==>%s\n"}
|
|
||||||
}
|
|
||||||
|
|
||||||
- `:PROMPT_MODE`: Name of {current prompt}[rdoc-ref:IRB@Prompt+and+Return+Formats];
|
|
||||||
initial value: `:DEFAULT`.
|
|
||||||
- `:RC`: Whether a {configuration file}[rdoc-ref:IRB@Configuration+File]
|
|
||||||
was found and interpreted;
|
|
||||||
initial value: `true` if a configuration file was found, `false` otherwise.
|
|
||||||
- `:SAVE_HISTORY`: Number of commands to save in
|
|
||||||
{input command history}[rdoc-ref:IRB@Input+Command+History];
|
|
||||||
initial value: `1000`.
|
|
||||||
- `:SINGLE_IRB`: Whether command-line option `--single-irb` was given;
|
|
||||||
initial value: `true` if the option was given, `false` otherwise.
|
|
||||||
See {Single-IRB Mode}[rdoc-ref:IRB@Single-IRB+Mode].
|
|
||||||
- `:USE_AUTOCOMPLETE`: Whether to use
|
|
||||||
{automatic completion}[rdoc-ref:IRB@Automatic+Completion];
|
|
||||||
initial value: `true`.
|
|
||||||
- `:USE_COLORIZE`: Whether to use
|
|
||||||
{color highlighting}[rdoc-ref:IRB@Color+Highlighting];
|
|
||||||
initial value: `true`.
|
|
||||||
- `:USE_LOADER`: Whether to use the
|
|
||||||
{IRB loader}[rdoc-ref:IRB@IRB+Loader] for `require` and `load`;
|
|
||||||
initial value: `false`.
|
|
||||||
- `:USE_TRACER`: Whether to use the
|
|
||||||
{IRB tracer}[rdoc-ref:IRB@Tracer];
|
|
||||||
initial value: `false`.
|
|
||||||
- `:VERBOSE`: Whether to print {verbose output}[rdoc-ref:IRB@Verbosity];
|
|
||||||
initial value: `nil`.
|
|
||||||
- `:__MAIN__`: The main \IRB object;
|
|
||||||
initial value: `main`.
|
|
@ -1,184 +0,0 @@
|
|||||||
irb関連おまけコマンドとライブラリ
|
|
||||||
$Release Version: 0.7.1 $
|
|
||||||
$Revision$
|
|
||||||
by Keiju ISHITSUKA(Nihon Rational Co.,Ltd.)
|
|
||||||
|
|
||||||
=begin
|
|
||||||
|
|
||||||
:コマンド:
|
|
||||||
* rtags -- ruby tags command
|
|
||||||
|
|
||||||
:関数ライブラリ:
|
|
||||||
* xmp -- irb version of gotoken xmp-function
|
|
||||||
|
|
||||||
:クラスライブラリ:
|
|
||||||
* frame.rb -- frame tracer
|
|
||||||
* completion.rb -- irb completor
|
|
||||||
|
|
||||||
= rtags
|
|
||||||
|
|
||||||
rtagsはemacs及びvi用の, TAGファイルをつくるコマンドです.
|
|
||||||
|
|
||||||
== 使い方
|
|
||||||
|
|
||||||
rtags [-vi] file....
|
|
||||||
|
|
||||||
カレントディレクトリにemacs用のTAGSファイルができます. -viオプションを
|
|
||||||
つけた時にはvi用のtagsファイルを作成します.
|
|
||||||
|
|
||||||
emacsの場合, 通常のetags.elがそのまま使えます. 検索可能なのは,
|
|
||||||
|
|
||||||
* クラス
|
|
||||||
* メソッド
|
|
||||||
* 特異メソッド
|
|
||||||
* alias
|
|
||||||
* attrで宣言されたアクセサ(パラメータがシンボルか文字列リテラルに限る)
|
|
||||||
* attr_XXXで宣言されたアクセサ(パラメータがシンボルか文字列リテラルに限る)
|
|
||||||
|
|
||||||
です.
|
|
||||||
|
|
||||||
Cなどで使っているのと違うのは, コンプリーションに関する部分で,
|
|
||||||
|
|
||||||
関数名は,
|
|
||||||
|
|
||||||
関数名(
|
|
||||||
|
|
||||||
クラスは,
|
|
||||||
|
|
||||||
::クラス名::....::クラス名
|
|
||||||
|
|
||||||
メソッドは,
|
|
||||||
|
|
||||||
::クラス名::....::クラス名#メソッド名
|
|
||||||
|
|
||||||
特異メソッド(クラスメソッド)は
|
|
||||||
|
|
||||||
::クラス名::....::クラス名.メソッド名
|
|
||||||
|
|
||||||
でコンプリーションを行なうところです.
|
|
||||||
|
|
||||||
= xmp.rb
|
|
||||||
|
|
||||||
ごとけんxmpの上位互換バージョンです. ただ, 非常に重いのでごとけんxmpで
|
|
||||||
は対応できない時に, 使用すると良いでしょう.
|
|
||||||
|
|
||||||
== 使い方
|
|
||||||
|
|
||||||
=== 関数として使う.
|
|
||||||
|
|
||||||
require "irb/xmp"
|
|
||||||
xmp <<END
|
|
||||||
foo = 1
|
|
||||||
foo
|
|
||||||
END
|
|
||||||
---
|
|
||||||
foo = 1
|
|
||||||
==>1
|
|
||||||
foo
|
|
||||||
==>1
|
|
||||||
|
|
||||||
=== XMPインスタンスを用いる.
|
|
||||||
|
|
||||||
この場合は, XMPがコンテキスト情報を持つので, 変数の値などを保持してい
|
|
||||||
ます.
|
|
||||||
|
|
||||||
require "irb/xmp"
|
|
||||||
xmp = XMP.new
|
|
||||||
xmp.puts <<END
|
|
||||||
foo = 1
|
|
||||||
foo
|
|
||||||
END
|
|
||||||
xmp.puts <<END
|
|
||||||
foo
|
|
||||||
END
|
|
||||||
===
|
|
||||||
foo = 1
|
|
||||||
==>1
|
|
||||||
foo
|
|
||||||
==>1
|
|
||||||
foo
|
|
||||||
==>1
|
|
||||||
|
|
||||||
== コンテキストに関して
|
|
||||||
|
|
||||||
XMPメソッド群のコンテキストは, 呼び出す前のコンテキストで評価されます.
|
|
||||||
明示的にコンテキストを指定するとそのコンテキストで評価します.
|
|
||||||
|
|
||||||
例:
|
|
||||||
|
|
||||||
xmp "foo", an_binding
|
|
||||||
|
|
||||||
:注:
|
|
||||||
マルチスレッドには対応していません.
|
|
||||||
|
|
||||||
= frame.rb
|
|
||||||
現在実行中のフレーム情報を取り扱うためのクラスです.
|
|
||||||
|
|
||||||
* IRB::Frame.top(n = 0)
|
|
||||||
上からn番目のコンテキストを取り出します. nは0が最上位になります.
|
|
||||||
* IRB::Frame.bottom(n = 0)
|
|
||||||
下からn番目のコンテキストを取り出します. nは0が最下位になります.
|
|
||||||
* IRB::Frame.sender
|
|
||||||
センダになっているオブジェクトを取り出します. センダとは, そのメソッ
|
|
||||||
ドを呼び出した側のselfのことです.
|
|
||||||
|
|
||||||
:注:
|
|
||||||
set_trace_funcを用いてRubyの実行をトレースしています. マルチスレッドに
|
|
||||||
は対応していません.
|
|
||||||
|
|
||||||
= completion.rb
|
|
||||||
irbのcompletion機能を提供するものです.
|
|
||||||
|
|
||||||
== 使い方
|
|
||||||
|
|
||||||
% irb -r irb/completion
|
|
||||||
|
|
||||||
とするか, ~/.irbrc 中に
|
|
||||||
|
|
||||||
require "irb/completion"
|
|
||||||
|
|
||||||
を入れてください. irb実行中に require "irb/completion" してもよいです.
|
|
||||||
|
|
||||||
irb実行中に (TAB) を押すとコンプレーションします.
|
|
||||||
|
|
||||||
トップレベルで(TAB)を押すとすべての構文要素, クラス, メソッドの候補がで
|
|
||||||
ます. 候補が唯一ならば完全に補完します.
|
|
||||||
|
|
||||||
irb(main):001:0> in
|
|
||||||
in inspect instance_eval
|
|
||||||
include install_alias_method instance_of?
|
|
||||||
initialize install_aliases instance_variables
|
|
||||||
irb(main):001:0> inspect
|
|
||||||
"main"
|
|
||||||
irb(main):002:0> foo = Object.new
|
|
||||||
#<Object:0x4027146c>
|
|
||||||
|
|
||||||
((|変数名.|))の後に(TAB)を押すと, そのオブジェクトのメソッド一覧がでま
|
|
||||||
す.
|
|
||||||
|
|
||||||
irb(main):003:0> foo.
|
|
||||||
foo.== foo.frozen? foo.protected_methods
|
|
||||||
foo.=== foo.hash foo.public_methods
|
|
||||||
foo.=~ foo.id foo.respond_to?
|
|
||||||
foo.__id__ foo.inspect foo.send
|
|
||||||
foo.__send__ foo.instance_eval foo.singleton_methods
|
|
||||||
foo.class foo.instance_of? foo.taint
|
|
||||||
foo.clone foo.instance_variables foo.tainted?
|
|
||||||
foo.display foo.is_a? foo.to_a
|
|
||||||
foo.dup foo.kind_of? foo.to_s
|
|
||||||
foo.eql? foo.method foo.type
|
|
||||||
foo.equal? foo.methods foo.untaint
|
|
||||||
foo.extend foo.nil?
|
|
||||||
foo.freeze foo.private_methods
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
% Begin Emacs Environment
|
|
||||||
% Local Variables:
|
|
||||||
% mode: text
|
|
||||||
% comment-column: 0
|
|
||||||
% comment-start: "%"
|
|
||||||
% comment-end: "\n"
|
|
||||||
% End:
|
|
||||||
%
|
|
||||||
|
|
@ -1,425 +0,0 @@
|
|||||||
irb -- interactive ruby
|
|
||||||
$Release Version: 0.9.5 $
|
|
||||||
$Revision$
|
|
||||||
by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
|
||||||
=begin
|
|
||||||
= irbとは?
|
|
||||||
|
|
||||||
irbはinteractive rubyの略です. rubyの式を標準入力から簡単に入力/実行する
|
|
||||||
ためのツールです.
|
|
||||||
|
|
||||||
= 起動
|
|
||||||
|
|
||||||
% irb
|
|
||||||
|
|
||||||
で行ないます.
|
|
||||||
|
|
||||||
= 使い方
|
|
||||||
|
|
||||||
irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本的には irb と
|
|
||||||
いうコマンドを実行するだけです. irbを実行すると, 以下のようなプロンプ
|
|
||||||
トが表れてきます. 後は, rubyの式を入れて下さい. 式が完結した時点で実行
|
|
||||||
されます.
|
|
||||||
|
|
||||||
dim% irb
|
|
||||||
irb(main):001:0> 1+2
|
|
||||||
3
|
|
||||||
irb(main):002:0> class Foo
|
|
||||||
irb(main):003:1> def foo
|
|
||||||
irb(main):004:2> print 1
|
|
||||||
irb(main):005:2> end
|
|
||||||
irb(main):006:1> end
|
|
||||||
nil
|
|
||||||
irb(main):007:0>
|
|
||||||
|
|
||||||
また, irbはReadlineモジュールにも対応しています. Readlineモジュールが
|
|
||||||
インストールされている時には, それを使うのが標準の動作になります.
|
|
||||||
|
|
||||||
= コマンドオプション
|
|
||||||
|
|
||||||
irb.rb [options] file_name opts
|
|
||||||
options:
|
|
||||||
-f ~/.irbrc を読み込まない.
|
|
||||||
-d $DEBUG をtrueにする(ruby -d と同じ)
|
|
||||||
-r load-module ruby -r と同じ.
|
|
||||||
-I path $LOAD_PATH に path を追加する.
|
|
||||||
-U ruby -U と同じ.
|
|
||||||
-E enc ruby -E と同じ.
|
|
||||||
-w ruby -w と同じ.
|
|
||||||
-W[level=2] ruby -W と同じ.
|
|
||||||
--context-mode n 新しいワークスペースを作成した時に関連する Binding
|
|
||||||
オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
|
|
||||||
--echo 実行結果を表示する(デフォルト).
|
|
||||||
--noecho 実行結果を表示しない.
|
|
||||||
--echo-on-assignment
|
|
||||||
代入時に実行結果を表示する.
|
|
||||||
--noecho-on-assignment
|
|
||||||
代入時に実行結果を表示しない.
|
|
||||||
--truncate-echo-on-assignment
|
|
||||||
代入時に省略された実行結果を表示する(デフォルト).
|
|
||||||
--inspect 結果出力にinspectを用いる.
|
|
||||||
--noinspect 結果出力にinspectを用いない.
|
|
||||||
--singleline シングルラインエディタを利用する.
|
|
||||||
--nosingleline シングルラインエディタを利用しない. デフォルトの動
|
|
||||||
作は, inf-ruby-mode以外でシングルラインエディタを利
|
|
||||||
用しようとする.
|
|
||||||
--colorize 色付けを利用する.
|
|
||||||
--nocolorize 色付けを利用しない.
|
|
||||||
--autocomplete オートコンプリートを利用する.
|
|
||||||
--noautocomplete オートコンプリートを利用しない.
|
|
||||||
--prompt prompt-mode
|
|
||||||
--prompt-mode prompt-mode
|
|
||||||
プロンプトモードを切替えます. 現在定義されているプ
|
|
||||||
ロンプトモードは, default, simple, xmp, inf-rubyが
|
|
||||||
用意されています.
|
|
||||||
--inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特
|
|
||||||
に指定がない限り, ラインエディタは使わなくなる.
|
|
||||||
--simple-prompt
|
|
||||||
非常にシンプルなプロンプトを用いるモードです.
|
|
||||||
--noprompt プロンプト表示を行なわない.
|
|
||||||
--single-irb irb 中で self を実行して得られるオブジェクトをサ
|
|
||||||
ブ irb と共有する.
|
|
||||||
--tracer コマンド実行時にトレースを行なう.
|
|
||||||
--back-trace-limit n
|
|
||||||
バックトレース表示をバックトレースの頭から n, 後ろ
|
|
||||||
からnだけ行なう. デフォルトは16
|
|
||||||
|
|
||||||
--verbose 詳細なメッセージを出力する.
|
|
||||||
--noverbose 詳細なメッセージを出力しない(デフォルト).
|
|
||||||
-v, --version irbのバージョンを表示する.
|
|
||||||
-h, --help irb のヘルプを表示する.
|
|
||||||
-- 以降のコマンドライン引数をオプションとして扱わない.
|
|
||||||
|
|
||||||
= コンフィギュレーション
|
|
||||||
|
|
||||||
irb起動時に``~/.irbrc''を読み込みます. もし存在しない場合は,
|
|
||||||
``.irbrc'', ``irb.rc'', ``_irbrc'', ``$irbrc''の順にloadを試みます.
|
|
||||||
|
|
||||||
オプションを設定する代わりに, 以下のコマンドでもデフォルトの動作を設定
|
|
||||||
できます.
|
|
||||||
|
|
||||||
IRB.conf[:IRB_NAME]="irb"
|
|
||||||
IRB.conf[:USE_TRACER]=false
|
|
||||||
IRB.conf[:USE_LOADER]=false
|
|
||||||
IRB.conf[:IGNORE_SIGINT]=true
|
|
||||||
IRB.conf[:IGNORE_EOF]=false
|
|
||||||
IRB.conf[:INSPECT_MODE]=nil
|
|
||||||
IRB.conf[:IRB_RC] = nil
|
|
||||||
IRB.conf[:BACK_TRACE_LIMIT]=16
|
|
||||||
IRB.conf[:USE_LOADER] = false
|
|
||||||
IRB.conf[:USE_SINGLELINE] = nil
|
|
||||||
IRB.conf[:USE_TRACER] = false
|
|
||||||
IRB.conf[:IGNORE_SIGINT] = true
|
|
||||||
IRB.conf[:IGNORE_EOF] = false
|
|
||||||
IRB.conf[:PROMPT_MODE] = :DEFAULT
|
|
||||||
IRB.conf[:PROMPT] = {...}
|
|
||||||
IRB.conf[:VERBOSE]=true
|
|
||||||
|
|
||||||
== プロンプトの設定
|
|
||||||
|
|
||||||
プロンプトをカスタマイズしたい時には,
|
|
||||||
|
|
||||||
IRB.conf[:PROMPT]
|
|
||||||
|
|
||||||
を用います. 例えば, .irbrcの中で下のような式を記述します:
|
|
||||||
|
|
||||||
IRB.conf[:PROMPT][:MY_PROMPT] = { # プロンプトモードの名前
|
|
||||||
:PROMPT_I => nil, # 通常のプロンプト
|
|
||||||
:PROMPT_S => nil, # 文字列などの継続行のプロンプト
|
|
||||||
:PROMPT_C => nil, # 式が継続している時のプロンプト
|
|
||||||
:RETURN => " ==>%s\n" # リターン時のプロンプト
|
|
||||||
}
|
|
||||||
|
|
||||||
プロンプトモードを指定したい時には,
|
|
||||||
|
|
||||||
irb --prompt my-prompt
|
|
||||||
|
|
||||||
でそのプロンプトモードで起動されます. または, .irbrcに下式を記述しても
|
|
||||||
OKです.
|
|
||||||
|
|
||||||
IRB.conf[:PROMPT_MODE] = :MY_PROMPT
|
|
||||||
|
|
||||||
PROMPT_I, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
|
|
||||||
|
|
||||||
%N 起動しているコマンド名が出力される.
|
|
||||||
%m mainオブジェクト(self)がto_sで出力される.
|
|
||||||
%M mainオブジェクト(self)がinspectされて出力される.
|
|
||||||
%l 文字列中のタイプを表す(", ', /, ], `]'は%wの中の時)
|
|
||||||
%NNi インデントのレベルを表す. NNは数字が入りprintfの%NNdと同じ. 省
|
|
||||||
略可能
|
|
||||||
%NNn 行番号を表します.
|
|
||||||
%% %
|
|
||||||
|
|
||||||
例えば, デフォルトのプロンプトモードは:
|
|
||||||
|
|
||||||
IRB.conf[:PROMPT][:DEFAULT] = {
|
|
||||||
:PROMPT_I => "%N(%m):%03n:%i> ",
|
|
||||||
:PROMPT_S => "%N(%m):%03n:%i%l ",
|
|
||||||
:PROMPT_C => "%N(%m):%03n:%i* ",
|
|
||||||
:RETURN => "=> %s\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
となっています.
|
|
||||||
|
|
||||||
RETURNは, 現在のところprintf形式です. 将来仕様が変わるかも知れません.
|
|
||||||
|
|
||||||
== サブirbの設定
|
|
||||||
|
|
||||||
コマンドラインオプションおよびIRB.confは(サブ)irb起動時のデフォルトの
|
|
||||||
設定を決めるもので, `5. コマンド'にあるconfで個別の(サブ)irbの設定がで
|
|
||||||
きるようになっています.
|
|
||||||
|
|
||||||
IRB.conf[:IRB_RC]にprocが設定されていると, サブirbを起動する時にその
|
|
||||||
procをirbのコンテキストを引数として呼び出します. これによって個別のサ
|
|
||||||
ブirbごとに設定を変えることができるようになります.
|
|
||||||
|
|
||||||
|
|
||||||
= コマンド
|
|
||||||
|
|
||||||
irb拡張コマンドは, 簡単な名前と頭に`irb_'をつけた名前と両方定義されて
|
|
||||||
います. これは, 簡単な名前がoverrideされた時のためです.
|
|
||||||
|
|
||||||
--- exit, quit, irb_exit
|
|
||||||
終了する.
|
|
||||||
サブirbの場合, そのサブirbを終了する.
|
|
||||||
|
|
||||||
--- conf, irb_context
|
|
||||||
irbの現在の設定を表示する. 設定の変更は, confにメッセージを送るこ
|
|
||||||
とによって行なえる.
|
|
||||||
|
|
||||||
--- conf.eval_history = N
|
|
||||||
実行結果のヒストリ機能の設定.
|
|
||||||
nnは整数かnilで nn>0 であればその数だけヒストリにためる。nn==0の時は
|
|
||||||
無制限に記憶する、nilだとヒストリ機能はやめる(デフォルト).
|
|
||||||
|
|
||||||
--- Conf.back_trace_limit
|
|
||||||
バックトレース表示をバックトレースの頭からn, 後ろからnだけ行なう.
|
|
||||||
デフォルトは16
|
|
||||||
|
|
||||||
--- conf.ignore_eof = true/false
|
|
||||||
^Dが入力された時の動作を設定する. trueの時は^Dを無視する, falseの
|
|
||||||
時はirbを終了する.
|
|
||||||
|
|
||||||
--- conf.ignore_sigint= true/false
|
|
||||||
^Cが入力された時の動作を設定する. false時は, irbを終了する. trueの
|
|
||||||
時の動作は以下のようになる:
|
|
||||||
入力中: これまで入力したものをキャンセルしトップレベルに戻る.
|
|
||||||
実行中: 実行を中止する.
|
|
||||||
|
|
||||||
--- conf.inf_ruby_mode = true/false
|
|
||||||
inf-ruby-mode用のプロンプト表示を行なう. デフォルトはfalse. 特に指定
|
|
||||||
がない限り, ラインエディタは使わなくなる.
|
|
||||||
|
|
||||||
--- conf.inspect_mode = true/false/nil
|
|
||||||
インスペクトモードを設定する.
|
|
||||||
true: インスペクトして表示する.
|
|
||||||
false: 通常のprintで表示する.
|
|
||||||
nil: 通常モードであれば, inspect modeとなり, mathモードの時は, non
|
|
||||||
inspect modeとなる.
|
|
||||||
|
|
||||||
--- conf.use_loader = true/false
|
|
||||||
load/require時にirbのfile読み込み機能を用いるモードのスイッチ(デフォ
|
|
||||||
ルトは用いない). このモードはIRB全体に反映される.
|
|
||||||
|
|
||||||
--- conf.prompt_c
|
|
||||||
ifの直後など, 行が継続している時のプロンプト.
|
|
||||||
|
|
||||||
--- conf.prompt_i
|
|
||||||
通常のプロンプト.
|
|
||||||
|
|
||||||
--- conf.prompt_s
|
|
||||||
文字列中などを表すプロンプト.
|
|
||||||
|
|
||||||
--- conf.rc
|
|
||||||
~/.irbrcを読み込んだかどうか?
|
|
||||||
|
|
||||||
--- conf.use_prompt = true/false
|
|
||||||
プロンプト表示するかどうか? デフォルトではプロンプトを表示する.
|
|
||||||
|
|
||||||
--- conf.use_multiline = true/false/nil
|
|
||||||
マルチラインエディタを使うかどうか?
|
|
||||||
true: マルチラインエディタを使う.
|
|
||||||
false: マルチラインエディタを使わない.
|
|
||||||
nil: (デフォルト)inf-ruby-mode以外でマルチラインエディタを利用しよう
|
|
||||||
とする.
|
|
||||||
|
|
||||||
--- conf.use_singleline = true/false/nil
|
|
||||||
シングルラインエディタを使うかどうか?
|
|
||||||
true: シングルラインエディタを使う.
|
|
||||||
false: シングルラインエディタを使わない.
|
|
||||||
nil: (デフォルト)inf-ruby-modeとマルチラインエディタ以外でシングルラ
|
|
||||||
インエディタを利用しようとする.
|
|
||||||
#
|
|
||||||
#--- conf.verbose=T/F
|
|
||||||
# irbからいろいろなメッセージを出力するか?
|
|
||||||
|
|
||||||
--- cws, chws, irb_cws, irb_chws, irb_change_workspace [obj]
|
|
||||||
objをselfとする. objが省略されたときは, home workspace, すなわち
|
|
||||||
irbを起動したときのmain objectをselfとする.
|
|
||||||
|
|
||||||
--- pushws, irb_pushws, irb_push_workspace [obj]
|
|
||||||
UNIXシェルコマンドのpushdと同様.
|
|
||||||
|
|
||||||
--- popws, irb_popws, irb_pop_workspace
|
|
||||||
UNIXシェルコマンドのpopdと同様.
|
|
||||||
|
|
||||||
--- irb [obj]
|
|
||||||
サブirbを立ちあげる. objが指定された時は, そのobjをselfとする.
|
|
||||||
|
|
||||||
--- jobs, irb_jobs
|
|
||||||
サブirbのリスト
|
|
||||||
|
|
||||||
--- fg n, irb_fg n
|
|
||||||
指定したサブirbにスイッチする. nは, 次のものを指定する.
|
|
||||||
|
|
||||||
irb番号
|
|
||||||
スレッド
|
|
||||||
irbオブジェクト
|
|
||||||
self(irb objで起動した時のobj)
|
|
||||||
|
|
||||||
--- kill n, irb_kill n
|
|
||||||
サブirbをkillする. nはfgと同じ.
|
|
||||||
|
|
||||||
--- source, irb_source path
|
|
||||||
UNIXシェルコマンドのsourceと似ている. 現在の環境上でpath内のスクリ
|
|
||||||
プトを評価する.
|
|
||||||
|
|
||||||
--- irb_load path, prev
|
|
||||||
|
|
||||||
Rubyのloadのirb版.
|
|
||||||
|
|
||||||
= システム変数
|
|
||||||
|
|
||||||
--- _
|
|
||||||
前の計算の実行結果を覚えている(ローカル変数).
|
|
||||||
--- __
|
|
||||||
実行結果の履歴を覚えている.
|
|
||||||
__[line_no]で、その行で実行した結果を得ることができる. line_noが負の
|
|
||||||
時には、最新の結果から-line_no前の結果を得ることができる.
|
|
||||||
|
|
||||||
= 使用例
|
|
||||||
|
|
||||||
以下のような感じです.
|
|
||||||
|
|
||||||
dim% ruby irb.rb
|
|
||||||
irb(main):001:0> irb # サブirbの立ちあげ
|
|
||||||
irb#1(main):001:0> jobs # サブirbのリスト
|
|
||||||
#0->irb on main (#<Thread:0x400fb7e4> : stop)
|
|
||||||
#1->irb#1 on main (#<Thread:0x40125d64> : running)
|
|
||||||
nil
|
|
||||||
irb#1(main):002:0> fg 0 # jobのスイッチ
|
|
||||||
nil
|
|
||||||
irb(main):002:0> class Foo;end
|
|
||||||
nil
|
|
||||||
irb(main):003:0> irb Foo # Fooをコンテキストしてirb
|
|
||||||
# 立ちあげ
|
|
||||||
irb#2(Foo):001:0> def foo # Foo#fooの定義
|
|
||||||
irb#2(Foo):002:1> print 1
|
|
||||||
irb#2(Foo):003:1> end
|
|
||||||
nil
|
|
||||||
irb#2(Foo):004:0> fg 0 # jobをスイッチ
|
|
||||||
nil
|
|
||||||
irb(main):004:0> jobs # jobのリスト
|
|
||||||
#0->irb on main (#<Thread:0x400fb7e4> : running)
|
|
||||||
#1->irb#1 on main (#<Thread:0x40125d64> : stop)
|
|
||||||
#2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
|
|
||||||
nil
|
|
||||||
irb(main):005:0> Foo.instance_methods # Foo#fooがちゃんと定義さ
|
|
||||||
# れている
|
|
||||||
["foo"]
|
|
||||||
irb(main):006:0> fg 2 # jobをスイッチ
|
|
||||||
nil
|
|
||||||
irb#2(Foo):005:0> def bar # Foo#barを定義
|
|
||||||
irb#2(Foo):006:1> print "bar"
|
|
||||||
irb#2(Foo):007:1> end
|
|
||||||
nil
|
|
||||||
irb#2(Foo):010:0> Foo.instance_methods
|
|
||||||
["bar", "foo"]
|
|
||||||
irb#2(Foo):011:0> fg 0
|
|
||||||
nil
|
|
||||||
irb(main):007:0> f = Foo.new
|
|
||||||
#<Foo:0x4010af3c>
|
|
||||||
irb(main):008:0> irb f # Fooのインスタンスでirbを
|
|
||||||
# 立ちあげる.
|
|
||||||
irb#3(#<Foo:0x4010af3c>):001:0> jobs
|
|
||||||
#0->irb on main (#<Thread:0x400fb7e4> : stop)
|
|
||||||
#1->irb#1 on main (#<Thread:0x40125d64> : stop)
|
|
||||||
#2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
|
|
||||||
#3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
|
|
||||||
nil
|
|
||||||
irb#3(#<Foo:0x4010af3c>):002:0> foo # f.fooの実行
|
|
||||||
nil
|
|
||||||
irb#3(#<Foo:0x4010af3c>):003:0> bar # f.barの実行
|
|
||||||
barnil
|
|
||||||
irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# jobのkill
|
|
||||||
nil
|
|
||||||
irb(main):009:0> jobs
|
|
||||||
#0->irb on main (#<Thread:0x400fb7e4> : running)
|
|
||||||
nil
|
|
||||||
irb(main):010:0> exit # 終了
|
|
||||||
dim%
|
|
||||||
|
|
||||||
= 使用上の制限
|
|
||||||
|
|
||||||
irbは, 評価できる時点(式が閉じた時点)での逐次実行を行ないます. したがっ
|
|
||||||
て, rubyを直接使った時と, 若干異なる動作を行なう場合があります.
|
|
||||||
|
|
||||||
現在明らかになっている問題点を説明します.
|
|
||||||
|
|
||||||
== ローカル変数の宣言
|
|
||||||
|
|
||||||
rubyでは, 以下のプログラムはエラーになります.
|
|
||||||
|
|
||||||
eval "foo = 0"
|
|
||||||
foo
|
|
||||||
--
|
|
||||||
-:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError)
|
|
||||||
---
|
|
||||||
NameError
|
|
||||||
|
|
||||||
ところが, irbを用いると
|
|
||||||
|
|
||||||
>> eval "foo = 0"
|
|
||||||
=> 0
|
|
||||||
>> foo
|
|
||||||
=> 0
|
|
||||||
|
|
||||||
となり, エラーを起こしません. これは, rubyが最初にスクリプト全体をコン
|
|
||||||
パイルしてローカル変数を決定するからです. それに対し, irbは実行可能に
|
|
||||||
なる(式が閉じる)と自動的に評価しているからです. 上記の例では,
|
|
||||||
|
|
||||||
eval "foo = 0"
|
|
||||||
|
|
||||||
を行なった時点で評価を行ない, その時点で変数が定義されるため, 次式で
|
|
||||||
変数fooは定義されているからです.
|
|
||||||
|
|
||||||
このようなrubyとirbの動作の違いを解決したい場合は, begin...endで括って
|
|
||||||
バッチ的に実行して下さい:
|
|
||||||
|
|
||||||
>> begin
|
|
||||||
?> eval "foo = 0"
|
|
||||||
>> foo
|
|
||||||
>> end
|
|
||||||
NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0>
|
|
||||||
(irb):3
|
|
||||||
(irb_local_binding):1:in `eval'
|
|
||||||
|
|
||||||
== ヒアドキュメント
|
|
||||||
|
|
||||||
現在のところヒアドキュメントの実装は不完全です.
|
|
||||||
|
|
||||||
== シンボル
|
|
||||||
|
|
||||||
シンボルであるかどうかの判断を間違えることがあります. 具体的には式が完了
|
|
||||||
しているのに継続行と見なすことがあります.
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
% Begin Emacs Environment
|
|
||||||
% Local Variables:
|
|
||||||
% mode: text
|
|
||||||
% comment-column: 0
|
|
||||||
% comment-start: "%"
|
|
||||||
% comment-end: "\n"
|
|
||||||
% End:
|
|
||||||
%
|
|
@ -190,7 +190,6 @@ module SyncDefaultGems
|
|||||||
cp_r("#{upstream}/test/irb", "test")
|
cp_r("#{upstream}/test/irb", "test")
|
||||||
cp_r("#{upstream}/irb.gemspec", "lib/irb")
|
cp_r("#{upstream}/irb.gemspec", "lib/irb")
|
||||||
cp_r("#{upstream}/man/irb.1", "man/irb.1")
|
cp_r("#{upstream}/man/irb.1", "man/irb.1")
|
||||||
cp_r("#{upstream}/doc/irb", "doc")
|
|
||||||
when "json"
|
when "json"
|
||||||
rm_rf(%w[ext/json lib/json test/json])
|
rm_rf(%w[ext/json lib/json test/json])
|
||||||
cp_r("#{upstream}/ext/json/ext", "ext/json")
|
cp_r("#{upstream}/ext/json/ext", "ext/json")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user