Skip to content

Instantly share code, notes, and snippets.

フィーチャ: 入稿管理ビルダの認証権限
シナリオアウトライン: メソッドレベルの権限
前提 DUの入稿管理ビルダがあり
かつ AMSに"<ユーザ>"でログインしている
ならば "save"ビルダコマンドの実行は"<save>"
かつ "abandon!"ビルダコマンドの実行は"<abandon!>"
かつ "reset"ビルダコマンドの実行は"<reset>"
例:
| ユーザ | save | commit | abandon! | reset |
require 'mechanize'
WWW::Mechanize::Page.class_eval do
def images
@images ||= search('img').map do |img|
case src = img['src']
when %r{^https?://}
src
else
(uri + src).to_s
module Inline
include Haml::Filters::Base
def self.[](key)
@@data[key.to_s] rescue nil
end
def render(str)
@@data = Hash[*str.split(/^\s*@@\s*(\w+)\s*\n/m)[1..-1]]
return nil
User.transaction(:serializable) do
...
# generates
BEGIN ;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE ;
class Foo
def a
end
private
def b
end
end
Foo.new.should respond_to(:a) # passed
Spec::Matchers.define :be_extension_of do |expected|
match do |obj|
(class << obj; self; end).ancestors.include?(expected)
end
end
obj = Object.new
obj.should be_extension_of(Kernel) # => true
obj.should be_extension_of(Spec) # Spec::Expectations::ExpectationNotMetError
obj.extend(Spec)
We couldn’t find that file to show.
require 'chawan'
text = '本日はバリ晴天なりっす'
Chawan.parse(text)
=> [<名詞: '本日'>, <助詞: 'は'>, <名詞: 'バリ'>, <名詞: '晴天'>, <助動詞: 'なり'>, <助動詞: 'っす'>]
Chawan.parse(text).noun
=> [<名詞: '本日'>, <名詞: 'バリ'>, <名詞: '晴天'>]
Chawan.parse(text).compact.noun
=> [<名詞: '本日'>, <名詞: 'バリ晴天'>]
require 'rubygems'
require 'extlib'
class Foo
include Extlib::Hook
def foo(arg)
p [:foo, arg]
end