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

Ruby & we

871fc089cd3cbbc18b9f868c8dd85cce?s=47 Olivier Lacan
February 11, 2016

Ruby & we

How contributing to community projects like rubygems.org can help you overcome your fears and become a better Ruby developer.

Video of the talk is available here: https://vimeo.com/155107107

871fc089cd3cbbc18b9f868c8dd85cce?s=128

Olivier Lacan

February 11, 2016
Tweet

Transcript

  1. Ruby & we

  2. Why do we care?

  3. How do we care?

  4. Where can we help?

  5. Where do we start?

  6. Problem 1

  7. None
  8. 1 result?

  9. Then show me the result!

  10. None
  11. ~ interlude ~

  12. Excuses

  13. “What if nobody cares?”

  14. If you care, somebody else probably does too.

  15. “What if they think my code sucks?”

  16. Then you’ll have a chance to improve?

  17. “What if …”

  18. Shut up!

  19. Find courage in your pears.

  20. None
  21. programming

  22. None
  23. ~ end ~

  24. Solution 2

  25. How do I change things?

  26. github.com/rubygems/rubygems.org

  27. None
  28. None
  29. None
  30. Make your point 
 with Ruby.

  31. None
  32. “Cool, I know how to write tests.”

  33. None
  34. “Aw, mannn! This isn’t RSpec…”

  35. It’s actually not that different.

  36. None
  37. We had to write Cucumber features.

  38. None
  39. None
  40. You don’t have to write Cucumber features!

  41. This was our test.

  42. context '(…) with a single exact match' do setup do

    @sinatra = create(:rubygem, :name => "sinatra") create(:version, :rubygem => @sinatra) get :show, :query => "sinatra" end should respond_with :redirect should redirect_to('the gem') { rubygem_path(@sinatra) } end
  43. This was our code.

  44. redirect_to rubygem_path(@exact_match) \
 if @gems == [@exact_match]

  45. That’s it.

  46. None
  47. +34 −8 Lines

  48. Pull Request conversation

  49. None
  50. " This makes it impossible to perform certain searches. For

    example, if a user wanted to search for all the gems with the omniauth prefix, this would no longer be possible because the omniauth gem exists.
  51. None
  52. None
  53. Are you sure? it seems to redirect only if there

    is only 1 element in the original search result array
  54. None
  55. None
  56. None
  57. (actual response)

  58. Takeaway #1 Give clear examples in your Pull Requests

  59. Takeaway #2 Don’t instantly fold, react to feedback politely.

  60. Takeaway #3 Reviewing PRs is hard, make it easy.

  61. Practice 3

  62. What about the setup?

  63. None
  64. ./script/setup

  65. Grab a data dump!

  66. rubygems.org/pages/data

  67. None
  68. script/load-pg-dump \
 -u olivierlacan \ -d rubygems_dev \ 
 -c

    dump
  69. You’ll need PostgreSQL 9.5 to use it.

  70. None
  71. To write tests, you gotta run tests.

  72. redis-server

  73. elasticsearch

  74. Otherwise, some tests will fail.

  75. bundle exec rake

  76. 1 minute later…

  77. Finished in 52.023608s, 
 17.0884 runs/s, 
 32.1008 assertions/s. 889

    runs, 1670 assertions, 
 0 failures, 0 errors, 5 skips
  78. [!!!] Index does not exist

  79. You’re missing the elasticsearch index.

  80. bundle exec rake gemcutter:index:update

  81. Tests + real world data give you ideas.

  82. None
  83. 2 years between the first & second PR

  84. “Which gems use my gem as a runtime dependency?” New

    Problem
  85. guides.rubygems.org

  86. None
  87. None
  88. None
  89. Let’s play!

  90. GET /api/v1/gems/rails/reverse_dependencies.json

  91. None
  92. None
  93. None
  94. Are those runtime or development dependencies?

  95. Both.

  96. I’m a gem maintainer and I want to know who

    depends on it at runtime?
  97. Before: you couldn’t.

  98. Now: you can.

  99. None
  100. None
  101. GET /api/v1/gems/rails/reverse_dependencies.json?only=runtime

  102. None
  103. GET /api/v1/gems/rails/reverse_dependencies.json?only=runtime

  104. None
  105. gems that depend on rails for runtime development 7115 1859

  106. What about your gems?

  107. What about the gems you use in production?

  108. Back to the 
 Pull Request.

  109. None
  110. Allow fetching only runtime reverse_dependencies from API Pull Request Title

  111. Clear, concise, add screenshots it can help, don’t make assumptions.

    Description
  112. None
  113. None
  114. Learn how to keep a fork updated: robots.thoughtbot.com/keeping-a-github-fork-updated Upkeep

  115. Respond to other contributors, to maintainers, be patient. Communication

  116. depend.herokuapp.com

  117. None
  118. Don’t try rails, it will crash the app. :-p

  119. hi@olivierlacan.com Questions? Want to pair?