Class: FavLanguage::RepoList

Inherits:
Object
  • Object
show all
Defined in:
lib/fav_language/repo_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(github:, username:) ⇒ RepoList

Returns a new instance of RepoList.



7
8
9
10
# File 'lib/fav_language/repo_list.rb', line 7

def initialize(github:, username:)
  @github = github
  @username = username
end

Instance Attribute Details

#githubObject (readonly)

Returns the value of attribute github.



5
6
7
# File 'lib/fav_language/repo_list.rb', line 5

def github
  @github
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/fav_language/repo_list.rb', line 5

def username
  @username
end

Instance Method Details

#fetchObject



12
13
14
15
16
17
# File 'lib/fav_language/repo_list.rb', line 12

def fetch
  @repos ||= github.repos
              .list(user: username, auto_pagination: true)
              .reject{ |r| r["fork"] }
              .map{ |r| Repo.new(r, github: github) }
end

#language_statsObject



19
20
21
22
23
# File 'lib/fav_language/repo_list.rb', line 19

def language_stats
  fetch.flat_map do |repo|
    repo.language_stats
  end
end