Project

envandle

0.0
No commit activity in last 3 years
No release in over 3 years
A library for enabling Gemfiles to specify gem locations from environment variables.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.13
~> 10.0
~> 3.5
 Project Readme

Envandle

A rubygem for enabling Gemfiles to specify gem locations from environment variables.

Build Status

Installation

$ gem install envandle

Usage

Enclose your Gemfile's code with an envandle block.

require "envandle"

binding.envandle do
  source "https://rubygems.org"

  gem "mygem", "~> 1.0"
end

Set the environment variables.

export ENVANDLE_GEM_PATH=mygem:/path/to/mygem

And execute Bundler.

$ bundle

Examples

Setting Paths

You can specify the gem method's path option by setting the ENVANDLE_GEM_PATH variable.

For example,

ENV["ENVANDLE_GEM_PATH"] = "mygem:/path/to/mygem"

binding.envandle do
  source "https://rubygems.org"

  gem "mygem", "~> 1.0"
end

is evaluated as:

gem "mygem", path: "/path/to/mygem"

If the variable is not set,

ENV["ENVANDLE_GEM_PATH"] = ""

binding.envandle do
  source "https://rubygems.org"

  gem "mygem", "~> 1.0"
end

is evaluated as:

gem "mygem", "~> 1.0"

Setting Git Branches

You can specify the gem method's git and branch options by setting the ENVANDLE_GEM_GIT_BRANCH variable.

For example,

ENV["ENVANDLE_GEM_GIT_BRANCH"] = "mygem:https://github.com/mosop/mygem.git#edge"

envandle do
  source "https://rubygems.org"

  gem "mygem", "~> 1.0"
end

is evaluated as:

gem "mygem", git: "https://github.com/mosop/mygem.git", branch: "edge"

If the variable is not set,

ENV["ENVANDLE_GEM_GIT_BRANCH"] = ""

binding.envandle do
  source "https://rubygems.org"

  gem "mygem", "~> 1.0"
end

is evaluated as:

gem "mygem", "~> 1.0"

Setting Git Commit IDs

You can specify the gem method's git and ref options by setting the ENVANDLE_GEM_GIT_REF variable.

ENV["ENVANDLE_GEM_GIT_REF"] = "mygem:https://github.com/mosop/mygem.git#aed3d9b9965b6938cca7490e98423cf9b5908b09"

Specifying Gemspecs

You can also specify a gemspec not a single gem.

For example, if your gem's name is "mygem", the gemspec refers the a, b and c gems and the c's version requirement is "~> 1.0",

ENV["ENVANDLE_GEM_PATH"] = "a:/path/to/a;b:/path/to/b"

binding.envandle do
  source "https://rubygems.org"

  gemspec
end

is evaluated as:

gem "mygem", path: "."
gem "a", path: "/path/to/a"
gem "b", path: "/path/to/b"
gem "c", "~> 1.0"

Resolving Multilevel Dependencies

For example, if a Gemfile refers the gem a that depends on the gem b, Envandle also tries to resolve the b's reference by the environment variables.

ENV["ENVANDLE_GEM_PATH"] = "a:/path/to/a;b:/path/to/b"

binding.envandle do
  source "https://rubygems.org"

  gem "a", "~> 1.0"
end

is evaluated as:

gem "a", path: "/path/to/a"
gem "b", path: "/path/to/b"

install-envandle

The install-envandle command just installs Envandle itself with the bundle install command. It's useful for successfully loading Envandle in your Gemfile with the Bundler's --path option.

$ install-envandle -h
install-envandle [OPTIONS]

Installs Envandle using Bundler.

Options:
  --envandle-source      gem source (default: https://rubygems.org)
  --envandle-bundle-bin  command path (default: bundle)

Additionally, you can specify all of the bundle-install's options.

Usage Example

$ gem install bundler
$ gem install envandle
$ install-envandle --path vendor/bundle
$ bundle install