Class: NewsStand::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/news_stand/github.rb,
lib/news_stand/github/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Github

Returns a new instance of Github.



7
8
9
10
11
12
# File 'lib/news_stand/github.rb', line 7

def initialize(options = {})
  @user = options['user']
  @repo = options['repo']
  @access_token = options['access_token']
  @issue_api = ::Github.new(oauth_token: access_token).issues
end

Instance Method Details

#all(state = 'open') ⇒ Object



14
15
16
# File 'lib/news_stand/github.rb', line 14

def all(state = 'open')
  @issue_api.list(user: user, repo: repo, state: state)
end

#get(number) ⇒ Object



18
19
20
# File 'lib/news_stand/github.rb', line 18

def get(number)
  @issue_api.find(user, repo, number)
end

#set(attributes = {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/news_stand/github.rb', line 22

def set(attributes = {})
  if attributes['number']
    number = attributes.delete('number')
    @issue_api.edit(user, repo, number, attributes)
  else
    @issue_api.create(user, repo, attributes)
  end
end