Ruby and Rails James Crisp.NET Practice Lead ThoughtWorks Australia From aperspective
James Crisp
Runtimes MRI
IronRuby Console Demo
public class CSharpDemo : Demo { public void SayHello() { for (int i=0; i<5; i++) { Console.WriteLine(“Hi from C#!”); }} public IEnumerable Greet( public IEnumerable Greet( IEnumerable guests) { return guests.Select(g => “Welcome” + g.Name); }}
class RubyDemo < Demo def say_hello 5.times { puts “Hi from Ruby!” } end def greet(guests) def greet(guests) guests.collect { |g| “Welcome #{g.name}” } endend >> RubyDemo.new.greet(fred, tina) => [“Welcome Fred”, “Welcome Tina”]
Tools and Frameworks
c:\> gem install rails
desc “Generate application code” task :code_gen do # do the code generation # do the code generationend desc “Compile code” task :compile => [:code_gen] do #do the compilation #do the compilationend desc “Test application” task :test => [:compile] do # run the tests # run the testsend Rake
Capistrano desc "Start ferret server" task :start, :role => :app do run "cd #{current_path}; script/ferret_server -e #{stage} start" run "cd #{current_path}; script/ferret_server -e #{stage} start"end desc "Stop ferret server" task :stop, :role => :app do run "cd #{current_path}; script/ferret_server -e #{stage} stop" run "cd #{current_path}; script/ferret_server -e #{stage} stop"end
RSpec describe User do it "should be in any roles assigned to it" do it "should be in any roles assigned to it" do user = User.new user = User.new user.assign_role("assigned role") user.assign_role("assigned role") user.should be_in_role("assigned role") user.should be_in_role("assigned role") end end...end
Routing Table Controller Method ModelView
Rails Project Demo
See also... Rails & screencasts Ruby / Rails API John Lam's blog for Iron Ruby Slides for this talk
-.net logo – agile development with rails - Matz - Ruby book – JRuby logo - YARV logo – IronRuby logo Image References
Questions?