Skip to content

Instantly share code, notes, and snippets.

@jorgemanrubia
Last active December 10, 2015 04:18
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 jorgemanrubia/4379665 to your computer and use it in GitHub Desktop.
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.
# 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