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

Raising the Bar

tyerhunt
October 02, 2011

Raising the Bar

Now that there are now over 25,000 gems on RubyGems.org, it's time we took a step back to look at the quality of what we're producing and the best practices we can all follow that will benefit the community.

Other languages expend a lot of effort maintaining a standard coding style and consistent APIs among their shared libraries, but the Ruby community doesn't. This has done a lot to lower the barrier to entry and allow the Ruby ecosystem to flourish, but it has also produced a lot of code of questionable quality that doesn't always mesh well in our applications.

There are simple conventions we can follow, though, that will make a big difference in establishing a consistent baseline for our gems. These include things like writing gemspecs instead of Rake tasks that generate them, properly namespacing your libraries, and not polluting the load path. But there are also other practices that will benefit others, like producing good documentation, including binaries when needed, and establishing a sane versioning strategy.

We'll cover the full lifecycle of a gem from beginning to end, from your first push to RubyGems.org to making and accepting community contributions, and consider the conventions that we can establish each step of the way to increase the value of the gems we're producing.

tyerhunt

October 02, 2011
Tweet

Other Decks in Technology

Transcript

  1. gem build stardust.gemspec WARNING: no author specified WARNING: no description

    specified WARNING: no email specified WARNING: no homepage specified Successfully built RubyGem Name: stardust Version: 0.0.1 File: stardust-0.0.1.gem
  2. Gem::Specification.new do |s| s.name = 'stardust' s.version = '0.0.1' s.summary

    = 'Video & Coffee' s.files = ['lib/stardust.rb'] s.require_paths = ['lib'] end
  3. Gem::Specification.new do |s| s.name = 'stardust' s.version = '0.0.1' s.summary

    = 'Video & Coffee' s.files = ['lib/stardust.rb'] s.require_paths = ['lib'] end
  4. $:.push File.expand_path('../lib', __FILE__) require 'stardust/version' Gem::Specification.new do |s| s.name =

    'stardust' s.version = '0.0.1' s.summary = 'Video & Coffee' s.files = ['lib/stardust.rb'] s.require_paths = ['lib'] end
  5. $:.push File.expand_path('../lib', __FILE__) require 'stardust/version' Gem::Specification.new do |s| s.name =

    'stardust' s.version = Stardust::VERSION s.summary = 'Video & Coffee' s.files = ['lib/stardust.rb'] s.require_paths = ['lib'] end
  6. Gem::Specification.new do |s| s.name = 'stardust' s.version = '0.0.1' s.summary

    = 'Video & Coffee' s.add_dependency 'activesupport', '~> 3.0.0' s.add_development_dependency 'rspec', '~> 2.3.0' end
  7. gem install stardust-0.0.1.gem Fetching: activesupport-3.0.10.gem (100%) Successfully installed activesupport-3.0.10 Successfully

    installed stardust-0.0.1 2 gems installed Installing ri documentation for activesupport-3.0.10... Installing ri documentation for stardust-0.0.1... Installing RDoc documentation for activesupport-3.0.10... Installing RDoc documentation for stardust-0.0.1...
  8. git status # On branch master # # Initial commit

    # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: .gitignore # new file: Gemfile # new file: Rakefile # new file: lib/stardust.rb # new file: lib/stardust/version.rb # new file: stardust.gemspec
  9. $: