Skip to content

Instantly share code, notes, and snippets.

@debbbbie
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debbbbie/82fafdd305a0f9eeb401 to your computer and use it in GitHub Desktop.
Save debbbbie/82fafdd305a0f9eeb401 to your computer and use it in GitHub Desktop.

Contrived example demonstrating microgem dependencies

contrived is a microgem that depends on another microgem array_range, however gemspecs don't support DVCS dependencies. So how do we solve this without prematurely denting the universe?

Just use bundler.

Usage

Add all microgems to your project's Gemfile:

gem 'contrived', gist: 'b80fe32305890c2a8286'
gem 'array_range', gist: 'be9c16b2cd94abf6625c'

Live example

$ git clone https://gist.github.com/b80fe32305890c2a8286.git contrived
...
$ cd contrived
$ bundle
...
$ bundle exec ruby -e 'require "contrived";puts Contrived.new.foo'
0..3
$
Gem::Specification.new do |s|
s.name = 'contrived'
s.summary = 'contrived'
s.description = 'contrived'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.files = ['contrived.rb']
s.require_path = '.'
s.author = 'Barry Allard'
s.email = 'barry.allard@gmail.com'
s.license = 'MIT'
s.homepage = 'https://gist.github.com/steakknife/b80fe32305890c2a8286'
s.add_dependency('array_range', [">= 0.0.1", '< 1'])
end
require 'array_range'
class Contrived
def foo
[1,2,3,4].range
end
end
gemspec
gem 'array_range', git: 'https://gist.github.com/be9c16b2cd94abf6625c.git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment