Monk

14
Monk, a ragasztó Bácsi László, lackac.hu na meg ruby.meetup.hu ;) 2009. szeptember 17.

description

Presentation given on the 2009 September meetup of budapest.rb about the Monk glue framework. The language is Hungarian.

Transcript of Monk

Page 1: Monk

Monk, a ragasztóBácsi László, lackac.hu

na meg ruby.meetup.hu ;)

2009. szeptember 17.

Page 2: Monk

Monk, a ragasztó

“Monk is a glue framework for web development in Ruby. It’s truly modular by relying on the best tool for each job. It’s also pretty fast thanks to Rack and Sinatra.”

2009. szeptember 17.

Page 3: Monk

Tehát a Monk igazából Sinatra?

Sinatra

Contest

Rack::Test

Webrat

Ohm (Redis)

logger, settings hash, development reloading2009. szeptember 17.

Page 4: Monk

Kezdeti lépések

$ sudo gem install monk

$ monk init myapp

git://github.com/monkrb/skeleton.rb

2009. szeptember 17.

Page 5: Monk

Felépítés

./app

./app/helpers

./app/models

./app/routes

./app/views

./config

./lib

./vendor

etc.

2009. szeptember 17.

Page 6: Monk

1 class Main 2 get "/" do 3 haml :home 4 end 5 6 ... 7 end

Routes

2009. szeptember 17.

Page 7: Monk

Views

Haml, Sass

= partial :games, :players => @players

2009. szeptember 17.

Page 8: Monk

Models

Ohm (Redis)

1 class Player < Ohm::Model 2 attribute :name 3 set :nicknames 4 list Games 5 counter :wins 6 7 index :name 8 9 def validate10 assert_present :name11 end12 end

2009. szeptember 17.

Page 9: Monk

1 >> require "ohm" 2 => true 3 >> Ohm.connect 4 => [] 5 >> Ohm.redis.set "Foo", "Bar" 6 => "OK" 7 >> Ohm.redis.get "Foo" 8 => "Bar"

Ohm

1 player = Players.create :name => "Michael Jordan" 2 player.id 3 # => 1 4 5 # Find a player by id 6 player == Player[1] 7 # => true 8 9 # Trying to find a non existent player10 Player[2]11 # => nil

2009. szeptember 17.

Page 10: Monk

1 class Main 2 helpers do 3 def my_helper 4 ... 5 end 6 7 ... 8 end 9 end

Helpers

2009. szeptember 17.

Page 11: Monk

haml 2.2.3 git://github.com/nex3/haml.gitohm 0.0.19 git://github.com/soveran/ohm.git

Dependencies

$ dep vendor --allvendor|-- sinatra-0.9.4`-- haml-2.2.2...

2009. szeptember 17.

Page 12: Monk

$ monk list default git://github.com/monkrb/skeleton.git$ monk add compass git://github.com/lackac/skeleton.git$ monk list default git://github.com/monkrb/skeleton.git compass git://github.com/lackac/skeleton.git

Skeletons

2009. szeptember 17.

Page 13: Monk

Directory

2009. szeptember 17.

Page 14: Monk

Demó, kérdések...

http://monkrb.com/

http://ohm.keyvalue.org/

http://github.com/lackac/skeleton/

http://lackac.hu/

2009. szeptember 17.