Agile Software Development with Edge Ruby
Ruby / Rails をもちいたソフトウェア開発の中で、Ruby の開発バージョン (発表時 2.3.0-dev) を取り入れているお話をします。本番環境は本番環境、開発環境は開発環境ということで、明日から個人ではじめられる話です。 プログラミングを楽しくする言語 Ruby のことをもっと知りたいという気持ちを持ち帰って頂ければ幸いです。
#!/usr/bin/env ruby | |
require 'irb' | |
class Array | |
def sample | |
detect {|elem| elem.to_sym == :muryoimpl } | |
end | |
end | |
IRB.start(__FILE__) |
# | |
# RSpec の its('foo.bar.baz') { ... } にインスパイアされたものです。 | |
# | |
# array.map(&:foo).map(&:bar).map(&:baz) を array.map_chain('foo.bar.baz') と | |
# 書けるものを書いてみたけれど、実際のところ AR でもちいると n+1 query が起きるため | |
# Gems にするには今ひとつはばかれるのであった。 | |
# | |
class Array | |
def map_chain(method_names) | |
case method_names |
module Readline | |
def readline | |
# ... | |
end | |
module_function :readline | |
def self.input=(input) | |
# ... | |
end |
import junit.framework.TestSuite; | |
import org.junit.runner.Description; | |
import org.junit.runner.JUnitCore; | |
import org.junit.runner.notification.RunListener; | |
public class Main { | |
public static void main(String[] args) { | |
JUnitCore core = new JUnitCore(); | |
core.addListener(new RunListener() { |
$:.unshift(File.dirname(__FILE__)) | |
require 'spec_helper' | |
module BowlongGameMacro | |
class BowlongGamePlayer | |
def initialize | |
@game = Game.new | |
end | |
def roll_spare |
import org.jmock.cglib.MockObjectTestCase; | |
public class ExampleTest extends MockObjectTestCase { | |
public void testExample() throws Exception { | |
... | |
final Mock mock = new Mock(ClassName.class); | |
mock.expects(once()).method("methodName").will(returnValue("returnValue")); | |
mock.proxy(); | |
... |
Timer timer = new Timer(true); | |
... | |
TimerTask task = new TimerTask() { | |
public void run() { | |
// The action to be performed by this timer task. | |
} | |
}; | |
timer.scheduleAtFixedRate(task, 0, watchInterval); |
ruby -e 'Dir.glob("*").each { |jar| system("jar tvf #{jar}") }' |
image = MiniMagick::Image.open('original.png') | |
image.resize '800x600' | |
image.write('resized.png') |