Class: Atreides::Github
- Inherits:
-
Object
show all
- Defined in:
- app/models/atreides/github.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(json_data) ⇒ Github
Returns a new instance of Github.
4
5
6
|
# File 'app/models/atreides/github.rb', line 4
def initialize(json_data)
@data = Hashie::Mash.new(json_data)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
8
9
10
|
# File 'app/models/atreides/github.rb', line 8
def method_missing(method)
@data.send(method)
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2
3
4
|
# File 'app/models/atreides/github.rb', line 2
def data
@data
end
|
Class Method Details
.all(options = {}) ⇒ Object
19
20
21
|
# File 'app/models/atreides/github.rb', line 19
def all(options={})
issues(options)
end
|
.authorize_url ⇒ Object
40
41
42
|
# File 'app/models/atreides/github.rb', line 40
def authorize_url
client.auth_code.authorize_url(:redirect_uri => Settings.github.callback, :scope => Settings.github.scope)
end
|
.find(id) ⇒ Object
23
24
25
|
# File 'app/models/atreides/github.rb', line 23
def find(id)
Atreides::Github.new(issue(id))
end
|
.get(method, params = {}) ⇒ Object
36
37
38
|
# File 'app/models/atreides/github.rb', line 36
def get(method, params={})
access_token.get("https://api.github.com/#{method}", params)
end
|
.get_token(code) ⇒ Object
44
45
46
|
# File 'app/models/atreides/github.rb', line 44
def get_token(code)
client.auth_code.get_token(code, :redirect_uri => Settings.github.callback)
end
|
.issue(id) ⇒ Object
27
28
29
|
# File 'app/models/atreides/github.rb', line 27
def issue(id)
JSON.parse( get("repos/#{Settings.github.user}/#{Settings.github.repo}/issues/#{id}").body )
end
|
.issues(options) ⇒ Object
31
32
33
34
|
# File 'app/models/atreides/github.rb', line 31
def issues(options)
options.reverse_merge!({:labels => "site,review me"})
JSON.parse( get("repos/#{Settings.github.user}/#{Settings.github.repo}/issues", {:params => options}).body )
end
|
Instance Method Details
12
13
14
15
|
# File 'app/models/atreides/github.rb', line 12
def
id = @data.number
@comments ||= (id)
end
|