To view this screencast, add it to
your cart
and
checkout.
You can buy this screencast for any price, including FREE!
Now that GemCutter is becoming the standard host for gems, deploying gems couldn’t be easier!
We no longer need tools like hoe, newgem, bones, jeweler or others. Sure, these tools may still be useful, but we don’t need them to create simple gems!
Let’s say you have a Ruby file that you want to share with people. It lets objects bark.
1 class Object 2 def bark 3 puts "woof! I am #{ self.to_s }!" 4 end 5 end
Very cool library. Let’s share it!
- Create a new directory … let’s call it
object-bark - Create a
libdirectory and put your ruby file in it, so you haveobject-bark/lib/object-bark.rb - Create a
object-bark.gemspecfile with the following content …
1 Gem::Specification.new do |s| 2 s.name = 'object-bark' 3 s.version = '0.1.0' 4 s.summary = 'Lets object bark!' 5 s.files = Dir['lib/**/*.rb'] 6 end
- Run
gem build object-bark.gemspecand you should end up with aobject-bark-0.1.0.gemfile - Run
gem install object-bark-0.1.0.gemto install the gem locally or, if you want, you can … - Run
gem push object-bark-0.1.0.gemto push the gem to GemCutter, for all to use! (requires the gemcutter gem)
Once your gem is installed, you can use it like any other:
1 $ irb 2 >> require 'rubygems' 3 => true 4 >> require 'object-bark' 5 => true 6 >> Object.bark 7 woof! I am Object! 8 => nil 9 >> 5.bark 10 woof! I am 5! 11 => nil
That’s basically all there is to it! To watch me make a gem and ramble on, giving pointers here and there, watch the screencast.
Enjoy!