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

Hobbit (English)

Krzysztof Wawer
July 23, 2014
520

Hobbit (English)

Prese

Krzysztof Wawer

July 23, 2014
Tweet

Transcript

  1. 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
  2. Rack Application require 'rack' ! class HelloWorld def call(env) [200,

    {'Content-Type' => 'text/plain'}, 'Hello World!'] end end ! run HelloWorld.new
  3. 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!
  4. Hobbit first name: bonsai, but … ! must be fast

    very simple, only routes extendable no configuration ! http://www.sitepoint.com/ruby-microframeworks-round/
  5. 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
  6. Hello World require 'hobbit' ! class HelloWorld < Hobbit::Base get

    '/' do 'Hello World!' end end ! run HelloWorld.new
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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