December 12, 2015
Rails project, and why I come out in favour of using
manifest.js file, by default, are compressed, uglified and concatenated using Rail's Asset Pipeline.
Advantages and Disadvantages
Upgrading to a later version of a library can be a time consuming process as you have to manually check that the correct dependencies have been included, while simultaneously ensuring that you are not breaking other library's dependencies.
Ruby uses RubyGems for package management. For each RubyGem, the name, version, operating system and any dependencies are specified. To add a RubyGem to your Rail’s project, the RubyGem’s name is added to the Gemfile and the command
bundle install is entered into Terminal. This will install the RubyGem along with any dependencies into your Rail’s project.
To update a RubyGem, or possibly revert to an older version, the required version is specified in the Gemfile file and the command
bundle installis entered into Terminal. This will remove the previous RubyGem and add the newly specified RubyGem along with any dependencies to your Rail’s project
It works by automatically converting a Bower project to a RubyGem so that it can be included and treated like any other RubyGem.
What is Bower?
To understand what is going on lets go through an example:
Creating a Bower package
Once you have installed NPM type the following into Terminal.
npm install -g bower.
In order to install NPM - a package manager for Node - requires that you first install Node. There are a number of posts that show you how to install Node - see appendix
Create your Bower package by typing into the Terminal the following:
This takes you through a couple of steps to define your Bower Package. You will need to specify a unique project name and the location of the git repository.
Once the Bower package has been created then it can be registered so that it is listed in the Bower’s directory.
To register, type the following into Terminal. My dummy project is called cezDemoBower
bower register cezDemoBower firstname.lastname@example.org:chrisZingel/cezDemoBower.git
You can use the following command in Terminal to check that the package has been correctly setup
bower info cezDemoBower
To use this Bower Library in your rails application
Include the following in your Gemfile
source 'https://rails-assets.org' do gem "rails-assets-cezDemoBower" end