Class: Cinch::Plugins::Github::Issue

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin, Octopi
Defined in:
lib/cinch/plugins/github/issue.rb

Overview

Handles interaction with Issues API.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.authorObject

Returns the value of attribute author.



13
14
15
# File 'lib/cinch/plugins/github/issue.rb', line 13

def author
  @author
end

.repoObject

Returns the value of attribute repo.



13
14
15
# File 'lib/cinch/plugins/github/issue.rb', line 13

def repo
  @repo
end

.tokenObject

Returns the value of attribute token.



13
14
15
# File 'lib/cinch/plugins/github/issue.rb', line 13

def token
  @token
end

.userObject

Returns the value of attribute user.



13
14
15
# File 'lib/cinch/plugins/github/issue.rb', line 13

def user
  @user
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



15
16
17
# File 'lib/cinch/plugins/github/issue.rb', line 15

def configure(&block)
  yield self
end

Instance Method Details

#display_help(m) ⇒ Object

Display Github Issue Help



26
27
28
29
30
31
32
# File 'lib/cinch/plugins/github/issue.rb', line 26

def display_help(m)
  User(m.user.nick).send (<<-EOF).gsub(/^ {10}/,'')
  !issue state [open|closed] [query] - query for a ticket with state closed
  !issue find [query] - query for a ticket with state open
  !issue link [number] - returns link for issue number.
  EOF
end

#get_ticket(m, *args) ⇒ Object

Find ticket with gieven



35
36
37
38
39
# File 'lib/cinch/plugins/github/issue.rb', line 35

def get_ticket(m, *args)
  query, state = args.reverse
  results = search_issue CGI.escape(query), state
  output m, results.first.last
end

Returns the issue as a link



54
55
56
# File 'lib/cinch/plugins/github/issue.rb', line 54

def issue_link(number)
  "https://www.github.com/#{self.class.author}/#{self.class.repo}/issues/#{number}"
end

Return the link of the issue



42
43
44
# File 'lib/cinch/plugins/github/issue.rb', line 42

def reply_link(m, arg)
  arg =~ /\D+/ ? m.reply("You need to give me a number...") : m.reply(issue_link(arg))
end

#search_issue(query, state = 'open') ⇒ Object

Use Github API and Search for the Issue



47
48
49
50
51
# File 'lib/cinch/plugins/github/issue.rb', line 47

def search_issue(query, state = 'open')
  authenticated_with :login => self.class.user, :token => self.class.token do
    Octopi::Issue.search :user => self.class.author, :repo => self.class.repo, :state => state, :keyword => query
  end
end