Class: OctocatHerder::Repository

Inherits:
Base
  • Object
show all
Defined in:
lib/octocat_herder/repository.rb

Instance Attribute Summary

Attributes inherited from Base

#connection, #raw

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#available_attributes, #initialize, #method_missing

Constructor Details

This class inherits a constructor from OctocatHerder::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OctocatHerder::Base

Class Method Details

.method_missing(id, *args) ⇒ Object

Raises:

  • (NoMethodError)


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/octocat_herder/repository.rb', line 9

def self.method_missing(id, *args)
  if id.id2name =~ /list_(.+)/
    repository_type = Regexp.last_match(1)
    if ['all', 'private', 'public', 'member'].include? repository_type
      arguments = [args[0], args[1], repository_type]
      arguments << args[2] unless args[2].nil?

      return self.list(*arguments)
    end
  end

  raise NoMethodError.new("undefined method #{id.id2name} for #{self}:#{self.class}")
end

Instance Method Details

#closed_pull_requestsObject



47
48
49
# File 'lib/octocat_herder/repository.rb', line 47

def closed_pull_requests
  OctocatHerder::PullRequest.find_for_repository(, name, 'closed')
end

#open_pull_requestsObject



43
44
45
# File 'lib/octocat_herder/repository.rb', line 43

def open_pull_requests
  OctocatHerder::PullRequest.find_for_repository(, name, 'open')
end

#ownerObject



39
40
41
# File 'lib/octocat_herder/repository.rb', line 39

def owner
  OctocatHerder::User.fetch(, connection)
end

#owner_avatar_urlObject



31
32
33
# File 'lib/octocat_herder/repository.rb', line 31

def owner_avatar_url
  @raw['owner']['avatar_url']
end

#owner_idObject



27
28
29
# File 'lib/octocat_herder/repository.rb', line 27

def owner_id
  @raw['owner']['id']
end

#owner_loginObject



23
24
25
# File 'lib/octocat_herder/repository.rb', line 23

def 
  @raw['owner']['login']
end

#owner_urlObject



35
36
37
# File 'lib/octocat_herder/repository.rb', line 35

def owner_url
  @raw['owner']['url']
end

#sourceObject



51
52
53
54
55
# File 'lib/octocat_herder/repository.rb', line 51

def source
  return unless @raw['source']

  OctocatHerder::Repository.new(@raw['source'], connection)
end