This is the third part of the Storyteller Trilogy, you can read other parts in the following links:
So I built a library and I want to use it as a gem. I read the information from rubygems, and I didn't get it, so I followed the instructions from Bundler, which is great, I didn't understand most of it but it worked (well, the publishing part is still a mystery).
I will tell you the way I think is the best one to do it.
First, make the repository
You already have the idea, probably most of the code is already there, so instead of following the tutorial, build the repository. Don't push anything yet, but ensure you have the URL.
If you use Github, make it combo and build the Homepage, don't need to fill up anything, but now you've got web addresses!
So now, create the gem
bundle gem storyteller the script asks you a bunch of great stuff that will build up for you.
After its done, you will have
storyteller.gemspec filled with lots of information, but something is missing.. aha! the URLs, and the description.
If you chose to add a test framework you should add the dependency on the gemspec like so
spec.add_development_dependency "rspec", "~> 3.2" that is a development dependency, you don't need to have it when you are in production. The ones that are really needed for your gem to work you need to add them like so
The typical structure is having a file with the gem's name inside
lib and then you work the magic. This part is really necessary
Then I pushed the code into Github and I tried to use the gem, it went like this.
gem "storyteller", github: "avispatech/storyteller"
class DoSomething < Storyteller::Story
step 'Say hi' do
And works! Next step is how to publish it, but thats the easy part, right?