別のキーワード
種類
- インスタンスメソッド (66)
- モジュール関数 (48)
- 特異メソッド (30)
- 文書 (12)
ライブラリ
- benchmark (24)
- fileutils (12)
- rake (12)
- readline (12)
- shell (48)
-
shell
/ command-processor (18) -
shell
/ filter (18)
クラス
- Shell (48)
-
Shell
:: CommandProcessor (18) -
Shell
:: Filter (18)
キーワード
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
-
alias
_ command (6) - benchmark (12)
- bm (12)
-
def
_ system _ command (6) -
install
_ system _ commands (6) - out (18)
- readline (12)
- sh (12)
- transact (18)
-
unalias
_ command (6) -
undef
_ system _ command (6) - uptodate? (12)
検索結果
先頭5件
- Shell
# system(command , *opts) -> Shell :: SystemCommand - Shell
:: CommandProcessor # system(command , *opts) -> Shell :: SystemCommand - Shell
:: Filter # system(command , *opts) -> Shell :: SystemCommand - Shell
. def _ system _ command(command , path = command) -> nil - Shell
. undef _ system _ command(command) -> Shell :: CommandProcessor
-
Shell
# system(command , *opts) -> Shell :: SystemCommand (18231.0) -
command を実行する.
...で指定します。
@param opts command のオプションを文字列で指定します。複数可。
使用例:
require 'shell'
Shell.verbose = false
sh = Shell.new
print sh.system("ls", "-l")
Shell.def_system_command("head")
sh.system("ls", "-l") | sh.head("-n 3") > STDOUT... -
Shell
:: CommandProcessor # system(command , *opts) -> Shell :: SystemCommand (18231.0) -
command を実行する.
...で指定します。
@param opts command のオプションを文字列で指定します。複数可。
使用例:
require 'shell'
Shell.verbose = false
sh = Shell.new
print sh.system("ls", "-l")
Shell.def_system_command("head")
sh.system("ls", "-l") | sh.head("-n 3") > STDOUT... -
Shell
:: Filter # system(command , *opts) -> Shell :: SystemCommand (18231.0) -
command を実行する.
...で指定します。
@param opts command のオプションを文字列で指定します。複数可。
使用例:
require 'shell'
Shell.verbose = false
sh = Shell.new
print sh.system("ls", "-l")
Shell.def_system_command("head")
sh.system("ls", "-l") | sh.head("-n 3") > STDOUT... -
Shell
. def _ system _ command(command , path = command) -> nil (6143.0) -
Shell のメソッドとして command を登録します.
...ドを実行するにはまず, Shellのメソッドとして定義します.
注) コマンドを定義しなくとも直接実行できる Shell#system コマンドもあります.
@param command Shell のメソッドとして定義するコマンドを文字列で指定します。
@param path......ます。
例)
require 'shell'
Shell.def_system_command "ls"
# ls を定義
Shell.def_system_command "sys_sort", "sort"
# sortコマンドをsys_sortとして定義
sh = Shell.new
sh.transact {
ls.each { |l|
puts l
}
(ls("-l") | sys_sort("-k 5")).each {|l|
pu... -
Shell
. undef _ system _ command(command) -> Shell :: CommandProcessor (6143.0) -
commandを削除します.
...の文字列を指定します。
動作例:
require 'shell'
Shell.def_system_command("ls")
# ls を定義
Shell.undef_system_command("ls")
# ls を 削除
sh = Shell.new
begin
sh.transact {
ls("-l").each {|l|
puts l
}
}
rescue NameError => err
put... -
Shell
. install _ system _ commands(pre = "sys _ ") -> () (6135.0) -
system_path上にある全ての実行可能ファイルをShellに定義する. メソッ ド名は元のファイル名の頭にpreをつけたものとなる.
...
system_path上にある全ての実行可能ファイルをShellに定義する. メソッ
ド名は元のファイル名の頭にpreをつけたものとなる.
@param pre Shellに定義するメソッド名の先頭に付加される文字列を指定します。
使用例: ls -l | head -n 5......のような例。
require 'shell'
Shell.install_system_commands
sh = Shell.new
sh.verbose = false
sh.transact {
(sys_ls("-l") | sys_head("-n 5")).each {|l|
puts l
}
}... -
FileUtils
# sh(*cmd) {|result , status| . . . } (3018.0) -
与えられたコマンドを実行します。
...参照してください。
例:
sh %{ls -ltr}
sh 'ls', 'file with spaces'
# check exit status after command runs
sh %{grep pattern file} do |ok, res|
if ! ok
puts "pattern not found (status = #{res.exitstatus})"
end
end
@see Kernel.#exec, Kernel.#system... -
FileUtils
. # uptodate?(newer , older _ list , options = nil) -> bool (3006.0) -
newer が、older_list に含まれるすべてのファイルより新しいとき真。 存在しないファイルは無限に古いとみなされます。
...@param options どのようなオプションも指定することはできません。
@raise ArgumentError options にオプションを指定した場合に発生します。
//emlist[][ruby]{
require 'fileutils'
FileUtils.uptodate?('hello.o', ['hello.c', 'hello.h']) or system('make')
//}... -
Readline
. # readline(prompt = "" , add _ hist = false) -> String | nil (130.0) -
prompt を出力し、ユーザからのキー入力を待ちます。 エンターキーの押下などでユーザが文字列を入力し終えると、 入力した文字列を返します。 このとき、add_hist が true であれば、入力した文字列を入力履歴に追加します。 何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、 ユーザからの入力がない場合は nil を返します。
...adline.readline("> ")
(">"を表示し、入力待ちの状態になります。
ここでは「ls」を入力後、エンターキーを押したと想定します。)
> ls
p input # => "ls"
input = Readline.readline("> ", true)
(">"を表示し、入力待ちの状態になります......dline.readline
p buf
end
rescue Interrupt
system("stty", stty_save)
exit
end
例: INTシグナルを捕捉して、端末状態を復帰する。
require 'readline'
stty_save = `stty -g`.chomp
trap("INT") { system "stty", stty_save; exit }
while buf = Readline.rea... -
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (118.0) -
Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
...am labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
=== フォーマット文字列
フォーマット文字列として以下が使用できます。
: %u
user CPU time で置き換えられます。Benchmark::Tms#utime
: %y
system CPU ti......stem")。Benchmark::Tms#stime
: %U
子プロセスの user CPU time で置き換えられます。Benchmark::Tms#cutime
: %Y
子プロセスの system CPU time で置き換えられます。Benchmark::Tms#cstime
: %t
total CPU time で置き換えられます。Benchmark::Tms#total
: %r
実.......times do ; a = "1"; end }
tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
[tf+tt+tu, (tf+tt+tu)/3]
end
#=>
#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
# upto:... -
Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] (118.0) -
Benchmark.#benchmark メソッドの引数を簡略化したものです。
...たものです。
Benchmark.#benchmark メソッドと同様に働きます。
@param label_width ラベルの幅を指定します。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
//emlist[][ruby]{
require 'benchmark'
n = 50000......eport { for i in 1..n; a = "1"; end }
x.report { n.times do ; a = "1"; end }
x.report { 1.upto(n) do ; a = "1"; end }
end
#=>
#
# user system total real
# 1.033333 0.016667 1.016667 ( 0.492106)
# 1.483333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000000 1.51......"1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
end
#=>
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
# upto:... -
Shell
. alias _ command(alias , command , *opts) { . . . } -> self (46.0) -
コマンドの別名(エイリアス)を作成します。 コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.
...l.def_system_command などであらかじめ作成します.
@param alias エイリアスの名前を文字列で指定します.
@param command コマンド名を文字列で指定します.
@param opts command で指定したコマンドのオプションを指定します.
使用例: ls -la......| sort -k 5 のような例。
require 'shell'
Shell.def_system_command("ls")
Shell.alias_command("lsla", "ls", "-a", "-l")
Shell.def_system_command("sort")
sh = Shell.new
sh.transact {
(lsla | sort("-k 5")).each {|l|
puts l
}
}...