• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
14th Tue

Endless Ruby

HAMLを使うようになってから、endの無いrubyが欲しい今日この頃。 あわや自作する直前、先人の仕事を見つけました。

[ANN] Endless Ruby 0.0.2

endless.rb is a pre-processor for ruby which allows you to use python-ish indentation to delimit scopes, instead of having to type 'end' every time.

良いですね。残念ながら、現時点ではrubylexerのrequireでエラーが出るようですが、一定の制約付きでもかまわないので動くようになるとありがたいです。 JRubyのCharles Nutterも割と 肯定的なコメント を寄せていますね。

Oh dear god no!

Seriously though...neat :)

-- Charlie

JRubyのオプションに--endlessがつく?

posted by Png genki on Tue 14 Jul 2009 at 17:41

Merbの開発がなかなか進展しないのでSinatraをちょっと触ってみたところ、 DataMapper、Herokuとの組み合わせが非常に簡単でいい感じでした。

blog.rb

   1  require "rubygems"
   2  require "sinatra"
   3  require "dm-core"
   4  require "haml"
   5  
   6  DataMapper::setup(:default, ENV['DATABASE_URL'] || 'sqlite3:db.sqlite3')
   7  
   8  class Post
   9    include DataMapper::Resource
  10    property :id, Serial
  11    property :content, Text
  12    auto_upgrade!
  13  end
  14  
  15  get "/" do
  16    @posts = Post.all(:order => [:id.desc])
  17    haml :index
  18  end
  19  
  20  post "/" do
  21    Post.create(params)
  22    redirect "/"
  23  end
  24  
  25  __END__
  26  @@ index
  27  %h1 Hello, Sinatra!
  28  %ul
  29    - @posts.each do |post|
  30      %li= post.content
  31  %form{:method => :post}
  32    %textarea{:name => :content}
  33    %input{:type => :submit, :value => "Post"}

config.ru

   1  require "blog.rb"
   2  run Sinatra::Application

ローカルで起動するには

   1  % ruby blog.rb

もしくは

   1  % rack

でok. rubyの場合はhttp://localhost:4567、Rackの場合は http://localhost:9292 にアクセス。

これをHerokuにデプロイすると、 http://sinatora-blog.heroku.com/ こんな感じで動きます。

posted by Png genki on Tue 14 Jul 2009 at 15:37 with 2 comments
Contents
Endless Ruby
Sinatra+DataMapper+Heroku
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ