Class: Github::Contributions::List

Inherits:
Object
  • Object
show all
Defined in:
lib/github-contributions/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, current_user, options = {}) ⇒ List



7
8
9
10
# File 'lib/github-contributions/list.rb', line 7

def initialize connection,current_user, options = {}
  @current_user=current_user
  @connection = connection 
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/github-contributions/list.rb', line 6

def connection
  @connection
end

#current_userObject (readonly)

Returns the value of attribute current_user.



6
7
8
# File 'lib/github-contributions/list.rb', line 6

def current_user
  @current_user
end

Instance Method Details

#find_contributors(org, repo) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/github-contributions/list.rb', line 44

def find_contributors(org,repo)
  @repos_contributions=@connection.repos.contributors(auto_pagination: true,repo:repo,anon:1,user:org).map(&:login) rescue []
  if @repos_contributions.include? @current_user
    combo=org+"/"+repo
    @your_contri.push(combo)
  end
  if @your_contri.nil?
    @your_contri="No Contribution"
  end
  @your_contri
end

#find_list_of_orgsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/github-contributions/list.rb', line 17

def find_list_of_orgs
  @repos_org=Array.new()
  @repos_contributions=Array.new()
  @your_contri=Array.new()
  @orgs =Array.new()
  @orgs.push(@current_user)
  @orgs.push(@connection.orgs.list.map(&:login))
  @orgs=@orgs.flatten.compact
  results = []
  @orgs.collect do |org|
    results << self.find_repo_of_org(org)
  end
  results
end

#find_repo_of_org(org) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/github-contributions/list.rb', line 32

def find_repo_of_org(org)
  @repos_org.push(@connection.repos.all(auto_pagination:true).map(&:name))
  @repos_org.push(@connection.repos.list(auto_pagination: true,user:org).map(&:name))
  results = []
  @repos_org.collect do |repos|
    repos.collect do |repo|
      results << self.find_contributors(org,repo)
    end
  end
  results
end

#listObject



12
13
14
15
# File 'lib/github-contributions/list.rb', line 12

def list
  @list=find_list_of_orgs
  @list.flatten.compact.uniq
end