A Portrait of the Artist as a Young Gem Author
Upcoming SlideShare
Loading in...5
×
 

A Portrait of the Artist as a Young Gem Author

on

  • 1,622 views

Talk from The Nuby Hoedown / Ruby Hoedown 2010 about fundamental concepts of RubyGems and gem authoring.

Talk from The Nuby Hoedown / Ruby Hoedown 2010 about fundamental concepts of RubyGems and gem authoring.

Statistics

Views

Total Views
1,622
Views on SlideShare
1,622
Embed Views
0

Actions

Likes
1
Downloads
13
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    A Portrait of the Artist as a Young Gem Author A Portrait of the Artist as a Young Gem Author Presentation Transcript

    • Portrait of the Artist as a Young Gem Author Matt Yoho @mattyoho
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO We’re going to talk about
    • RUBYGEMS 101 MATT YOHO RubyGems
    • RUBYGEMS 101 MATT YOHO What, why, how
    • RUBYGEMS 101 MATT YOHO guidelines
    • RUBYGEMS 101 MATT YOHO In the beginning...
    • RUBYGEMS 101 MATT YOHO In the beginning... (Roughly 1995.)
    • RUBYGEMS 101 MATT YOHO ...Matz created Ruby.
    • RUBYGEMS 101 MATT YOHO And it was good.
    • RUBYGEMS 101 MATT YOHO It was also interpreted.
    • RUBYGEMS 101 MATT YOHO No .so, no .class, no .o, no .dll etc...
    • RUBYGEMS 101 MATT YOHO load './foo/bar/paperclip.rb' require './foo/bar/paperclip'
    • RUBYGEMS 101 MATT YOHO require works based on what is available in Ruby’s load path $LOAD_PATH or $:
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb >> $: => ["/Library/Ruby/Gems/1.8/gems/open_gem-1.4.0/bin", "/Library/Ruby/Gems/ 1.8/gems/open_gem-1.4.0/lib", "/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/ powerpc-darwin10.0", "/Library/Ruby/Site/1.8/universal-darwin10.0", "/Library/ Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/ 1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin10.0", "/System/Library/ Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc- darwin10.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/universal-darwin10.0", "."] >>
    • RUBYGEMS 101 MATT YOHO require will load a path only once
    • RUBYGEMS 101 MATT YOHO however... it does not expand paths
    • RUBYGEMS 101 MATT YOHO require '/matt/foo/bar/file' require './foo/bar/file'
    • RUBYGEMS 101 MATT YOHO Code shared at the source level.
    • RUBYGEMS 101 MATT YOHO Wild West
    • RUBYGEMS 101 MATT YOHO Package Management
    • RUBYGEMS 101 MATT YOHO Along came RubyGems
    • RUBYGEMS 101 MATT YOHO Along came RubyGems eventually.
    • RUBYGEMS 101 MATT YOHO RubyConf 2003
    • RUBYGEMS 101 MATT YOHO Jim Weirich Chad Fowler Rich Kilmer David Black
    • RUBYGEMS 101 MATT YOHO Packaging standard Library repository/server
    • RUBYGEMS 101 MATT YOHO gem server
    • RUBYGEMS 101 MATT YOHO Eric Hodel @drbrain Seattle.rb
    • RUBYGEMS 101 MATT YOHO RubyGems - How does it work?!
    • RUBYGEMS 101 MATT YOHO Duck Punch
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from (irb):1:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb -rubygems ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from /Users/matt/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Users/matt/ruby/1.8/rubygems/custom_require.rb:31:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from (irb):1:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from (irb):1:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb -rubygems ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from /Users/matt/ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require' from /Users/matt/ruby/1.8/rubygems/ custom_require.rb:31:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb -rubygems ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from /Users/matt/ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require' from /Users/matt/ruby/1.8/rubygems/ custom_require.rb:31:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb -rubygems ruby-1.8.7-p249 > require 'foo' LoadError: no such file to load -- foo from /Users/matt/ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require' from /Users/matt/ruby/1.8/rubygems/ custom_require.rb:31:in `require' from (irb):1
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb >> $: => ["/Library/Ruby/Gems/1.8/gems/open_gem-1.4.0/bin", "/Library/Ruby/Gems/ 1.8/gems/open_gem-1.4.0/lib", "/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/ powerpc-darwin10.0", "/Library/Ruby/Site/1.8/universal-darwin10.0", "/Library/ Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/ 1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin10.0", "/System/Library/ Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc- darwin10.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/universal-darwin10.0", "."] >>
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb >> require ‘nokogiri’ => true >> $: => ["/Library/Ruby/Gems/1.8/gems/open_gem-1.4.0/bin", "/Library/Ruby/Gems/ 1.8/gems/open_gem-1.4.0/lib", "/Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/ bin", "/Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/lib", "/Library/Ruby/Gems/ 1.8/gems/nokogiri-1.3.3/ext", "/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/ powerpc-darwin10.0", "/Library/Ruby/Site/1.8/universal-darwin10.0", "/Library/ Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/ 1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin10.0", "/System/Library/ Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc- darwin10.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/universal-darwin10.0", "."] >>
    • RUBYGEMS 101 MATT YOHO ⚡ matt $ irb >> require ‘nokogiri’ => true >> $: => ["/Library/Ruby/Gems/1.8/gems/open_gem-1.4.0/bin", "/Library/Ruby/Gems/ 1.8/gems/open_gem-1.4.0/lib", "/Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/ bin", "/Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/lib", "/Library/Ruby/Gems/ 1.8/gems/nokogiri-1.3.3/ext", "/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/ powerpc-darwin10.0", "/Library/Ruby/Site/1.8/universal-darwin10.0", "/Library/ Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/ 1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin10.0", "/System/Library/ Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/ Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc- darwin10.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/universal-darwin10.0", "."] >>
    • RUBYGEMS 101 MATT YOHO Gemspec
    • RUBYGEMS 101 MATT YOHO version = File.read(File.expand_path('../../RAILS_VERSION', __FILE__)).strip Gem::Specification.new do |s|   s.platform = Gem::Platform::RUBY   s.name = 'activemodel'   s.version = version   s.summary = 'A toolkit for building modeling frameworks.'   s.description = 'A toolkit for building modeling frameworks.'   s.required_ruby_version = '>= 1.8.7'   s.author = 'David Heinemeier Hansson'   s.email = 'david@loudthinking.com'   s.homepage = 'http://www.rubyonrails.org'   s.rubyforge_project = 'activemodel'   s.files = Dir['CHANGELOG', 'MIT-LICENSE', 'README.rdoc', 'lib/**/ *']   s.require_path = 'lib'   s.has_rdoc = true   s.add_dependency('activesupport', version)   s.add_dependency('builder', '~> 2.1.2')   s.add_dependency('i18n', '~> 0.4.1') end
    • RUBYGEMS 101 MATT YOHO version = File.read(File.expand_path("../RAILS_VERSION",__FILE__)).strip Gem::Specification.new do |s|   s.platform = Gem::Platform::RUBY   s.name = 'rails'   s.version = version   s.summary = 'Full-stack web application framework.'   s.description = 'Ruby on Rails is awesome.'   s.required_ruby_version = '>= 1.8.7'   s.required_rubygems_version = ">= 1.3.6"   s.author = 'David Heinemeier Hansson'   s.email = 'david@loudthinking.com'   s.homepage = 'http://www.rubyonrails.org'   s.bindir = 'bin'   s.executables = ['rails']   s.add_dependency('activesupport', version)   s.add_dependency('actionpack', version)   s.add_dependency('activerecord', version)   s.add_dependency('activeresource', version)   s.add_dependency('actionmailer', version)   s.add_dependency('railties', version)   s.add_dependency('bundler', '~> 1.0.0') end
    • RUBYGEMS 101 MATT YOHO Structure
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO #!/usr/local/bin/ruby # # This file was generated by RubyGems. # # The application 'thin' is installed as part of a gem, and # this file is here to facilitate running it. # require 'rubygems' version = ">= 0" if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then version = $1 ARGV.shift end gem 'thin', version load 'thin'
    • RUBYGEMS 101 MATT YOHO Rake
    • RUBYGEMS 101 MATT YOHO Rake tasks make a gem author’s life easier.
    • RUBYGEMS 101 MATT YOHO namespace :gem do desc 'Builds the gem from the gemspec' task :build do sh 'mkdir -p ./pkg' sh 'gem build ./basic_assumption.gemspec' sh 'mv ./basic_assumption-*.gem ./pkg/basic_assumption-EDGE.gem' end desc 'Installs the built gem' task :install => :build do sh 'gem install ./pkg/basic_assumption-EDGE.gem' end end task :default => [:spec, :cucumber]
    • RUBYGEMS 101 MATT YOHO ⚡ basic_assumption (master)$ rake -T (in /Users/matt/projects/basic_assumption) rake bundle:install # Installs the dependencies listed in Gemfile rake clobber # Remove generated code rake clobber:app # Remove generated Rails app rake cucumber # Run Cucumber features rake gem:build # Builds the gem from the gemspec rake gem:install # Installs the built gem rake generate:app # Generate Rails app for integ tests rake generate:custom # Generate scaffolds, etc rake init # Set up gem, runs the specs and cukes rake setup # Sets up the environment for cukes rake spec # Run specs rake spec_with_rcov # Run specs with rcov
    • RUBYGEMS 101 MATT YOHO Documentation
    • RUBYGEMS 101 MATT YOHO RDoc
    • RUBYGEMS 101 MATT YOHO “Use the Source.”
    • RUBYGEMS 101 MATT YOHO RDoc
    • RUBYGEMS 101 MATT YOHO gem server
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO YARD
    • RUBYGEMS 101 MATT YOHO Rocco
    • RUBYGEMS 101 MATT YOHO man
    • RUBYGEMS 101 MATT YOHO •NAME •SYNOPSIS •DESCRIPTION •OPTIONS •FILES •ENVIRONMENT •DIAGNOSTICS •BUGS •AUTHOR •SEE ALSO
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO README Driven Development
    • RUBYGEMS 101 MATT YOHO Licensing
    • RUBYGEMS 101 MATT YOHO Do it right away.
    • RUBYGEMS 101 MATT YOHO MIT, BSD, Ruby
    • RUBYGEMS 101 MATT YOHO Permissive Licenses Copyright (c) 2004-2010 David Heinemeier Hansson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    • RUBYGEMS 101 MATT YOHO The DWTFYWTPL DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE                     Version 2, December 2004  Everyone is permitted to copy and distribute verbatim or modified  copies of this license document, and changing it is allowed as long  as the name is changed.             DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION   0. You just DO WHAT THE FUCK YOU WANT TO.
    • RUBYGEMS 101 MATT YOHO Matz and OSS “There are various merits, but for me the biggest is freedom. I prefer the term 'free software' more than open source.” - Japan, Inc., August 2000
    • RUBYGEMS 101 MATT YOHO Good
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO RVM
    • RUBYGEMS 101 MATT YOHO rvm gemset use
    • RUBYGEMS 101 MATT YOHO Don’t require RubyGems
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO export RUBYOPT=rubygems
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO Manually manage the load path
    • RUBYGEMS 101 MATT YOHO lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require 'basic_assumption/version' Gem::Specification.new do |s|   s.name = %q{basic_assumption}   s.version = BasicAssumption::Version::STRING end
    • RUBYGEMS 101 MATT YOHO Use rake.vim
    • RUBYGEMS 101 MATT YOHO Don’t use Jeweler
    • RUBYGEMS 101 MATT YOHO Prefer static gemspecs
    • RUBYGEMS 101 MATT YOHO Use semantic versioning
    • RUBYGEMS 101 MATT YOHO http://semver.org/
    • RUBYGEMS 101 MATT YOHO X.Y.Z X.Y.Zpre Major.Minor.Patch
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO Write good specs.
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO Integration test
    • RUBYGEMS 101 MATT YOHO Specs go a long way, but...
    • RUBYGEMS 101 MATT YOHO Specs go a long way, but... Rails dependencies, etc.
    • RUBYGEMS 101 MATT YOHO Yuck.
    • RUBYGEMS 101 MATT YOHO Cucumber
    • RUBYGEMS 101 MATT YOHO Aruba
    • RUBYGEMS 101 MATT YOHO cucumber features for command line apps
    • RUBYGEMS 101 MATT YOHO
    • CUCARUBA! MATT YOHO YO DAWG! I heard you like writing features while you write features so we put cukes in your cukes!
    • RUBYGEMS 101 MATT YOHO ~/projects/lib/tmp/aruba
    • RUBYGEMS 101 MATT YOHO ~/projects/lib/tmp/aruba ./tmp/aruba rake task
    • RUBYGEMS 101 MATT YOHO ~/projects/lib/tmp/aruba templates ./tmp/aruba rake task
    • RUBYGEMS 101 MATT YOHO Feature: Rails Controllers Can Make Assumptions Scenario: controller invokes assume Given a file named "app/controllers/widgets_controller.rb" with: """ class WidgetsController < ApplicationController assume(:widget) { Widget.find(params[:id]) } end """ And a file named "app/views/widgets/show.html.erb" with: """ <blink><%= widget.name %></blink> """ And a file named "features/widget_is_viewed_by_visitor.feature" with: """ Feature: Widget is viewed by visitor Scenario: success Given a widget named "foobar" When I view the widget Then I should see "foobar" """ When I run "cucumber features/widget_is_viewed_by_visitor.feature" Then I should see: """ 1 scenario (1 passed) 3 steps """
    • RUBYGEMS 101 MATT YOHO Feature: Foo Does Something Scenario: foo works Given a file named "foo.feature" with: """ Feature: Widget is viewed by visitor Scenario: success Given a foo named "bar" When I view the foo Then I should see "bar" """ When I run "cucumber foo.feature" Then I should see: """ 1 scenario (1 passed) 1 step """
    • RUBYGEMS 101 MATT YOHO A little slow, but totally badass.
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO http://github.com/aslakhellesoy/aruba http://github.com/rspec/rspec- rails http://github.com/mattyoho/ basic_assumption
    • RUBYGEMS 101 MATT YOHO RVM and Bundler are complimentary
    • RUBYGEMS 101 MATT YOHO Provide contribution guidelines
    • RUBYGEMS 101 MATT YOHO Unicorn
    • RUBYGEMS 101 MATT YOHO Get Forked
    • RUBYGEMS 101 MATT YOHO i <3 GitHub
    • RUBYGEMS 101 MATT YOHO Git commit etiquette
    • RUBYGEMS 101 MATT YOHO Publish!
    • RUBYGEMS 101 MATT YOHO
    • RUBYGEMS 101 MATT YOHO RubyGems.org gem build gem push
    • RUBYGEMS 101 MATT YOHO Learn by example
    • RUBYGEMS 101 MATT YOHO RSpec2, Nokogiri, Paperclip, anything by Ryan Tomayko, Tom Preston-Warner, or any other GitHubber
    • Thank you Matt Yoho matt@edgecase.com @mattyoho