Sha256: 67bc530a348a682351eea3d07c23e150702380658a54aee91d81ae78746e637c
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
module Contributions class RepositoryList attr_reader :list def initialize(*args) @list = [args].flatten end # Public: Add a string or array of strings to the repository list. # # repos - a string or an array of strings (each of which is a # 'username/repo') # # Returns a RepositoryList def add(repos) @list.push(repos).flatten! self end # Public: Turn repositories into key value pairs. # # Returns an Array of Hashes {:username, :repository} def key_value_pairs results = [] @list.each do |e| p = e.split('/') results.push Hash[:username => p[0], :repository => p[1]] end results end # Public: Replace list of repositories with the list provided. # # repos - a string or an array of strings (each of which is a # 'username/repo') # # Returns a RepositoryList def only(repos) @list = [repos].flatten self end # Public: Remove a string or array of strings from the repository # list. # repos - a string or an array of strings (each of which is a # 'username/repo') # # Returns a RepositoryList def remove(repos) @list.delete_if { |e| [repos].flatten.include? e } self end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
contributions-0.2.0 | lib/contributions/repository_list.rb |
contributions-0.1.2 | lib/contributions/repository_list.rb |
contributions-0.1.1 | lib/contributions/repository_list.rb |