building your (my) first gem

9
Building Your (My) First Gem Cam Kidman @camkidman

Upload: cameron-kidman

Post on 09-Aug-2015

22 views

Category:

Technology


0 download

TRANSCRIPT

Building Your (My) First Gem

Cam Kidman@camkidman

Getting Started

• bundle gem GEM

bundle gem is the “rails g” of gem building

File Structure

• Top level files are Gemfile, LICENSE.txt, README.md, Rakefile, *.gemspec, and /lib

• Files are added in /lib, optionally (recommended), create a /spec folder for your tests (assuming you use Rspec)

• Executables would go in /bin

backwards.gemspec

• Your gemspec file is where your gem’s configuration is set.

• You can add dependencies, set versioning, etc.

• The first thing we’ll do in our example is add testing resources

TDD!

spec/backwards_spec.rb

TDD!

lib/backwards.rb

I get all my method

names from Dr. Doofenshmirtz

TDD!Our test now yields:

Publishing Your Gem

1. Create a rubygems.org account

2. gem build backwards.gemspec (make sure you get rid of any TODOs in your .gemspec file!). This will create a .gem file in your working directory

3. Put your rubygems.org credentials in a file in ~/.gem/credentials

4. gem push backwards-0.0.1.gem

Done!Questions?