-
-
Save jimmycuadra/ee7bf493b57ffce403b2 to your computer and use it in GitHub Desktop.
Bundler subgroups, second approach
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
source "https://rubygems.org" | |
# Internal: A Hash of Procs containing subgroup code. | |
@subgroups = {} | |
# Public: Defines a subgroup for later inclusion in an environment-based group. | |
# | |
# name - A Symbol name for the group. | |
# block - A Proc to be called when the subgroup is included. | |
# | |
# Returns nothing. | |
def subgroup(name, &block) | |
@subgroups[name] = block | |
end | |
# Public: Includes gems in a group by evaluating stored Procs within an environment-based group. | |
# | |
# group_name - The Symbol name of the group to compose. | |
# subgroup_names - One or more Symbol names of the subgroup(s) to include. | |
# | |
# Returns nothing. | |
def compose_group(group_name, *subgroup_names) | |
group(group_name) do | |
subgroup_names.each { |name| @subgroups[name].call } | |
end | |
end | |
### Default gems | |
### These gems are required in all environments. | |
gem "rails", "3.0.13" | |
gem "mysql2" | |
### Subgroups | |
subgroup :debugger do | |
gem "debugger", require: nil | |
end | |
subgroup :pry do | |
gem "pry" | |
gem "pry-rails", require: nil | |
gem "pry-nav" | |
gem "pry-coolline" | |
gem "pry-doc" | |
end | |
subgroup :factories do | |
gem "factory_girl_rails" | |
end | |
subgroup :test_frameworks do | |
gem "rspec-rails" | |
gem "cucumber-rails", require: nil | |
gem "capybara" | |
end | |
subgroup :test_support do | |
gem "simplecov", require: nil | |
gem "spork" | |
end | |
subgroup :test_doubles do | |
gem "rr" | |
gem "vcr" | |
end | |
subgroup :console do | |
gem "wirble" | |
gem "hirb" | |
end | |
### Groups | |
### These groups will be loaded by Bundler based on Rack environment. Each | |
### call to compose_group defines an environment group and the list of | |
### subgroups that compose it. | |
compose_group :development, | |
:factories, :console, :debugger, :pry | |
compose_group :test, | |
:factories, :test_frameworks, :test_support, :test_doubles, | |
:debugger, :pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment