Skip to content

Instantly share code, notes, and snippets.

@jvranish
Created August 12, 2012 01:53
Show Gist options
  • Save jvranish/3328798 to your computer and use it in GitHub Desktop.
Save jvranish/3328798 to your computer and use it in GitHub Desktop.
An example explaining how to use bundler to replace externals/submodules
source "http://rubygems.org"
gem "my_awesome_lib", :path => "../my_awesome_lib"
# or to use directly from a git repository:
# gem "my_awesome_lib", :git => "git://path/to/git/repo/my_awesome_lib.git", :branch => "1.0"
# or just use as a gem (perhaps from your very own gem source):
# gem "my_awesome_lib", ">= 1.0.0"
Gem::Specification.new do |gem|
gem.email = "job.vranish@atomicembedded.com"
gem.authors = ["Job Vranish"]
gem.summary = %Q{An awesome library}
gem.description = %Q{A fake gem to make bundler to what we want}
files = Dir['*'].reject {|f| File.directory? f}
test_files = []
gem.require_path = '.' # <-- make sure this includes the path of your ruby file (relative to your .gemspec)
gem.executables = []
gem.files = files # <-- at a minimum this should include your ruby script
# but if you want to eventually package up your library in a gem
# (not a bad idea) this needs to include all the files you want to
# include in the gem.
gem.test_files = test_files
gem.name = "my_awesome_lib"
gem.version = "1.0.0"
gem.add_dependency 'bundler'
end
class My_Awesome_Lib
# this little method uses the magic __FILE__ value to generate a path
# relative to this file
def self.location
File.expand_path(
File.join(
File.dirname(__FILE__),
".")) # <-- change this appropriately if this file not at project root
end
end
require "rubygems"
require "bundler/setup"
require 'my_awesome_lib'
# print out the path to our awesome library
puts My_Awesome_Lib.location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment