Railsåå¼·ä¼ï¼ æ±äº¬ç¬¬5å ã«è¡ã£ã¦ãããååã¯ããã¸ã§ã¯ããæ¢ã«é ãæ°å³ã«ã¦åå ã§ããªãã£ãã®ã§2ã¶æã¶ãã¨ãªãã
å°é¨ã®æ¯ãä¸ãç§èåé§ åã¨ããããé¨ãé¿ãã¦ãã¤ãã«åã«å¯ã£ããããã«éã¾ã£ããæªããéå£ã飲ç©çæã«éã¾ã£ã¦ããã®ã§ããã¤ãã«ã®å®è¡ããã«ãæ·å°å 飲é£ç¦æ¢ã ããã¨æããããã§ããã©ãã¾ã§å ¬éã§ã©ãããæ·å°ãªã®ãä¸æã
ä»åã¯åå¼·ä¼ã»æ親ä¼ã¨ãã«åå è ãéå»æé«ã¨ãããã¨ã§ããã大éªã®åå¼·ä¼ã®å¤§è¦æ¨¡ãã¨æ¬æ ¼ãã«ã¯åã°ãªãããã©ãæ±äº¬ãçãä¸ãã£ã¦ããã
æ¯åº¦ããªãã¿ãååã»å¾åã«åãã¦ãããããªã¼ãã³ã¹ãã¼ã¹å½¢å¼ãæ¡ã£ãã
åå
3ã¤ã®ã»ãã·ã§ã³ã«åãããã
- Rails 1.1ã®æ°æ©è½
- ããã®ããRailsã¬ã·ããï¼ä»®ï¼æã¡åãã
- AWDwR chap.2ãèªã
ç§ã¯ããããã®ããRailsã¬ã·ããï¼ä»®ï¼æã¡åãããã«åºããã½ãããã³ã¯ã»ã¯ãªã¨ã¤ãã£ãããåºçäºå®ã®Railsã¬ã·ãæ¬ã®ãã¿åºãã§ãããããã¯ãããã¨é«æ©ä¼é·ãèè ã¨ãããã¨ã§ok?ãèè ã»ç·¨éè ã®ã¿ãªãã¾ãåºããç« ç«ã¦ã¨ãã¿ãè¦ãªãããã¿ããªã§ããããªã¬ã·ãã欲ãããã¨ãè²ã ãããããã¨ãè¨ã£ã¦æ¡ãåºãã¦ãã£ãã
Pragmatic Bookshelfã®æ¬ ãåºãããã©ã Ruby-GetText ã¨ã ã¹ãã¸ã§ã ã¨ããæ¥æ¬ãªãã§ã¯ã®è©±é¡ãçã沢山ãæ¨æºã®validationã»ããã¯æ¥æ¬ã«ãããéçºã®è¦æ±ã«å¿ããã«ã¯ã¾ã ä¸è¶³ã¨ãããæè¦ããã£ãã®ã§ããã®è¾ºãè¼ããããããªãã
Pragmatic Bookshelfã®æ¬ã¯AWDwRãèªãã§railsã使ã£ããã¨ãããããã層ãä¸å¿ã«å¿ç¨æãæããã®ã«å¯¾ãã¦ããã¡ãã®ã¬ã·ãã¯Rubyã«ã¤ãã¦ãããã¾ãç¥èã¯è¦æ±ãããwebéçºã®çµé¨ãããã¨ããããããã®ç¥èãåæã«ãrailsã®ãããããæããç´¹ä»ãã¦ããã
ç§ãããããè²ã è¨ããã¦ããã£ãããã©ãä¸ã§ãç¹ã«ãé¡ããããã®ã¯ãé«æ©ä¼é·ã®å®æ¼åçä»ãã æ£ãããã¼ãº ã§ã¹ãã·ã£ã«ã¸ã§ãã¬ã¼ã·ã§ã³ããã«ã¯ããã
Railsã¯ãã¬ã¼ã ã¯ã¼ã¯ãã«ãã¼ããé åãåºãããæ¯è¼ç使ã£ã¦ã層ã§ããã¯ãã®åå¼·ä¼å¸¸é£ã§ããä»ã®äººã®ã¬ã·ãææ¡ãèãã¦ãããç¥ããªãã£ããã¨ããã®ãçµæ§ãã£ããã¨ã¦ãåå¼·ã«ãªã£ããåºå¸è ãã¢ã¯ãã£ãã«çºè¨ãããã¦æéå ã§ã¯ã¤ã³ã¹ãã¼ã«ãã¸ã§ãã¬ã¼ã·ã§ã³ãActiveRecordã¾ã§ãããã§ãã¯ã§ãããæ®ãã¯æ親ä¼ã«ã¦è¡ã£ããå ¥éçã§ãããã¨ãé æ ®ããªãããé常ã«å 容ãæ¿ãã®ã§ãåºçã楽ãã¿ã§ããã
ä»ç§ã«åºçäºå®ã¨ãããã¨ãªã®ã§ãçããè²·ãã¾ããããåå¼·ä¼ï¼ æ±äº¬ã®ç¥æµãè©°ã¾ã£ã¦ãã¾ãã
ä»ã®ã»ãã·ã§ã³
Rails 1.1ã®æ°æ©è½
Cascades Eager Loadingãããããããpagenationã§ä½¿ãããrakeã³ãã³ããå¤ãã¤ãã追å ãããããããããã
AWDwR chap.2
訳ãç´ æ´ãããã¨ã声ã«åºãã¦èªã¿ããRailsã¨ãæ¬å½ã¯part 2ã®ã¤ããã§ææ¡ãããã®ã«ãééã£ã¦chap.2ã¨é¡ãã¦ãã¾ã£ãããã«ããçµãã£ã¦ãã¾ã£ããããã
å¾å
4ã¤ã®ã»ãã·ã§ã³ã«åãããã
- 俺ã¨ä¸ç·ã«Rails Recipe 28ãèªã¾ãªãã
- AWDwR chap. 20 (Action Web Service)ãèªãã
- Gruffã©ã¤ãã©ãªæ¯è¼
- RJSããã«ãããã
ç§ã¯ActionWebServiceã»ãã·ã§ã³ã®ãªã¼ãã¼ã«ãªã£ããæ°æ¥åã«çµãã£ãããã¸ã§ã¯ãã®æ¹ã§ãLLã«ããSOAPå®è£ ã®åè£ã¨ãã¦Railsã®ActionWebServiceãè©ä¾¡ããã ãã®ã¨ãã®ã¬ãã¼ã ãå ¬éãã¦ããã
å ±åã®ã¾ã¨ã
ã¾ããã¬ãã¼ããä¸æ·ã«ãã®ã¨ãã®è©ä¾¡çµæãå ±åãWebServiceã«ã¤ãã¦ãå®éã®éçºçµé¨ã¯ãªã人ãããã®ã§ããã®è¾ºã軽ãææããªããå ±åããã ä¸è¨ã¯ãã®å 容ãåè¿°ã®ã¬ãã¼ããä½µãã¦å¾¡è¦§ãã ããã
éçºè¦æ¨¡ã¨æéãã·ã¹ãã è² è·ããèãã¦LLãé¸æ
Perl5ãªããã¡ããCPANãè¦ã
- PHP5ãªãæ¨æºé¢æ°ã¨ãããããæãããã©ãé«æ©è½ãªã®ã¯PEARã®SOAP(beta)
Rubyã ã¨soap4r
ã§ãããããã¯åçåã®ãããåæ å ±ãè£ããªãã¨SOAPã«ãã¾ãè¼ããããªãã
ããããLLçéãããã¾ãXML好ãã§ãªãã®ãæä¼ã£ã¦ããã°ããããã¡ã
äºãã®çæããã¡ãã»ã¼ã¸ããã¼ã¹ã§ããªãã£ãããéäºææ§ããããAxisã«å¯¾ããäºææ§ã¯æèãã¦ãã¦ãLLå士ã¯ãã¾ãæèãã¦ããªãã®ããã
PEARã®SOAPã©ã¤ãã©ãªã¨ããã½ã¼ã¹ä»¥å¤ã«ã¾ã¨ããªããã¥ã¡ã³ããç¡ãã
WSDL ãæã§æ¸ãã®ã¯æ»ã¬ã
- ActionWebServiceã¯åè£è¶³ã®ããã«DSLãåãå ¥ãã¦ãæ¯è¼çç°¡åã«æ¸ããããã«ãªã£ã¦ããã
- ã¡ã½ããã³ã¼ã«ã®æ¹æ³ã¨ãã¦ã®SOAP/XML-RPCã¨å²ãåã£ã¦ãWSDLã®æè»æ§ããä½ããã¯ç«¯æãããã®å²ãåãã®ã»ã³ã¹ã«ãã£ã¦ãç¾å®ã®éçºã§ä½¿ãæããªã£ã¦ããã
WebServiceç¨ã®scaffoldã§ãèªåçæããããã©ã¼ã ã使ã£ã¦ãã©ã¦ã¶ããWebãµã¼ãã¹ãcallã§ããã®ã¯å¤§ããã
ããããrequest, resposne, return valueããããã«è¡¨ç¤ºããã
ããããAWDwR chap.20ãé ã«èªãã§ãã£ãã
- ActionWebServiceãç¥ãã¦AWS
- åä¸ã®ã³ã¼ãã§SOAP/XML-RPC両æ¹ããµãã¼ããããµã¼ãã¼ãæ¸ãã
- SOAP/XML-RPCã®å®å ¨ãªå®è£ ã§ã¯ãªããããã¾ã§ãããããã®ãããã³ã«ããã¡ã½ããã³ã¼ã«ãå¤é¨ã·ã¹ãã ã«å ¬éããæ段ã¨å²ãåã£ã¦ããã
- Apiã¯ã©ã¹å ã§ãDSLã£ã½ãå¤é¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®ç¾©
- Controllerã¾ãã¯å°ç¨ã®Serviceã¯ã©ã¹å ã§å¤é¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®è£
APIå®ç¾©DSLã®ä»çµã¿
åçåè¨èªã«ããã¦ãã©ããã£ã¦SOAPãªã©ã«å¿ è¦ãªåæ å ±ãææãããã¯åé¡ã§ããããActionWebServiceã§ã¯DSLã§è§£æ±ºããã
ä¸æãã®ã®APIï¼SOAPã§ããportã«å¯¾å¿ï¼ã¯ ActionWebService::API::Base
ã®ãµãã¯ã©ã¹ã§è¡¨ç¾ãããããã®ãµãã¯ã©ã¹ã®ä¸ã§ api_method
ã¯ã©ã¹ã¡ã½ãããå©ç¨ãã¦ã¡ã½ããåå®ç¾©ã宣è¨ããã
class HogeApi < ActiveRecord::API::Base api_method :foo api_method :bar end
ã¡ã½ããã®å¼æ°ãæ»ãå¤ãã®å㯠api_method
ã«ãªãã·ã§ã³ãä»ãã¦è¡¨ç¾ãããå©ç¨ã§ããåã¯æ¬¡ã®éã
- XSchemaã®åºæ¬ãã¼ã¿åã®ä¸é¨: ãããã¯AWSã®DSLå
ã§ã¯
:string
,:int
,:datetime
ã®ãããªã·ã³ãã«å¤ã§è¡¨ç¾ãã ActiveRecord::Base
ã®ãµãã¯ã©ã¹: ãããã¯DSLå ã§ã¯Class
ãªãã¸ã§ã¯ããã®ãã®ã§è¡¨ç¾ãã- æ§é åå: å©ç¨ã§ããåãã¡ã³ãã¼ã¨ããä»»æã«ãã¹ãå¯è½ãªæ§é ä½ã
ActionWebService::Struct
ãç¶æ¿ããClass
ãªãã¸ã§ã¯ãã§è¡¨ç¾ããã - é åå: å©ç¨ã§ããåãã¡ã³ãã¼ã¨ããé åãDSLå ã§ã¯å表è¨ãå¯ä¸ã®ã¡ã³ãã¼ã¨ãããããªé åã§è¡¨ç¾ãã
# æ´æ°è¨ç®API class CalcApi < ActiveRecord::API::Base # å ç® api_method :add, :expects => [:int, :int], :returns => [:int] # æ¸ç® api_method :sub, :expects => [:int, :int], :returns => [:int] # ç´æ°ãåæ api_method :divisors, :expects => [:int], :returns => [[:int]] end
Apiã¯ã©ã¹ã¯å¤é¨ã«APIå®ç¾©ã示ãã¨ããæå³ã§ãJavaã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã«è¿ãåå¨ã§ãããJavaã§æ¸ãã¨å¤§ä½ãããªã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨ç価ã§ããã
interface CalcApi { int add(int param1, int param2); int sub(int param1, int param2); int[] divisors(int param1); }
ããã§ãAWSã®APIå®ç¾©ã«ã¯ãã©ã¡ã¼ã¿åãå«ã¾ãã¦ããªããã¨ã«æ°ã¥ãããã©ã¡ã¼ã¿åãè¨å®ããã«ã¯åé
ã® Hash
ã使ãã
# æ´æ°è¨ç®API class CalcApi < ActiveRecord::API::Base # å ç® api_method :add, :expects => [{:lhs => :int}, {:rhs => :int}], :returns => [:int] # æ¸ç® api_method :sub, :expects => [{lhs => :int}, {:rhs => :int}], :returns => [:int] # ç´æ°ãåæ api_method :divisors, :expects => [{:base => :int}], :returns => [[:int]] end
ããã§ã次ã¨ç価ã¨ãªã
interface CalcApi { int add(int lhs, int rhs); int sub(int lhs, int rhs); int[] divisors(int base); }
è¨èªå ã«åå®ç¾©ã®å°ç¨èªå½ãæã¤éçåè¨èªã«æ¯ã¹ãã°ããããè½ã¡ãããããã§ãRubyã®DSLãçã¿åºãåãæ大éã«å¼ãåºãã¦ãåçåè¨èªã¨ãã¦ã¯æ¯è¼ç綺éºã«APIãå®ç¾©ã§ãã¦ããã¨æããå¢ãã¦WSDLãæã§æ¸ãã®ã«æ¯ã¹ãã°100å楽ã ã
ä¸ã®ä¾ã§ã¯æ§é ååãªã©ã使ã£ã¦ããªããã ActiveRecord::Base
ã®ãµãã¯ã©ã¹ãã¤ã¾ãã¨ããRailsã¢ããªã±ã¼ã·ã§ã³ã«ãããModelã¯ã©ã¹ããã®ã¾ã¾è¿ãå¤ã«ã§ããã®ã¯ä¾¿å©ã ãå
é¨ã¢ãã«ã¨APIå´ã®ãã¼ã¿æ§é ãæ¬è³ªçã«åä¸ã§ããå ´åããããã^ãè©°ãæ¿ãããããªãã¦æ¸ãã
Javaãªãå é¨ã¢ãã«ãããã¾ãã¾ãå¤é¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ã«è¡¨ããæ§é åã¨åçãªå ´åã§ããççµåæ§ãä¿ã¤ããã«å¥ã®interfaceãå®ç¾©ãããã¨ãæ¤è¨ããã ãããããããããã§åçåè¨èªã¨WebServiceã®å©ç¹ãæ´»ãã¦ãã¡ã³ãã¼æ§é ããä¿ã¦ã°ãããå®éã«ã©ãããåã§ãããã¯åé¡ã«ãªããªãã®ã§ï¼Duck typeã ãï¼ãModelã¯ã©ã¹ããã®ã¾ã¾å¤ã«åºãã¦ãçµåã¯å¯ã«ãªããªãããããRailsãå¯ãæ¯ã¨ãããã¬ã¼ã ã¯ã¼ã¯ã§ããå¤é¨ã·ã¹ãã ã¨å¯ãªã®ã¯ä¸è¬ã«ã¯å¬ãããªããã®ãã
AWDwRã«ã¯æè¨ãã¦ããªãã£ãæ°ãããããåæ²ã®ç§ã®ã¬ãã¼ãã«ããéãã ActiveRecord::Base
ã®ãµãã¯ã©ã¹ã¯å¼æ°ã«ã¯æå®ã§ããªããæå®ããã"ActiveRecord model classes not allowed in :expects"ã¨è¨ããããããã¯æ®å¿µã
generation
ä¸ã®ãããªAPIå®ç¾©ã®éåãä½ãããã®generatorãæ¨æºã§ç¨æããã¦ããã次ãå¼ã¶ã
$ script/generate web_service ApiName [method_name, ...]
ããã«ããã <var>ApiName</var>
Apiï¼APIå®ç¾©ã¯ã©ã¹ï¼ã <var>ApiName</var>
Controllerï¼APIå®è£
ã¯ã©ã¹ï¼ã <var>ApiName</var>
ApiTestï¼APIæ©è½ãã¹ãï¼ãçæãããã
$ script/generate web_service Calc add sub divisors => create app/apis exists test/functional create app/apis/calc_api.rb create app/controllers/calc_controller.rb create test/functional/calc_api_test.rb
çæããããã¨ã¯ã
- ã¡ã½ããå®ç¾©ã«
:expects
ã¨:returns
ãè¨å® - ã³ã³ããã¼ã©ã¼ã®ã¡ã½ããå®è£ ã«ãã対å¿ãããã©ã¡ã¼ã¿ãæå®
- ã¡ã½ããã®ä¸èº«ãå®è£
:expects
㨠:returns
ã®ã»ãã¯ããã ããã次ã«ãçæããã段éã§ã¯ CalcController
ã¯ãããªæããªã®ã§ã
class CalcController < ApplicationController wsdl_service_name 'Calc' def add end def sub end def divisors end end
ããã«ããã©ã¡ã¼ã¿ã足ãã¦å®è£ ããã
class CalcController < ApplicationController wsdl_service_name 'Calc' def add(lhs, rhs) lhs + rhs end def sub(lhs, rhs) lhs - rhs end def divisors(base) (1..Math.sqrt(base).to_i).inject([]) { |divs, candidate| div, mod = base.divmod(candidate) if mod == 0 divs << candidate divs << div unless div == candidate end divs } end end
ããã§ããã¾ãã§ããããã¤ã³ãã¯ããã©ã¡ã¼ã¿ã ActionController::Base#params
ã§ã¯ãªããæ®éã«åãåããã¨ã
scaffold
ç´ æ´ãããã®ã¯ãscaffoldæ©è½ã§ãããä¸ã®Controllerã¯ã©ã¹å®ç¾©ã«æ¬¡ã®å®£è¨ã足ãã
web_service_scaffold :invoke
:invoke
ã¨ããã®ã¯ä»»æã«æå®ã§ãããscaffoldç»é¢ã«ã¢ã¯ã»ã¹ããããã®actionåã§ãããããã§ã script/server ãèµ·åã㦠http://localhost:3000/calc/invoke ã«ã¢ã¯ã»ã¹ãã¦ã¿ããã
ã¡ã½ããã®ä¸è¦§ãã§ã§ãããããã¦ã試ãã«addã¡ã½ãããé¸æãã¦ã¿ãã¨ãã©ã¡ã¼ã¿ã®å ¥åãã©ã¼ã ãåºã§ããã
ãããsubmitããã¨request, resposneã®XMLãã³ãä»ãã§çµæã表示ãããã
çµæãé åã§ãåæ§ã
ãã¡ãããå®éã®éçºã§ã¯ãµãã³ã³ãã¼ãã³ãã®åä½ãã¹ããã¾ããã£ãããã£ã¦ãããªã®ã ããã©ãã§ãéçºãã¦ãAPIã試ããããæãã®GUIãããããã£ã¦åªã§æã«å ¥ãã®ã¯å¬ãããWebãµã¼ãã¹ãéçºããçµé¨ãããã° ãããã®ä½¿ã£ã¦ãæ ãããã ããã
ãã®scaffoldingã®ä»çµã¿ã¯ç´ç²ã«éçºä¸ã®ãã¹ãã®ããã®ãã®ãªã®ã§ãéç¨æã«ã¯web_service_scaffold宣è¨ãåã£ã¦å¤ãã¦ãã¾ãããã®ããããActionViewãªããã®ãã³ãã¬ã¼ãçæããã"scaffold"ã£ã¦ããæå³åããããæ確ã ãæ¬å½ã«æ§ç¯ä½æ¥ç¨ã®ãè¶³å ´ããªã®ãã
Dispatchingã¨ã
ä»ã¯ãControllerå ã«ãã¿ã«APIãå®è£ ãã¦ãã¾ã£ããã§ããã®æ¹æ³ã«ã¯ä¸ã¤åé¡ãããã1ã¤ã®web-serviceã¨ã³ããã¤ã³ãURLã«1ã¤ã®APIããé ç½®ã§ããªãã®ã ãRailsã®Routingã®ä»çµã¿ã§ã¯ã1ã¤ã®PATH_INFO componentã¯1ã¤ã®ã³ã³ããã¼ã©ã¼ã«ããããããããªãã¦ãä¸ã®ããããã§ã¯1ã¤ã®ã³ã³ããã¼ã©ã¼ã«ã¯1ã¤ã®APIããå®è£ ã§ããªãããã ã
ã¸ã§ãã¬ã¼ã¿ã¼ãããã©ã«ãã§çæããä¸ã®ãããªããããã¯"Direct dispatching mode"ã¨è¨ã£ã¦ãAWSãæä¾ãã3ã¤ã®ããããã®ãã¡ã®1ã¤ã§ããããã®ä»ã«"Layered Dispatching mode"ã¨"Delegated dispatching mode"ãããã
"Layered dispatching mode"ã§ã¯ã1ã¤ã®ã³ã³ããã¼ã©ã¼ã§è¤æ°ã®APIããµãã¼ãã§ãããå¤æ´ç¹ãã¹ãç¹ã¯ã
- ãµãã¼ãããããããã®APIã«ã¤ãã
ActionWebService::Base
ãç¶æ¿ããã¯ã©ã¹ãä½æãããã³ã³ããã¼ã©ã¼å ã§APIãå®è£ ãã代ããã«ããã®ã¯ã©ã¹ã§å®è£ ãæä¾ããã - ã³ã³ããã¼ã©ã¼ã¯ã©ã¹ã§"
web_service_dispatching_mode :layered
"ã宣è¨ãã - ã³ã³ããã¼ã©ã¼ã¯ã©ã¹ã§ãAPIåã¨
ActionWebService::Base
ã®å ·è±¡ã¤ã³ã¹ã¿ã³ã¹ã®å¯¾å¿ã宣è¨ããã
ä¾ãã°ãcontrollerã¯ã©ã¹ã
class CalcController < ApplicationController wsdl_service_name 'Calc' web_service_dispatching_mode :layaered web_service :calc, CalcService.new end
ã§ãserviceã¯ã©ã¹ã
class CalcService < ActionWebService::Base def add(lhs, rhs) lhs + rhs end def sub(lhs, rhs) lhs - rhs end def divisors(base) (1..Math.sqrt(base).to_i).inject([]) { |divs, candidate| div, mod = base.divmod(candidate) if mod == 0 divs << candidate divs << div unless div == candidate end divs } end end
é ç½®ã¨ã
- æ§é ä½åã®å®ç¾©ã¯ãããã¯APIã®ä¸é¨ã§ããã¨èã㦠app/apis ã®ä¸ãè¯ãã®ããªã
Serviceã¯ã©ã¹ã®å®ç¾©ã¯ãç§ã¯controllerã«è¿ãåå¨ã ã¨æãããï¼ãã¨ãgeneratorãä½ã£ãcontrollerã®ãã¡ã¤ã«ãã³ãã¼ãã¦æ¸ããã®ã§ï¼ app/controllers ã«ç½®ãã®ãããããããªããã¨æãã
app/services ã£ã¦ããã®ãä½ã£ã¦
$LOAD_PATH
ã«è¿½å ããã®ãã¢ãªã§ã¯ãªããã¨ããæè¦ã
å ¬éã¨ã
ä¸ã®ä¾ã§ã http://localhost:3000/calc/service.wsdl ã«ã¢ã¯ã»ã¹ããã°SOAPç¨ã®WSDLãæã«å ¥ãã çæããããã® ãè¦ã¦ã¿ã¦ã»ããããããæã§æ¸ãã¨å¤§å¤ã ããã©ãDSLã®åã§ä¸ã®APIå®ç¾©ã ãã§çæãããã®ã ã
XML-RPCã®å ´å㯠http://localhost:3000/calc/api ãã¨ã³ããã¤ã³ãã¨ãªãã
ãã¹ãã®èªååã¨ã
AWSã®ãã¹ãããµãã¼ãããæ©è½ããã£ããæä¾ããã¦ãã¦ãgeneratorã§web_serviceãçæããæã«ã¯ãã¹ãã±ã¼ã¹ã®ã¹ã±ã«ãã³ãçæãããã
controllerã®ãã¹ãã§getãpostãå¼ãã§ã¢ã¯ã·ã§ã³ã®ã®æåããã¹ãã§ããããã«ããã¹ãã±ã¼ã¹å ã§invokeã¨ããã¡ã½ãããå¼ã¶ãã¨ã§å ¬éãããã¡ã½ããã®æåããã¹ãã§ããã
ã¯ã©ã¤ã¢ã³ãæ©è½ã¨ã
ä¸å¿ãAWSã«ãã¯ã©ã¤ã¢ã³ãæ©è½ã¯ããã ActionWebService::Client::Soap
㨠ActionWebService::Client::XmlRpc
ã ããããã new
ã«APIå®ç¾©ã¯ã©ã¹ã渡ããªãã¨ãããªããã¤ã¾ããå¤é¨ã·ã¹ãã ã®ã¤ã³ã¿ã¼ãã§ã¼ã¹å®ç¾©ãAWSã®DSLå½¢å¼ã«å¤æããªãã¨ç解ãã¦ãããªãã®ã ãå¤é¨ã·ã¹ãã ã®ããã«ããããAPIå®ç¾©ãæ¸ãä¸ãã®ã¯é¢åãªã®ã§ããã®ç¹ã ãã¯soap4rã®æ¹ã便å©ããã«æããã
AWSã®ã¯ã©ã¤ã¢ã³ãæ©è½ã¯Railså士ãWeb serviceã§ã¤ãªãå ´åã®ãããã¨ãããã¨ã ãããï¼
script/generate wsdl2api ãã§ãã¦ãããã®ã«ããã¨ãã御æè¦ãããããã£ã¨ããsoap4rã®wsdl2ruby.rbã®ã©ããã¼ã§ããããããgeneratorã欲ããã
ãã£ã¦ã¿ã
ãããªæãã§ãã¿ããªã§å®éã«AWSã試ãã¦ã¿ãã
- scaffoldã®ãã¯ã¼ã«æåããã
- Calcãä½ã£ã¦ã¿ãã
web serviceæªçµé¨ã ã£ã人ããæ¢åã®railsã¢ããªã±ã¼ã·ã§ã³ã®æ©è½ã20åã§Webãµã¼ãã¹ã¨ãã¦å ¬éã§ããã
é§ åæ¤ç´¢APIåãã
- AWSãæµè¡ãããã°æç¨ãªAPIãã©ãã©ãå ¬éãããäºæ
çµè«
Rails使ãã®çãããåãã¦scaffold generatorã使ã£ã¦ã¿ãã¨ããåãã¦ã¹ãã¸ã§ãã使ã£ã¦ã¿ãã¨ããåãã¦è²ã¤ããã°ãè¦ãæã®ãã®æ°æã¡ãæãåºãã¦ãã ããã
- ããããããã
- ãããã¾ã§ããããã¢ãã¡ãããã
- ããããã®ã¤ãã£ã¦ããã
- ãã®æ°æã¡ãWebServiceã®ä¸çã§ä»ä¸åº¦å³ããã¾ãã
大è¦æ¨¡éçºãªãSOAPå¨ããå å®ãã¦ãããJavaãï¼C++ãï¼ASP.NETãç¾å®çã§ããããã§ããä¸å°è¦æ¨¡ã®Web Serviceéçºãã¢ã¸ã£ã¤ã«ã«ãããªãActionWebServiceã§ãããã
ä»ã®ã»ãã·ã§ã³
俺ã¨ä¸ç·ã«Recipe28ãèªã¾ãªãã
ãããã«ããã®ã»ãã·ã§ã³ãPragmatic Bookshelfã®ã»ãã®Rails Recipesã®Î²çãèªãã ããããã¬ã·ããå¢ããããããããã«ããã®æ³å®ãã¦ããã¬ã·ãã¯å½æ¥ã®ææ°ãã¼ã¸ã§ã³ã§ã¯recipe 43ã«ãªã£ã¦ããã¨ãã
Rails 1.1ã§å°å ¥ãããintegration testã¯ããããã
- unit testã¯modelã¯ã©ã¹ãããã ãã§ãã¹ãããã
- functional testã¯controllerãç´æ¥å¼ã³åºããã¨ã§controllerãmodelãã³ã³ããã¼ã«ããæ§åããã¹ãããã
- integrationãã¹ãã¯ãRoutingã¾ã§å«ããRailsãã¬ã¼ã ã¯ã¼ã¯å ¨ä½ã®æåãå¼ã³åºãã¦ãcontrollerãã¾ããã£ãå¦çãã»ãã·ã§ã³ã®ç¶æ ã«ä¾åããå¦çããã¹ããã
ããããIntegration testã®ãã¹ãã±ã¼ã¹ã¯ãã»ã¨ãã©è±æãèªãã§ãããã®ãããªèªç¶ãªDSLã§æ¸ããããããã Bob.login.as.administrator
ã¨ãã
Gruffã©ã¤ãã©ãª
ãªã¼ãã¼ã¯ããã¯ããããã ã£ãããª?
GruffããRMagicããCSS-graphãããããããé¢ç½ãããªã°ã©ãã©ã¤ãã©ãªãæ¯è¼ãã¦ãRailsã§å©ç¨ãããã¨ãæ¤è¨ããããããéä¸ã§ããã ãããä¹±å ¥ãã¦çãä¸ãã£ãã¨ãã
RJSããã«ãããã
ååã®RJSã»ãã·ã§ã³ãå¼ãç¶ãã§ããã«è©³ããããããã
- RJSã¯ãRubyã³ã¼ããæ¸ãã¨JavaScriptãçæãã¦ããã®ã¹ã¯ãªãããDOMãéãã¦ãã©ã¦ã¶ã®ç»é¢ãããããä»çµã¿ã
- RJSã使ã£ããã¼ã¸ã®æåã調ã¹ãã«ã¯ãJavaScriptãå¼ã£ãå¾ã®ã½ã¼ã¹ãè¦ãããªãã¨ä¸ä¾¿ããã®ããã«ã¯Firefoxã®View generated sourceãã©ã°ã¤ã³ã便å©ããããã
view generated sourceã£ã¦ã©ãã ããï¼ãaddons.mozilla.orgãgoogleã§ã¯è¦ä»ãããªãã£ããã ãã©ã ãã®ããã¯ãã¼ã¯ã¬ãã ã ãããã
æ親ä¼=å®´ä¼
ä¸æ¬¡ä¼ã§ã¯ãæ¨ä»Rubyistãéã¾ãã°å¿ ãå§ã¾ãHaskell話ã¨ããã¬ã·ãæ¬ãã¿åºãã®ç¶ãã¨ããããè¨æ¶ããããäºæ¬¡ä¼ã®è¨æ¶ãã»ã¨ãã©ãªãã®ã¯ä½æ ã ããããããªã«é£²ãã§ãªãã®ã«ã
å
¥éHaskell ãèªãã§ãããããæ°å¦æ¦å¿µã¨Haskellã®æ¦å¿µããã£ããçµã³ä»ããã <-
ãâã®ãã¨ã ã¨åãã£ã¦ã¾ããã£ãããããã¯ã©ã¹ã¯ãã®ã¾ã¾ã¯ã©ã¹ã§è¯ããããã¢ããã¯ãã®ã¾ã¾ã¢ããã§ãããããã§ããã¢ããå¾ãã©ããã£ã¦IOã®æåã«çµã³ä»ãã®ãããåãã£ã¦ãªãã£ãããã®è¾ºããã£ãããããæ°å¦ã®ä¸çã¾ã§ãã£ã¦ããã°ããã¨ã¯ãã¼ã ã°ã©ã¦ã³ãã ã
ã¨ãããããªè©±ãããããRailsã§20åã§Wikiãä½ã£ã¦ãã¾ã£ãæ¹ã®è©±ãèãã¦ã³ã£ãããããã
ããã ããã«ããã±ãã¾ãã®ç¶ããã¼ãã¬ãã¨è¨ã£ããããããªæãããããªããã¨è¨ãããã