web2.0 and ruby

Download Web2.0 and Ruby

Post on 21-Oct-2014

3.396 views

Category:

Technology

2 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

Microsoft PowerPoint - web2.0-and-ruby.ppt

2008.02.26

Web 2.0Web 2.0RubyRuby

()

http://www.edit.ne.jp/~koic/

gem install rails gem install rails --yy

2Web 2.0Ruby

: http://www.edit.ne.jp/~koic/ Twitter: http://twitter.com/koic/ : koic.ito@gmail.com :

3Web 2.0Ruby

4Web 2.0Ruby

5Web 2.0Ruby

6Web 2.0Ruby

GoF

java.lang

7Web 2.0Ruby

8Web 2.0Ruby

9Web 2.0Ruby

@nawoto LLWG

@_dot

10Web 2.0Ruby

11Web 2.0Ruby

involve NOT evolve

12Web 2.0Ruby

13Web 2.0Ruby

Web 2.0 EngineerMind vol.5

vol.11

928

14Web 2.0Ruby

involve NOT evolve

15Web 2.0Ruby

16Web 2.0Ruby

RubyRuby on Rails Ruby on RailsREST Ruby on Rails

17Web 2.0Ruby

18Web 2.0Ruby

Chapter 1. WebRuby

19Web 2.0Ruby

Ruby

http://www.ruby-lang.org/ja/

20Web 2.0Ruby

Web 2.0 Perl, PHP, Python, RubyLightweight LanguageWeb

21Web 2.0Ruby

Lightweight Language Lightweight Language

22Web 2.0Ruby

say = "I love Ruby"puts say

say['love'] = "*love*"puts say.upcase

5.times { puts say }

23Web 2.0Ruby

Ruby/AmazonWeb API

require 'amazon/search'

if ARGV.size != 2puts "Usage: #{$0} "

"[Amazon Web Services AccessKey ID] [text to search for]"exit

endaccess_key, search_request = ARGVreq = Amazon::Search::Request.new(access_key)

req.keyword_search(search_request, 'books', Amazon::Search::LIGHT) do |book|puts %{"#{book.product_name}" by #{book.authors.join(', ')}}

end

$ ruby amazon-search.rb "restful web services"RESTful Web Services" by Leonard Richardson, Sam Ruby, David Heinemeier

Hansson

amazon-search.rb

RESTful Web

24Web 2.0Ruby

Ruby on Rails

RubyWeb

25Web 2.0Ruby

Ruby on Rails RubyWeb Ruby

David Heinemeier Hansson http://itpro.nikkeibp.co.jp/article/NEWS/20060620/241346/

Ruby

http://www.rubyonrails.org/

26Web 2.0Ruby

Ruby on Rails DRYDont Repeat Yourself

Convention over Configuration

full-stack

27Web 2.0Ruby

Chapter 11

28Web 2.0Ruby

DSL REST

Patterns

DSL REST

full-stackDRYCoC

29Web 2.0Ruby

Domain Specific Language (DSL) WebDSL BDDRSpec

DSL

class Profile < ActiveRecord::Basebelongs_to :account

validates_presence_of :nameend

30Web 2.0Ruby

DSLRuby RubyAPIRailsAPI

DSL

DSL

DSL

Ruby

DSLDSLRails

XMLRuby Rails

Rails

31Web 2.0Ruby

Patterns of Enterprise Application ArchitectureRefactoring DatabasesJ2EE Patterns

Patterns

32Web 2.0Ruby

REST

33Web 2.0Ruby

Chapter 2. RailsREST

34Web 2.0Ruby

RESTROA

REST

ROA

RESTWeb ROA Resource oriented Architecture REST

35Web 2.0Ruby

Web HTTPMachine ReadableXML

ROAWeb

require open-urirequire rexml

open(www...

HTML

XMLHTTP

URL

URL

Web 2008226

36Web 2.0Ruby

URI

URI

REST

URI

GET /maps/tokyo

37Web 2.0Ruby

HTTPGET /maps/tokyo

Map.find(:first, :conditions => [area = ?, tokyo])

HTTP

38Web 2.0Ruby

GET /maps/tokyo

Map.find(:first, :conditions => [area = ?, tokyo])

GETPOSTPUTDELETE

2008226

URI

39Web 2.0Ruby

WebActiveRecordCRUD Rails 2.0 REST

ActiveResource::Base

WebCRUD

Active Resource

class Map < ActiveResource::Baseself.site = http://localhost:3000

end

40Web 2.0Ruby

Lightweight LanguageWebWeb Rails

Chapter 1 & 2

$ gem install rails -y

Ruby

41Web 2.0Ruby

Chapter 3. Ruby on Rails

Rails

42Web 2.0Ruby

Model/Controller View UIJavaScript >< UI

Rails

43Web 2.0Ruby

44Web 2.0Ruby

45Web 2.0Ruby

46Web 2.0Ruby

SVN

RSpec on Railstest/unit

Capistrano

CC.rb

CI

47Web 2.0Ruby

V

A

A

V

A

T

V

V

T

VTA

333 test, development, production

48Web 2.0Ruby

http://cruisecontrolrb.thoughtworks.com/

V

CI

49Web 2.0Ruby

Ruby

50Web 2.0Ruby

51Web 2.0Ruby

irb net/httpWeb Ver 0.1 Irb net/httpWeb WebXMLrexml

Ver 0.2 test/unit net/httpWeb WebXMLrexml

Web

52Web 2.0Ruby

Web

Chapter 3

No, Silver Bullet!

53Web 2.0Ruby

Chapter 4.

54Web 2.0Ruby

JavaRuby 20088

55Web 2.0Ruby

JavaRuby JRuby Ruby 1.9

56Web 2.0Ruby

class Productattr_reader :namedef initialize(name)

@name = nameend

end

public class Product {private String name;

// public String getName() {

return name;}

}

Ruby

Java

getter, setter getter attr_reader

setter attr_writergetter, setter attr_accessor

name

57Web 2.0Ruby

module Specmodule Exceptions

class ExpectationNotMetError < StandardErrorend

endmodule Expectations

def should_equal(expected)raise Spec::Exceptions::ExpectationNotMetError

if self != expectedend

endend

class Objectinclude Spec::Expectations

end

Object

Ruby

p = Product.new(Ruby)p.name.should_equal(Ruby)

p.name.should_equal(Perl)

Ruby

58Web 2.0Ruby

()

()

public

()

()

protected

()()

(self)

privateJavaJavaJavaJavaRubyRubyRubyRuby

JavaRuby Ruby

59Web 2.0Ruby

==equal Java == (

) equal (

Enumerable#sortEnumarable#sort_by sort_by sort_by

Ruby Tips

60Web 2.0Ruby

Ruby 1.8 1.81.9 Ruby VM M17N

Ruby 1.9

Ruby 1.9Appendix

61Web 2.0Ruby

JavaRuby JRubyRuby 1.8 JavaRuby Java JavaRails

2Java Java Enterprise Ruby ><

JRuby

62Web 2.0Ruby

JavaRuby

Chapter 4

20088

63Web 2.0Ruby

WebWeb

Web

64Web 2.0Ruby

4q!