Class: MirrorGithub::Github
- Inherits:
-
Object
- Object
- MirrorGithub::Github
- Defined in:
- lib/mirror_github/github.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#org ⇒ Object
Returns the value of attribute org.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(username, password, org = nil) ⇒ Github
constructor
A new instance of Github.
-
#repositories ⇒ Object
Return a list of the current repositories for an organization.
Constructor Details
#initialize(username, password, org = nil) ⇒ Github
Returns a new instance of Github.
15 16 17 18 19 20 |
# File 'lib/mirror_github/github.rb', line 15 def initialize(username, password, org = nil) self.username = username self.password = password self.org = org self.connection = RestClient::Resource.new Github.api_url, :user => username, :password => password end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
13 14 15 |
# File 'lib/mirror_github/github.rb', line 13 def connection @connection end |
#org ⇒ Object
Returns the value of attribute org.
13 14 15 |
# File 'lib/mirror_github/github.rb', line 13 def org @org end |
#password ⇒ Object
Returns the value of attribute password.
13 14 15 |
# File 'lib/mirror_github/github.rb', line 13 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
13 14 15 |
# File 'lib/mirror_github/github.rb', line 13 def username @username end |
Class Method Details
.api_url ⇒ Object
8 9 10 |
# File 'lib/mirror_github/github.rb', line 8 def api_url 'https://api.github.com' end |
Instance Method Details
#repositories ⇒ Object
Return a list of the current repositories for an organization
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mirror_github/github.rb', line 23 def repositories return [] unless org JSON::parse(connection["orgs/#{org}/repos"].get).collect do |repo_hash| Repository.new(:ssh_url => repo_hash['ssh_url'], :private => repo_hash['private'], :created_at => repo_hash["created_at"], :pushed_at => repo_hash["pushed_at"], :name => repo_hash["name"]) end end |