[ruby] Merb ã使ã£ã¦ã¿ã -1
gem install ãã¦ã¿ã㨠merb 0.5.3ããã㯠0.9 ç³»ã使ãããã®ã§ git head ããã¤ã³ã¹ãã¼ã«ããã
ï¼change log ãè¦ã㨠0.5.3 ã®æ¬¡ã 0.9.0ï¼
OSX Tiger + ruby 1.8.6 + MacPorts ã§ã¤ã³ã¹ãã¼ã«ã¯æ»ãç¡ãå®äºã
éä¸ã¨ã©ã¼ãåºãå ´åã¯ã©ã¤ãã©ãªã gem ã®æç¡ãçããglib2ç¡ãã¨ããrspecç¡ãã¨ãã
ã¢ããªãæ¸ãã
åç §
datamapper, mock
init.rb ã触ãã
use_orm :datamapper use_test :test_unit use_test :rspec
rake ã« db: ç³»ã®ã¿ã¹ã¯ã追å ãããã
merb
ãå®è¡ãã㨠database.yml ã®ãµã³ãã«ãçæãããã
ãã® config/database.yml.sample ãæ¸ãæãã¦
# This is a sample database file for the DataMapper ORM :development: &defaults :adapter: sqlite3 :database: db/development.sqlite3 :host: localhost # :username: the_user # :password: secrets :test: <<: *defaults :database: db/test.sqlite3
ããä¸åº¦ merb ãå®è¡ãããä»åº¦ã¯éã£ãã
merb-gen merb-gen resource --help
ãå©ã㦠merb-gen ã§ä½ãåºæ¥ããã確èªã
Article ã«å¯¾å¿ãã model/controller ãæ¸ãã¦ã¿ããã
merb-gen resource article
spec ãåºæ¥ãã®ã§ autotest ãèµ°ãããã
model ããæ¸ãã¦ããã
article_spec.rb
describe Article do before(:each) do @article = Article.new end it { @article.should respond_to(:title) } it { @article.should respond_to(:body)} end
article.rb
class Article < DataMapper::Base property :title, :string property :body, :text end
ï¼ã¤ã¥ãï¼