Require
Manage your project's dependencies with a pretty DSL.
- Gem activation
- Require calls
- Load paths
- Gemspec configuration
Install
sudo gem install require
Example
Create require.rb
in your project's root directory:
require 'rubygems'
gem 'require'
require 'require'
Require do
gem(:sinatra, '=0.9.4') { require 'sinatra/base' }
gem(:haml, '=2.2.16') { require %w(haml sass) }
lib do
gem :sinatra
gem :haml
load_path 'vendor/authlogic/lib'
require 'authlogic'
end
end
Then in your library file (lib/whatever.rb
):
require File.("#{File.dirname(__FILE_)}/../require")
Require.lib!
- Activates sinatra and haml gems
- Requires sinatra, haml, and sass
- Adds vendor/authlogic/lib to the load paths
- Requires authlogic
Gemspec
You can also use Require
to generate a Gem::Specification
instance.
require 'rubygems'
gem 'require'
require 'require'
Require do
gem(:sinatra, '=0.9.4') { require 'sinatra/base' }
gemspec do
'Your Name'
dependencies do
gem :sinatra
end
email '[email protected]'
name 'my_project'
homepage "http://github.com/your_name/#{name}"
summary ""
version '0.1.0'
end
end
Then use it in your rakefile
:
require File.dirname(__FILE_) + "/require"
desc "Package gem"
Rake::GemPackageTask.new(Require.gemspec) do |pkg|
pkg.gem_spec = Require.gemspec
end