# File lib/capillary/ref_collection.rb, line 21 def initialize @refs = { "heads" => [], "tags" => [], "remotes" => {} } end
# File lib/capillary/ref_collection.rb, line 29 def self.parse(ref) refs = new refs.parse(ref) refs end
# File lib/capillary/ref_collection.rb, line 40 def <<(full_ref) refs, type, *name = full_ref.strip.split("/") return if type.nil? type = type.gsub("-", "_") if type == "remotes" append_array_in_hash(@refs[type], name.shift, name) else append_array_in_hash(@refs, type, name) end end
# File lib/capillary/ref_collection.rb, line 60 def method_missing(method, *args, &block) key = method.to_s return super if !@refs.key?(key) || args.length != 0 @refs[key] end
# File lib/capillary/ref_collection.rb, line 35 def parse(ref) return if ref.nil? || ref == "" ref.gsub(/[\(\)]/,"").split(/,\s?/).each { |r| self << r } end
# File lib/capillary/ref_collection.rb, line 52 def to_hash @refs.dup end
# File lib/capillary/ref_collection.rb, line 56 def to_json JSON.unparse(@refs) end
# File lib/capillary/ref_collection.rb, line 67 def append_array_in_hash(hash, key, names) hash[key] ||= [] hash[key] << names.join("/") end