Last active
December 10, 2015 04:18
-
-
Save jorgemanrubia/4379665 to your computer and use it in GitHub Desktop.
Exclude gems in heroku Cedar. Heroku will ignore :development and :test by default, but not other groups (such as :cucumber). Previous Bamboo stack let you define BUNDLE_WITHOUT, but it doesn't work anymore on Cedar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this code in some file and require it at the beginning of your Gemfile | |
# Then you can list the groups to exclude from heroku. E.g: | |
# | |
# exclude_in_heroku :cucumber, :development, :test | |
# | |
# Based on this post by Matt Campbell: http://soupmatt.com/fixing-bundlewithout-on-heroku-cedar, | |
# which is based in an idea by @grosser. All the credits to them. | |
module Bundler | |
class Dsl | |
old_group = instance_method(:group) | |
def exclude_in_heroku(*groups) | |
@gems_to_exclude = groups | |
end | |
def gems_to_exclude | |
@gems_to_exclude ||= [] | |
end | |
define_method(:group) do |*groups, &block| | |
should_exclude = groups.find{|group| gems_to_exclude.include?(group)} | |
groups = (should_exclude && ENV['HOME'].gsub('/', '') == 'app') ? 'test' : groups | |
old_group.bind(self).(*groups, &block) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment