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

Hobbit

Krzysztof Wawer
July 23, 2014
540

 Hobbit

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, notyfikacje, konwersja liczb i18n jon minitest thread_safe tzinfo bundler railties (4.1.4 - 368 897 B) rake thor sprockets-rails RAZEM 4 485 298 B ~ 4,28 MB
  2. Aplikacja Rack require 'rack' ! class HelloWorld def call(env) [200,

    {'Content-Type' => 'text/plain'}, 'Hello World!'] end end ! run HelloWorld.new
  3. Niektóre frameworki 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 pierwsza nazwa: bonsai, ale … ! musi być szybki

    bardzo prosty, tylko routing rozszerzalny zero konfiguracji ! http://www.sitepoint.com/ruby-microframeworks-round/
  5. hobbit - źródło https://github.com/patriciomacadden/hobbit v0.6.0, 12 VI 2014 - 9

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

    '/' do 'Hello World!' end end ! run HelloWorld.new
  7. hobbit-contrib - źródło https://github.com/patriciomacadden/hobbit-contrib v0.7.0, 10 VII 2014 - 5

    280 B ~ 5,16 KB hobbit/contrib.rb - 13 linii hobbit/environment.rb - 15 linii hobbit/error_handling.rb - 27 linii hobbit/filter.rb - 73 linii hobbit/mote.rb - 42 linii hobbit/render.rb - 55 linii hobbit/session.rb - 7 linii Razem: 232 linii
  8. hobbit-contrib - źródło https://github.com/patriciomacadden/hobbit-contrib environment.rb - development?, production? error_handling.rb -

    chwyta wyjątki filter.rb - after, before mote.rb - renderuje widoki przy użyciu Mote render.rb - renderuje widoki przy użyciu Tilt session.rb - łatwy dostęp do zmiennych zapisanych w sesji
  9. Format HTML 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 - ataki brak obrony przed atakami zalecane wykorzystanie: https://github.com/rkh/rack-protection

    Cross Site Request Forgery Cross Site Scripting Clickjacking Directory Traversal Session Hijacking IP Spoofing
  11. Prekompilacja assetów 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