Integrating Minitest with Shippable
I know, everyone uses Travis. I have nothing against it. But in case you want to test and/or …
Rails 3.1 introduced the asset pipeline, which make it easy to include versioned external assets as application dependencies.
Probably you will find almost any JS library you want, already Gemified, but, if it is not the case, you can Gemify those libraries by your own, and I can help you with it. So, let’s do it!
Bundler makes it simple to create the files and folders necessary for building a Gem:
$ bundle gem somelibrary
This command will create basically the following tree:
$ tree
somelibrary
├── Gemfile
├── lib
│ ├── somelibrary
│ │ └── version.rb
│ └── somelibrary.rb
├── LICENSE.txt
├── Rakefile
├── README.md
└── somelibrary.gemspec
But, I usually made some changes to it:
version.rb
file and it’s parent folder:$ rm -rf lib/somelibrary
Heads up: Don’t forget to change the
lib/someligrary.rb
andsomelibrary.gemspec
files!
somelibrary.gemspec
file…Remove the references to version.rb
, put a static version, replace the TODO’s by your own texts.
lib/somelibrary.rb
file…You had to force it to load the rails engine:
module Somelibrary
class Engine < ::Rails::Engine
end
end
vendor/assets
folderThat’s easy!
$ mkdir -p vendor/assets/{javascripts,stylesheets}
Even easier, just copy the respective js
and css
files to javascripts
and stylesheets
folders, respectively.
Now, create some rails app, and add the following to the Gemfile:
gem 'somelibrary', path: 'absolute/path/to/your/gem'
And, off course, add the respective imports in your application.js
and application.css
files.
Yeah, users would like some documentation and a few appointments about how to use your Gem. So, please, do it.
Well, now that the Gem is crafted, tested and documented, we could finally release it.
Create a github repository for your gem, and do the basics:
$ git init
$ git add -A
$ git commit -m 'first'
$ git remote add https://github.com/USER/REPO
$ git push origin master
And then, finally, release it using Rake:
$ rake release
This will create a tag for the version specified in your gemspec, push it to github and to rubygems.org.
Simple, uh?
Now, just use it as a normal gem :)
Hope you enjoyed the post.
Cheers