2014-06-04

Make a gem

Making and publishing your own gems is so incredibly simple. Here is my setp by step process when I want to publish one:

Make a Rubygems account

chmod 0600 ~/.gem/credentials ```

Prepare the code

These steps are my typical path, nothing is really mandatory there.

  • create a repo at github (or wherever you want)
  • create a base gem skeleton bundle gem mycoolgem
  • update the README.md, add some minimal information. The clearest you explain what it does the best chances people will adopt it. Add cypirght information
  • create a CHANGELOG.md because when you publish something you need a clear log of your version changes
  • enable the tracking on codeclimate, travis, coveralls, gemnasium
  • add badges from http://shields.io in the README.md because it helps to qualify the state of the code quickly
  • when the gem code don’t need to have access to the version number, I found convenient to just remove the version file and add version in the .gemspec from the changelog file with spec.version = File.read(File.expand_path('../CHANGELOG.md', __FILE__))[/([0-9]+\.[0-9]+\.[0-9]+)/] (so then when I version bump there is only one file to edit)
  • write the code (or copy it from the private app you extract it from)
  • add a spec/ or test/ dir and write some tests and try to reach a decent coverage

Release it

  • add the date in the changelog for the current version
  • rake release
  • bump the version to the next increment in the changelog (and version file if any)

Overall with the initial bundle command and the final rake task for release, it’s pretty straightforward.

Also check http://guides.rubygems.org/make-your-own-gem/

2014-05-27

Gem reverse dependencies

I have been looking for a way to see what gem uses a gem, so I can see examples of integration in other projects. The rubygems API guide don’t tell anything about such reverse dependency query. But it is actually there, it got merged some time ago, and optimized, but it is not documented yet (it runs really fast, kudos Rubygems guys).

ruby -ropen-uri -rpp -ryaml \
     -e 'pp YAML.load(open("https://rubygems.org/api/v1/gems/rails_best_practices/reverse_dependencies.yaml"))'

["metric_fu",
 "flyerhzm-metric_fu",
 "edouard-metric_fu",
 "devver-metric_fu",
 "goldstar-metric_fu",
 "socializer",
 "trollface",
 "guard-rails_best_practices",
 "rferraz-metric_fu",
 "git-hooks-helper",
 "odor",
 "rake_check",
 "koality",
 "danmayer-metric_fu",
 "bf4-metric_fu",
 "metrics_satellite",
 "code_hunter",
 "kinit",
 "rails-audit",
 "pronto-rails_best_practices",
 "free_disk_space",
 "warder",
 "ruby_osx_app",
 "sanelint"]

Out of curiosity I counted some wellknown gems usages by adding a .count at the end:

rake:    23766
rails:   6283
thor:    2786
pry:     2870
sinatra: 1964
devise:  422 

2012-09-16

Rubygems back on twitter

I was used to checkout the new gems on twitter while in public transportation, but the flow stopped 2 weeks ago. So after a while I just wrote my own webhook, that was amazingly easy and just took 2 hours (well it’s not elaborated and test-backed and all but it works)

https://github.com/mose/rubygems-alt

Now I can follow the feed again on https://twitter.com/RubyGemsAlt and even better, I can change the formatting of it haha.

I think next move would be to automatically add hashtags on the description from a list of known ones, like #rails or #sinatra. And I also need to daemonize it, right now it’s just running in a screen but daemonizing it would not be hard at all (with daemon gem).

But you are welcome to fork me and pull request and everything.