medellinrb / ruby_dsl

Ruby DSL's talk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Domain-Specific Language’s in Ruby

Resources for Ruby DSL talk

Slides

Domain Specific Languages in Ruby + Code Kata

Ruby DSL Fundamtentals

Check Blocks, Procs and Lambdas

Live coding demo, Router

Check router_dsl.rb files for a Rails-like router DSL

Rotator.new.map do
  resources :items
  get "/about_us/" => "pages#about_us"
  post "/products/" => "products#create"
end

Code Kata

Our goal is to create an HTML Markup DSL based on todays talk, (you can take router example as reference)

markup = FancyMarkup.new

markup.document do
  body do
    div id: 'container', class: 'kool' do
      list class: 'pretty' do
        item "item 1"
        item "item 2"
      end
    end
  end
end

markup.to_html
#=>
"<html>
  <body>
    <div id="container", class= "kool">
      <ul class="pretty">
        <li>item 1</li>
        <li>item 2</li>
      </ul>
    </div>
  </body>
</html>"

Fork and submit your solutions via Github Pull Request

About

Ruby DSL's talk


Languages

Language:Ruby 100.0%