Class: Github::Repository

Inherits:
OpenStruct show all
Includes:
Api
Defined in:
lib/github.rb

Constant Summary collapse

ATTR_NAMES =
[:name, :url, :owner_name, :owner_email]

Instance Method Summary collapse

Methods included from Api

#fetch, included

Methods inherited from OpenStruct

#[], #[]=

Instance Method Details

#owner_emailObject



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/github.rb', line 74

def owner_email
  if owner.is_a?(Hash) && email = owner['email']
    return email if email
  end

  if organization
    Organization.fetch(:name => organization).member_emails
  else
    User.fetch(:name => owner_name).email
  end
end

#owner_nameObject



70
71
72
# File 'lib/github.rb', line 70

def owner_name
  owner.is_a?(Hash) ? owner['name'] : owner
end

#pathObject



86
87
88
# File 'lib/github.rb', line 86

def path
  "repos/show/#{owner_name}/#{name}"
end

#private?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/github.rb', line 90

def private?
  self['private']
end

#to_hashObject



66
67
68
# File 'lib/github.rb', line 66

def to_hash
  ATTR_NAMES.inject({}) { |result, name| result.merge(name => self.send(name)) }
end