Class: Gitti::GitRepoSet
- Inherits:
-
Object
- Object
- Gitti::GitRepoSet
- Defined in:
- lib/gitti/reposet.rb
Overview
todo: rename to Hash/Dict/List/Map or use GitHubRepoSet ??
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(hash) ⇒ GitRepoSet
constructor
A new instance of GitRepoSet.
- #size ⇒ Object
Constructor Details
#initialize(hash) ⇒ GitRepoSet
Returns a new instance of GitRepoSet.
14 15 16 |
# File 'lib/gitti/reposet.rb', line 14 def initialize( hash ) @hash = hash end |
Class Method Details
.read(path) ⇒ Object
7 8 9 10 11 |
# File 'lib/gitti/reposet.rb', line 7 def self.read( path ) txt = File.open( path, 'r:utf-8') { |f| f.read } hash = YAML.load( txt ) new( hash ) end |
Instance Method Details
#each ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitti/reposet.rb', line 23 def each @hash.each do |org_with_counter,names| ## remove optional number from key e.g. ## mrhydescripts (3) => mrhydescripts ## footballjs (4) => footballjs ## etc. org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip ## puts " -- #{key_with_counter} [#{key}] --" yield( org, names ) end end |
#size ⇒ Object
18 19 20 21 |
# File 'lib/gitti/reposet.rb', line 18 def size ## sum up total number of repos @size ||= @hash.reduce(0) {|sum,(_,names)| sum+= names.size; sum } end |