SSHでつないで何か操作を行ったり、パスワードの入力を自動化したり、対話形式のプログラムをプログラム中から利用する場合は、expectモジュールを使用するのが一般的です。 Rubyは標準ライブラリ中にexpect.rbが存在していますが、IO#exceptとしてIOのメソッドとして定義されていて、このままでは扱いにくいので、仮想端末を扱うPTYライブラリとあわせて使用します。 require 'pty' require 'expect' module Expect def spawn(cmd) puts "CMD: #{cmd}" if $expect_verbose PTY.spawn(cmd) do |r,w,pid| @input_stream = r @output_stream = w @child_pid = pid PTY.protect_signal do yield en
■ [Ruby] gemのパッケージを展開する Gem::Installer#unpackを使うと簡単です。 require "rubygems/installer" Gem::Installer.new("classx-0.0.4.gem").unpack("classx-0.0.4") コマンドラインのほうがもっと簡単。 % gem unpack classx-0.0.4.gem Unpacked gem: '/tmp/classx-0.0.4' % ls classx-0.0.4 ChangeLog README Rakefile bench doc example lib spec tasks 見てわかるとおり上はこっちから逆に導き出したもんなんだけど。 ■ [C] CSpec : Behavior-driven development in C これはどうだろうねえ。 Overv
In a previous entry I discussed why I prefer One Assertion Per Test. In that entry I give a few state based examples, but didn't address the topic of mocks. This entry is going to focus on how you can use mocks while maintaining focus on maintainability. Let's start with an example. require 'test/unit' require 'rubygems' require 'mocha' module Expectations class SuiteRunner attr_accessor :suite de
京都市の美味しいパティスリーを紹介したい 前編(北側エリア) こんばんはぁ、ぺのぽすです 京都大学に入学してそろそろ4年目、趣味のパティスリー巡りをしてて気づいたことがあります。 京都市のパティスリー、レベル高すぎ!! 京都市はホントどこに行ってもで~~ら美味しいパティスリーがあり大体の観光、ご飯のついでに激ウマ…
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く