Go to lib folder and use bundler to generate main files for a gem:
$ bundle gem test_gem
create test_gem/Gemfile
create test_gem/Rakefile
create test_gem/LICENSE
create test_gem/README.md
create test_gem/.gitignore
create test_gem/test_gem.gemspec
create test_gem/lib/test_gem.rb
create test_gem/lib/test_gem/version.rb
Initializating git repo in /path/to/webapp/HouseTrip-Web-App/lib/test_gem
cd in to created directory
$ cd test_gem/
Bundler automatically created git repository for us, but we do not need it. Lets remove it:
$ rm -rf .git/
And we need to remove git dependency from gemspec file, open test_gem.gemspec file and change this line :
gem.files = `git ls-files`.split($\)
to this :
gem.files = Dir.glob("{bin,lib}/**/*")
Next step is to configure rake to include gem files properly and to include all rake files from a gem.
Open Rakefile file and overwrite it with this code:
#!/usr/bin/env rake
require "bundler/gem_tasks"
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
$LOAD_PATH << File.join(File.dirname(__FILE__))
# load custom tasks
Dir.glob(["lib/**/*.rake", "tasks/**/*.rake"]).each do |file|
Kernel.load file
end
And the last step is to add our gem in to project, open Gemfile from main web app and add this line:
gem 'test_gem', :path => File.join(File.dirname(__FILE__), '/lib/test_gem')
DONE :)
Posted by fragalla to HouseTrip Deck (2012-08-03 13:36)