For example, I have the following Gemfile:
source "https://rubygems.org"
group :example_group do
gem 'example_gem'
gem 'another_example_gem'
end
How can I list all gems inside :example_group in Ruby? Not really looking for a shell command.
For example, I have the following Gemfile:
source "https://rubygems.org"
group :example_group do
gem 'example_gem'
gem 'another_example_gem'
end
How can I list all gems inside :example_group in Ruby? Not really looking for a shell command.
Adapting from the Bundler::Graph, you could have :
Bundler.load.current_dependencies.select{|dep|
dep.groups.include?(:example_group)}.map(&:name)
Not sure what you are trying to do here, but some ideas:
So something like:
source "https://rubygems.org"
gems = []
group :example_group do
gem 'example_gem'
gems << gem 'another_example_gem'
end
group_gems = gems.select { |gm| gm.groups.include?(:example_group) }.map { |gm| gm.name }
p group_gems.uniq
Will print out your gems in the group when you use bundler (bundle install for example). Instead of printing them, you could save them somewhere.