Class: Gitlang::Organization

Inherits:
Object
  • Object
show all
Includes:
GithubStats, Utilities
Defined in:
lib/gitlang/organization.rb

Overview

Class representing a GitHub organization

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#conditional_rescue

Methods included from GithubStats

#absolute_usage_per_language, #relative_usage_per_language

Constructor Details

#initialize(name, client) ⇒ Organization

Returns a new instance of Organization.



13
14
15
16
17
18
19
20
21
# File 'lib/gitlang/organization.rb', line 13

def initialize(name, client)
  @name = name.downcase
  @client = client
  @repositories = fetch_repo_names.each_with_object([]) do |repo_name, repositories|
    # There is a tight coupling between Organisation and Repository, but I
    # think it's fine regarding the scope of the application.
    repositories << Repository.new(@name, repo_name, @client)
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/gitlang/organization.rb', line 11

def name
  @name
end

#repositoriesObject (readonly)

Returns the value of attribute repositories.



11
12
13
# File 'lib/gitlang/organization.rb', line 11

def repositories
  @repositories
end

Instance Method Details

#usage_per_repoObject

Creates an array of hashes with the language usage for each repository.



24
25
26
27
28
29
30
# File 'lib/gitlang/organization.rb', line 24

def usage_per_repo
  conditional_rescue do
    @repositories.each_with_object([]) do |repository, result|
      result << repository.languages
    end
  end
end