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
           ...
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,
                  ...
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 pat...
RUBYGEMS 101
           MATT YOHO




 ⚡ matt $ irb
>> $:
=> ["/Library/Ruby/Gems/1.8/gems/open_gem-1.4.0/bin", "/Library/...
RUBYGEMS 101
           MATT YOHO




               require will load a path only
                            once
RUBYGEMS 101
           MATT YOHO




                   however...
                   it does not expand
                ...
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
                  ...
RUBYGEMS 101
           MATT YOHO




                       RubyConf 2003
RUBYGEMS 101
           MATT YOHO




                       Jim Weirich
                       Chad Fowler
              ...
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 > requi...
RUBYGEMS 101
           MATT YOHO




    ⚡ matt $ irb -rubygems
  ruby-1.8.7-p249 > require 'foo'
  LoadError: no such fil...
RUBYGEMS 101
           MATT YOHO




    ⚡ matt $ irb
   ruby-1.8.7-p249 > require 'foo'
   LoadError: no such file to loa...
RUBYGEMS 101
           MATT YOHO




    ⚡ matt $ irb
   ruby-1.8.7-p249 > require 'foo'
   LoadError: no such file to loa...
RUBYGEMS 101
           MATT YOHO




    ⚡ matt $ irb -rubygems
   ruby-1.8.7-p249 > require 'foo'
   LoadError: no such ...
RUBYGEMS 101
           MATT YOHO




    ⚡ matt $ irb -rubygems
   ruby-1.8.7-p249 > require 'foo'
   LoadError: no such ...
RUBYGEMS 101
           MATT YOHO




    ⚡ matt $ irb -rubygems
   ruby-1.8.7-p249 > require 'foo'
   LoadError: no such ...
RUBYGEMS 101
           MATT YOHO




 ⚡ matt $ irb
>> $:
=> ["/Library/Ruby/Gems/1.8/gems/open_gem-1.4.0/bin", "/Library/...
RUBYGEMS 101
           MATT YOHO




 ⚡ matt $ irb
>> require ‘nokogiri’
=> true
>> $:
=> ["/Library/Ruby/Gems/1.8/gems/o...
RUBYGEMS 101
           MATT YOHO




 ⚡ matt $ irb
>> require ‘nokogiri’
=> true
>> $:
=> ["/Library/Ruby/Gems/1.8/gems/o...
RUBYGEMS 101
           MATT YOHO




                       Gemspec
RUBYGEMS 101
            MATT YOHO



version = File.read(File.expand_path('../../RAILS_VERSION', __FILE__)).strip

Gem::S...
RUBYGEMS 101
           MATT YOHO


version = File.read(File.expand_path("../RAILS_VERSION",__FILE__)).strip

Gem::Specifi...
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 '...
RUBYGEMS 101
           MATT YOHO




       Rake
RUBYGEMS 101
           MATT YOHO




                       Rake tasks make a
                        gem author’s life
 ...
RUBYGEMS 101
           MATT YOHO




namespace :gem do
 desc 'Builds the gem from the gemspec'
 task :build do
  sh 'mkdi...
RUBYGEMS 101
           MATT YOHO




 ⚡ basic_assumption (master)$ rake -T
(in /Users/matt/projects/basic_assumption)
rak...
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...
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

     ...
RUBYGEMS 101
           MATT YOHO




             The DWTFYWTPL

       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
     ...
RUBYGEMS 101
           MATT YOHO




Matz and OSS


       “There are various merits,
        but for me the biggest is
 ...
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)

...
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 dependen...
RUBYGEMS 101
           MATT YOHO




                       Yuck.
RUBYGEMS 101
           MATT YOHO




      Cucumber
RUBYGEMS 101
           MATT YOHO




                       Aruba
RUBYGEMS 101
           MATT YOHO




                         cucumber features
                       for command line a...
RUBYGEMS 101
           MATT YOHO
CUCARUBA! MATT YOHO




               YO DAWG! I heard you like writing
            features while you write features so ...
RUBYGEMS 101
           MATT YOHO




        ~/projects/lib/tmp/aruba
RUBYGEMS 101
           MATT YOHO




        ~/projects/lib/tmp/aruba


                              ./tmp/aruba
       ...
RUBYGEMS 101
           MATT YOHO




        ~/projects/lib/tmp/aruba


                 templates          ./tmp/aruba
 ...
RUBYGEMS 101
           MATT YOHO



Feature: Rails Controllers Can Make Assumptions

 Scenario: controller invokes assume...
RUBYGEMS 101
           MATT YOHO




Feature: Foo Does Something
 Scenario: foo works
  Given a file named "foo.feature" w...
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-
  ...
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, anythi...
Thank you
Matt Yoho
matt@edgecase.com
@mattyoho
Upcoming SlideShare
Loading in …5
×

A Portrait of the Artist as a Young Gem Author

1,687 views
1,610 views

Published on

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,687
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

A Portrait of the Artist as a Young Gem Author

  1. 1. Portrait of the Artist as a Young Gem Author Matt Yoho @mattyoho
  2. 2. RUBYGEMS 101 MATT YOHO
  3. 3. RUBYGEMS 101 MATT YOHO We’re going to talk about
  4. 4. RUBYGEMS 101 MATT YOHO RubyGems
  5. 5. RUBYGEMS 101 MATT YOHO What, why, how
  6. 6. RUBYGEMS 101 MATT YOHO guidelines
  7. 7. RUBYGEMS 101 MATT YOHO In the beginning...
  8. 8. RUBYGEMS 101 MATT YOHO In the beginning... (Roughly 1995.)
  9. 9. RUBYGEMS 101 MATT YOHO ...Matz created Ruby.
  10. 10. RUBYGEMS 101 MATT YOHO And it was good.
  11. 11. RUBYGEMS 101 MATT YOHO It was also interpreted.
  12. 12. RUBYGEMS 101 MATT YOHO No .so, no .class, no .o, no .dll etc...
  13. 13. RUBYGEMS 101 MATT YOHO load './foo/bar/paperclip.rb' require './foo/bar/paperclip'
  14. 14. RUBYGEMS 101 MATT YOHO require works based on what is available in Ruby’s load path $LOAD_PATH or $:
  15. 15. 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", "."] >>
  16. 16. RUBYGEMS 101 MATT YOHO require will load a path only once
  17. 17. RUBYGEMS 101 MATT YOHO however... it does not expand paths
  18. 18. RUBYGEMS 101 MATT YOHO require '/matt/foo/bar/file' require './foo/bar/file'
  19. 19. RUBYGEMS 101 MATT YOHO Code shared at the source level.
  20. 20. RUBYGEMS 101 MATT YOHO Wild West
  21. 21. RUBYGEMS 101 MATT YOHO Package Management
  22. 22. RUBYGEMS 101 MATT YOHO Along came RubyGems
  23. 23. RUBYGEMS 101 MATT YOHO Along came RubyGems eventually.
  24. 24. RUBYGEMS 101 MATT YOHO RubyConf 2003
  25. 25. RUBYGEMS 101 MATT YOHO Jim Weirich Chad Fowler Rich Kilmer David Black
  26. 26. RUBYGEMS 101 MATT YOHO Packaging standard Library repository/server
  27. 27. RUBYGEMS 101 MATT YOHO gem server
  28. 28. RUBYGEMS 101 MATT YOHO Eric Hodel @drbrain Seattle.rb
  29. 29. RUBYGEMS 101 MATT YOHO RubyGems - How does it work?!
  30. 30. RUBYGEMS 101 MATT YOHO Duck Punch
  31. 31. 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
  32. 32. 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
  33. 33. 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
  34. 34. 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
  35. 35. 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
  36. 36. 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
  37. 37. 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
  38. 38. 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", "."] >>
  39. 39. 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", "."] >>
  40. 40. 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", "."] >>
  41. 41. RUBYGEMS 101 MATT YOHO Gemspec
  42. 42. 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
  43. 43. 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
  44. 44. RUBYGEMS 101 MATT YOHO Structure
  45. 45. RUBYGEMS 101 MATT YOHO
  46. 46. RUBYGEMS 101 MATT YOHO
  47. 47. RUBYGEMS 101 MATT YOHO
  48. 48. RUBYGEMS 101 MATT YOHO
  49. 49. 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'
  50. 50. RUBYGEMS 101 MATT YOHO Rake
  51. 51. RUBYGEMS 101 MATT YOHO Rake tasks make a gem author’s life easier.
  52. 52. 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]
  53. 53. 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
  54. 54. RUBYGEMS 101 MATT YOHO Documentation
  55. 55. RUBYGEMS 101 MATT YOHO RDoc
  56. 56. RUBYGEMS 101 MATT YOHO “Use the Source.”
  57. 57. RUBYGEMS 101 MATT YOHO RDoc
  58. 58. RUBYGEMS 101 MATT YOHO gem server
  59. 59. RUBYGEMS 101 MATT YOHO
  60. 60. RUBYGEMS 101 MATT YOHO YARD
  61. 61. RUBYGEMS 101 MATT YOHO Rocco
  62. 62. RUBYGEMS 101 MATT YOHO man
  63. 63. RUBYGEMS 101 MATT YOHO •NAME •SYNOPSIS •DESCRIPTION •OPTIONS •FILES •ENVIRONMENT •DIAGNOSTICS •BUGS •AUTHOR •SEE ALSO
  64. 64. RUBYGEMS 101 MATT YOHO
  65. 65. RUBYGEMS 101 MATT YOHO
  66. 66. RUBYGEMS 101 MATT YOHO
  67. 67. RUBYGEMS 101 MATT YOHO README Driven Development
  68. 68. RUBYGEMS 101 MATT YOHO Licensing
  69. 69. RUBYGEMS 101 MATT YOHO Do it right away.
  70. 70. RUBYGEMS 101 MATT YOHO MIT, BSD, Ruby
  71. 71. 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.
  72. 72. 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.
  73. 73. 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
  74. 74. RUBYGEMS 101 MATT YOHO Good
  75. 75. RUBYGEMS 101 MATT YOHO
  76. 76. RUBYGEMS 101 MATT YOHO RVM
  77. 77. RUBYGEMS 101 MATT YOHO rvm gemset use
  78. 78. RUBYGEMS 101 MATT YOHO Don’t require RubyGems
  79. 79. RUBYGEMS 101 MATT YOHO
  80. 80. RUBYGEMS 101 MATT YOHO export RUBYOPT=rubygems
  81. 81. RUBYGEMS 101 MATT YOHO
  82. 82. RUBYGEMS 101 MATT YOHO Manually manage the load path
  83. 83. 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
  84. 84. RUBYGEMS 101 MATT YOHO Use rake.vim
  85. 85. RUBYGEMS 101 MATT YOHO Don’t use Jeweler
  86. 86. RUBYGEMS 101 MATT YOHO Prefer static gemspecs
  87. 87. RUBYGEMS 101 MATT YOHO Use semantic versioning
  88. 88. RUBYGEMS 101 MATT YOHO http://semver.org/
  89. 89. RUBYGEMS 101 MATT YOHO X.Y.Z X.Y.Zpre Major.Minor.Patch
  90. 90. RUBYGEMS 101 MATT YOHO
  91. 91. RUBYGEMS 101 MATT YOHO Write good specs.
  92. 92. RUBYGEMS 101 MATT YOHO
  93. 93. RUBYGEMS 101 MATT YOHO Integration test
  94. 94. RUBYGEMS 101 MATT YOHO Specs go a long way, but...
  95. 95. RUBYGEMS 101 MATT YOHO Specs go a long way, but... Rails dependencies, etc.
  96. 96. RUBYGEMS 101 MATT YOHO Yuck.
  97. 97. RUBYGEMS 101 MATT YOHO Cucumber
  98. 98. RUBYGEMS 101 MATT YOHO Aruba
  99. 99. RUBYGEMS 101 MATT YOHO cucumber features for command line apps
  100. 100. RUBYGEMS 101 MATT YOHO
  101. 101. CUCARUBA! MATT YOHO YO DAWG! I heard you like writing features while you write features so we put cukes in your cukes!
  102. 102. RUBYGEMS 101 MATT YOHO ~/projects/lib/tmp/aruba
  103. 103. RUBYGEMS 101 MATT YOHO ~/projects/lib/tmp/aruba ./tmp/aruba rake task
  104. 104. RUBYGEMS 101 MATT YOHO ~/projects/lib/tmp/aruba templates ./tmp/aruba rake task
  105. 105. 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 """
  106. 106. 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 """
  107. 107. RUBYGEMS 101 MATT YOHO A little slow, but totally badass.
  108. 108. RUBYGEMS 101 MATT YOHO
  109. 109. RUBYGEMS 101 MATT YOHO http://github.com/aslakhellesoy/aruba http://github.com/rspec/rspec- rails http://github.com/mattyoho/ basic_assumption
  110. 110. RUBYGEMS 101 MATT YOHO RVM and Bundler are complimentary
  111. 111. RUBYGEMS 101 MATT YOHO Provide contribution guidelines
  112. 112. RUBYGEMS 101 MATT YOHO Unicorn
  113. 113. RUBYGEMS 101 MATT YOHO Get Forked
  114. 114. RUBYGEMS 101 MATT YOHO i <3 GitHub
  115. 115. RUBYGEMS 101 MATT YOHO Git commit etiquette
  116. 116. RUBYGEMS 101 MATT YOHO Publish!
  117. 117. RUBYGEMS 101 MATT YOHO
  118. 118. RUBYGEMS 101 MATT YOHO RubyGems.org gem build gem push
  119. 119. RUBYGEMS 101 MATT YOHO Learn by example
  120. 120. RUBYGEMS 101 MATT YOHO RSpec2, Nokogiri, Paperclip, anything by Ryan Tomayko, Tom Preston-Warner, or any other GitHubber
  121. 121. Thank you Matt Yoho matt@edgecase.com @mattyoho

×