Skip to content

Instantly share code, notes, and snippets.

@bswinnerton
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bswinnerton/10005967 to your computer and use it in GitHub Desktop.
Save bswinnerton/10005967 to your computer and use it in GitHub Desktop.

Ruby on Rails Office Hours - Session 3

Building a gem

Video: https://www.youtube.com/watch?v=bMD5IB8vKmA
Real time chat: http://tlk.io/ror-study-group

Code Along

  1. Create the gem skeleton

    bundle gem topreddit
    
  2. CD into the gem

    cd topreddit
    
  3. Alter the gemspec to add anything you'd normally put in the Gemfile

    vi topreddit.gemspec
    

    Note: You can add runtime dependencies with spec.add_runtime_dependency

  4. Add the fluff of your gem to lib/topreddit.rb or require the appropriate other files from lib/topreddit/

    vi lib/topreddit.rb
    
  5. Make your gem executable, add any instantiation options here

    vi bin/topreddit
    chmod +x bin/topreddit
    

    Note: You'll need to require the main file in lib

  6. Add the files in git

    git add .
    git commit -m "Initial commit"
    
  7. Build your gem locally

    gem build topreddit.gemspec
    
  8. Install your gem locally

    gem install ./topreddit-0.0.1.gem
    
  9. Deploy to rubygems

    gem push topreddit-0.0.1.gem
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment