Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hobbit (English)

794f638b6f7f5132d5a13230e61c9db2?s=47 Krzysztof Wawer
July 23, 2014
250

Hobbit (English)

Prese

794f638b6f7f5132d5a13230e61c9db2?s=128

Krzysztof Wawer

July 23, 2014
Tweet

Transcript

  1. Building web application in Ruby Hobbit

  2. About me Christopher Wawer! krzysztof.wawer@gmail.com! Github: wafcio! ! Neubloc Poland

  3. Ruby on Rails Web Server Ruby on Rails Our application

  4. Ruby on Rails Web Server Ruby on Rails Our application

    Rack
  5. Ruby on Rails - zależności rails actionmailer (4.1.4 - 62

    112 B) mail actionpack (4.1.4 - 651 917 B) AbstractController, ActionController, ActionDispatch rack rack-test actionview (4.1.4 - 624 372 B) builder erubis activemodel (4.1.4 - 159 322 B) builder activerecord (4.1.4 - 1 143 044 B) arel ! activesupport (4.1.4 - 1 475 624 B) cache, core_ext, json, multibyte, notification, number conversions i18n jon minitest thread_safe tzinfo bundler railties (4.1.4 - 368 897 B) rake thor sprockets-rails SUM 4 485 298 B ~ 4,28 MB
  6. Ruby on Rails Convention over Configuration! ! Creator => Performer

  7. Ruby on Rails ??? Do we really understand RoR source

    code ?
  8. Ruby on Rails ??? Can we use RoR in optimal

    way ?
  9. Ruby on Rails ??? Maybe something we don’t like in

    RoR ?
  10. Ruby off Rails Web Server Ruby on Rails Our application

    Rack
  11. Ruby off Rails Micro Libraries! Piotr Solnica: https://www.youtube.com/ watch?v=urUEB8Kz6jY! Use

    only what you need! Better performance
  12. Rack Rack Web Serwer Our application https://github.com/rack/rack

  13. Rack Application require 'rack' ! class HelloWorld def call(env) [200,

    {'Content-Type' => 'text/plain'}, 'Hello World!'] end end ! run HelloWorld.new
  14. Rack Rack Web Server Our application https://github.com/rack/rack Lightweight framework

  15. Some frameworks Brooklyn, Cuba, Hobbit, Lotus, Nancy, NYNY, Mustermann, Ramaze,

    Rambutan, Scorched, Sinatra! https://github.com/luislavena/bench-micro! ! Cuba, Hobbit, Jellyfish, Sinatra, Substation, Subway! http://microrb.com/#framework!
  16. Hobbit Patricio Mac Adden patriciomacadden@gmail.com Github: patriciomacadden ! First commit:

    11 IV 2013
  17. Hobbit first name: bonsai, but … ! must be fast

    very simple, only routes extendable no configuration ! http://www.sitepoint.com/ruby-microframeworks-round/
  18. hobbit - source https://github.com/patriciomacadden/hobbit v0.6.0, 12 VI 2014 - 9

    239 B ~ 9,02 KB hobbit.rb - 4 lines hobbit/base.rb - 93 lines hobbit/request.rb - 10 lines hobbit/response.rb - 40 lines Sum: 147 lines
  19. Hello World require 'hobbit' ! class HelloWorld < Hobbit::Base get

    '/' do 'Hello World!' end end ! run HelloWorld.new
  20. hobbit-contrib - source https://github.com/patriciomacadden/hobbit-contrib v0.7.0, 10 VII 2014 - 5

    280 B ~ 5,16 KB hobbit/contrib.rb - 13 lines hobbit/environment.rb - 15 lines hobbit/error_handling.rb - 27 lines hobbit/filter.rb - 73 lines hobbit/mote.rb - 42 lines hobbit/render.rb - 55 lines hobbit/session.rb - 7 lines Sum: 232 lines
  21. hobbit-contrib - source https://github.com/patriciomacadden/hobbit-contrib environment.rb - development?, production? error_handling.rb -

    catch exceptions filter.rb - after, before mote.rb - render views with Mote render.rb - render views with Tilt session.rb - easy access to session
  22. HTML view require 'hobbit' require 'hobbit/render' require 'tilt/haml' ! class

    HelloWorld < Hobbit::Base def template_engine 'haml' end ! get '/' do render 'index', {}, layout: false end end ! run HelloWorld.new
  23. When something missing ? Rack gems Sinatra gems activesupport ???

  24. Hobbit - attacks no protection against web attacks use: https://github.com/rkh/rack-protection

    Cross Site Request Forgery Cross Site Scripting Clickjacking Directory Traversal Session Hijacking IP Spoofing
  25. Hobbit Application Template https://github.com/patriciomacadden/hat i18n tilt sprockets better_errors rake rack-test,

    minitest
  26. Asset precompilation require 'rake/sprocketstask' require 'uglifier' ! Rake::SprocketsTask.new do |t|

    environment = Sprockets::Environment.new environment.append_path(…) environment.js_compressor = :uglify environment.css_compressor = :scss ! t.environment = environment t.manifest = Sprockets::Manifest.new(environment, "public/assets/manifest.json") ! t.output = 'public/assets' t.assets = %w(application.js application.css) end rake assets # Compile assets ! rake clean_assets # Clean old assets ! rake clobber_assets # Remove all assembler
  27. Sample application Based on https://github.com/ryant523/blog haml sass rake sequel pony

  28. Thank you Questions ???