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

Reinvesting in Ruby

Tim Riley
February 09, 2017

Reinvesting in Ruby

As our community matures, and technology evolves around us, how can we ensure Ruby remains vital?

Opening keynote, RubyConf AU 2017

Tim Riley

February 09, 2017
Tweet

More Decks by Tim Riley

Other Decks in Technology

Transcript

  1. Rails 1.0: Party like it's one oh oh! Posted by

    David December 13, 2005 @ 09:02 PM
  2. Ruby 2.4.0 released (ruby-lang.org) 1. Android adopts JRuby: “It’s Java

    without the Java” (android.com) 2. Why Atom chose Ruby (atom.io) 3. Rubocop saved my life (medium.com) 4.
  3. rails new rails new rails new rails new rails new

    rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new rails new
  4. @timriley I have just realised I do not remember the

    last ruby I wrote — @johnbarton
  5. # Initialize once create_article = CreateArticle.new(repo) # Reuse many times

    create_article.(title: "Hello Melbourne") create_article.(title: "Hello World!”)
  6. # Initialize once create_article = CreateArticle.new(repo) # Reuse many times

    create_article.(title: "Hello Melbourne") create_article.(title: "Hello World!”)
  7. . ├── Gemfile ├── README.md ├── Rakefile ├── apps │

    └── main │ ├── lib │ │ └── main │ │ └── views │ │ └── welcome.rb │ ├── system │ │ ├── boot │ │ │ └── view.rb │ │ ├── boot.rb │ │ └── main │ │ ├── application.rb │ │ ├── container.rb │ │ ├── import.rb │ │ ├── transactions.rb │ │ ├── view_context.rb │ │ └── view_controller.rb
  8. class Index < Blog::ViewController configure do |config| config.template = "articles/index"

    end include Blog::Import[repo: "blog.repositories.articles"] expose :articles do repository.listing end end
  9. class Index < Blog::ViewController configure do |config| config.template = "articles/index"

    end include Blog::Import[repo: "repositories.articles"] expose :articles do repository.listing end end
  10. class Index < Blog::ViewController configure do |config| config.template = "articles/index"

    end include Blog::Import[repo: "repositories.articles"] expose :articles do repo.listing end end
  11. ol - articles.each do |article| li = article.title r.view “articles.index”

    <ol> <li>Hello Melbourne</li> <li>Hello World</li> </ol>
  12. ol - articles.each do |article| li = article.title r.view "articles.index"

    <ol> <li>Hello Melbourne</li> <li>Hello World</li> </ol>
  13. ol - articles.each do |article| li = article.title r.view "articles.index"

    <ol> <li>Hello Melbourne</li> <li>Hello World</li> </ol>
  14. ol - articles.each do |article| li = article.title r.view "articles.index"

    <ol> <li>Hello Melbourne</li> <li>Hello World</li> </ol>
  15. Routing & HTTP dry-web-roda Object dependency management dry-system & dry-auto_inject

    Views dry-view Data modelling dry-types & dry-struct 1 2 3 4
  16. class MyApp < Dry::Web::Roda::Application route do |r| r.get "articles" do

    r.view "articles.index" end r.post "articles" do r.resolve "operations.create_article" do |create| create.(r[:article]) end end end end
  17. class MyApp < Dry::Web::Roda::Application route do |r| r.get "articles" do

    r.view "articles.index" end r.post "articles" do r.resolve "operations.create_article" do |create| create.(r[:article]) end end end end
  18. class MyApp < Dry::Web::Roda::Application route do |r| r.get "articles" do

    r.view "articles.index" end r.post "articles" do r.resolve "operations.create_article" do |create| create.(r[:article]) end end end end
  19. class MyApp < Dry::Web::Roda::Application route do |r| r.get "articles" do

    r.view "articles.index" end r.post "articles" do r.resolve "operations.create_article" do |create| create.(r[:article]) end end end end
  20. input = { "title" => "Hello Melbourne", "body" => "Why

    I always forget my umbrella", "published" => "1", "published_at" => "2017-02-09 09:50" } ArticleSchema.(input).to_h { title: "Hello Melbourne", body: "Why I always forget my umbrella" published: true, published_at: 2017-02-09 09:50:00 +1100 }
  21. input = { "title" => "Hello Melbourne", "body" => "Why

    I always forget my umbrella", "published" => "1", "published_at" => "2017-02-09 09:50" } ArticleSchema.(input).to_h { title: "Hello Melbourne", body: "Why I always forget my umbrella" published: true, published_at: 2017-02-09 09:50:00 +1100 }
  22. input = { "title" => "Hello Melbourne", "body" => "Why

    I always forget my umbrella", "published" => "1", "published_at" => "2017-02-09 09:50" } ArticleSchema.(input).to_h { title: "Hello Melbourne", body: "Why I always forget my umbrella" published: true, published_at: 2017-02-09 09:50:00 +1100 }
  23. input = { "title" => "Hello Melbourne", "body" => "Why

    I always forget my umbrella", "published" => "1", "published_at" => "2017-02-09 09:50" } ArticleSchema.(input).to_h { title: "Hello Melbourne", body: "Why I always forget my umbrella" published: true, published_at: 2017-02-09 09:50:00 +1100 }
  24. input = { "title" => "Hello Melbourne", "body" => "Why

    I always forget my umbrella", "published" => "1", "published_at" => "2017-02-09 09:50" } ArticleSchema.(input).to_h { title: "Hello Melbourne", body: "Why I always forget my umbrella" published: true, published_at: 2017-02-09 09:50:00 +1100 }
  25. ArticleSchema.("published" => "1").messages { :title => [ "is missing", "size

    cannot be less than 3"], :body => ["is missing"], :published_at => ["is missing"] }
  26. ArticleSchema.("published" => "1").messages { :title => [ "is missing", "size

    cannot be less than 3"], :body => ["is missing"], :published_at => ["is missing"] }
  27. class CreateArticle include Blog::Import[repo: "repositories.articles"] def call(input) validation = Validation::ArticleSchema.(input)

    if validation.success? result = repo.create(validation) Article.new(result) end end end
  28. r.post do r.resolve "operations.create_article" do |create| create.(r[:article]) m.success do r.redirect

    "/articles" end m.failure do |validation| r.view "articles.new", validation: validation end end end end
  29. r.post do r.resolve "operations.create_article" do |create| create.(r[:article]) do |m| m.success

    do r.redirect "/articles" end m.failure do |validation| r.view "articles.new", validation: validation end end end end
  30. r.post do r.resolve "operations.create_article" do |create| create.(r[:article]) do |m| m.success

    do r.redirect "/articles" end m.failure do |validation| r.view "articles.new", validation: validation end end end end
  31. r.post do r.resolve "operations.create_article" do |create| create.(r[:article]) do |m| m.success

    do r.redirect "/articles" end m.failure do |validation| r.view "articles.new", validation: validation end end end end
  32. r.post do r.resolve "operations.create_article" do |create| create.(r[:article]) do |m| m.success

    do r.redirect "/articles" end m.failure do |validation| r.view "articles.new", validation: validation end end end end
  33. create_article.(r[:article]) do |m| m.success do r.redirect "/articles" end m.failure :create

    do |errors| r.view "articles.new", validation: errors end m.failure :notify do |error| # ... end end
  34. create_article.(r[:article]) do |m| m.success do r.redirect "/articles" end m.failure :create

    do |errors| r.view "articles.new", validation: errors end m.failure :notify do |error| # ... end end
  35. create_article.(r[:article]) do |m| m.success do r.redirect "/articles" end m.failure :create

    do |errors| r.view "articles.new", validation: errors end m.failure :notify do |error| # ... end end
  36. create_article.(r[:article]) do |m| m.success do r.redirect "/articles" end m.failure :create

    do |errors| r.view "articles.new", validation: errors end m.failure :notify do |error| # ... end end
  37. Let's say every company gets three innovation tokens. You can

    spend these however you want, but the supply is fixed. — Dan McKinley