Sha256: cfc1ba442cc49a53f3765675d6adabb6987476f78d015bb9b8b5b193b7e29a4f
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
module Rocktumbler # The GroupFilter is a class responsible for filtering gems into group # and sorting the groups and their gems alphabetically. class GroupFilter def initialize(gem_dependencies, opts) @gem_dependencies = gem_dependencies @opts = opts end def filter gems_by_group = @gem_dependencies.group_by(&:groups) default_gems = gems_by_group.delete([:default]) default_gems.sort! groups = [Rocktumbler::Group.new(:default, default_gems, @opts)] gems_by_group_sorted = sort_groups(gems_by_group, default_gems) groups.concat(gems_by_group_sorted) end private def sort_groups(gems_by_group, default_gems) gems_by_group.inject([]) do |arr, (group, gems)| gems_unique_to_group = gems - default_gems gems_unique_to_group.sort! gems_unique_to_group.uniq! arr << Rocktumbler::Group.new(group, gems_unique_to_group, @opts) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rocktumbler-0.1.3 | lib/rocktumbler/group_filter.rb |