Ruby


yaml


hash, array

記事:


カレントディレクトリの取得


rbenv でrubyのバージョン切り替え


rvmを読み込まないようにする

/etc/profile.d/rvm.sh がログインする度に読み込まれるが、rpmで入れていたバージョンを常に使いたい場合に無効にできる


rubyバージョンをシステムバージョンに戻す

rvm use system

gemファイルの依存性を表示

gem dependency aws-sdk                                                                  
Gem aws-sdk-1.7.1
  httparty (~> 0.7)
  json (~> 1.4)
  nokogiri (>= 1.4.4)
  uuidtools (~> 2.1)

デバッグ


スタックトレースの取得


irb(interactive ruby)

library irb

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。


RVMのアンインストール

rvm seppuku
# globalに入っている場合はsudoを付ける
sudo rvm seppuku
sudo rm /etc/profile.d/rvm.sh
# ~/.rvm , ~/.bashrc の中, ~/.bash_profile の中が消えているか確認

RVM(Ruby Version Manager) で複数バージョンのRubyを共存


CentOS5.8上にRuby1.9, RubyGems1.8.24, Rails 3.2.2をインストール

  1. root, /tmpで作業
    sudo su -
    cd /tmp
  2. checkinstall, yamlのインストール。CentOS5.8ではrpmforgeからcheckinstallのインストールは出来なくなった
    yum --enablerepo=epel install yaml libyaml-devel
    wget http://futuremix.org/downloads/checkinstall-1.6.1-1.src.rpm
    wget http://futuremix.org/downloads/checkinstall-1.6.1-1.x86_64.rpm
    rpm -ivh checkinstall-1.6.1-1.x86_64.rpm

Logger

fog クラウドサービスライブラリ


[WARNING] MultiJson is using the default adapter

RubyGems

セキュリティ

相対パスでも絶対パスでもrequire


関数名の取得

	# 呼び出し元関数情報を取得
	# 
	# @note
	# - p parse_caller(caller.first)
	def parse_caller(at)
	  if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
	    file = $1
	    line = $2.to_i
	    method = $3
	    return [file, line, method]
	  end
	end

	# 実行中関数名を取得
	def function_name
		return caller.first.scan(/`(.*)'/).to_s
	end

定数

__LINE__
__FILE__

便利関数


標準入出力

STDIN
STDOUT
STDERR
$stdin
$stdout = $defout
$stderr = $deferr

vim設定


チートシート


添付ファイル: filerackspace-dns.rb 1888件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-11-10 (水) 12:18:16