Skip to content

Commit

Permalink
initial issues plugin commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brentvatne committed Sep 17, 2011
1 parent 184249c commit 0422f47
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gem 'tinder'
gem 'nokogiri'
gem 'json'
gem 'twss'
gem 'octopi'

group :development do
gem 'jeweler'
Expand Down
26 changes: 22 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GEM
activesupport (3.1.0)
multi_json (~> 1.0)
addressable (2.2.6)
api_cache (0.2.3)
classifier (1.3.1)
stemmer (>= 1.0.0)
crack (0.1.8)
Expand All @@ -12,22 +13,36 @@ GEM
faraday (0.7.4)
addressable (~> 2.2.6)
multipart-post (~> 1.1.0)
rack (>= 1.1.0, < 2)
rack (< 2, >= 1.1.0)
faraday_middleware (0.7.0)
faraday (~> 0.7.3)
git (1.2.5)
hashie (1.1.0)
http_parser.rb (0.5.2)
httparty (0.7.8)
crack (= 0.1.8)
jeweler (1.6.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
json (1.5.4)
mechanize (2.0.1)
net-http-digest_auth (>= 1.1.1, ~> 1.1)
net-http-persistent (~> 1.8)
nokogiri (~> 1.4)
webrobots (>= 0.0.9, ~> 0.0)
mime-types (1.16)
mocha (0.9.12)
multi_json (1.0.3)
multipart-post (1.1.3)
net-http-digest_auth (1.1.1)
net-http-persistent (1.9)
nokogiri (1.5.0)
octopi (0.4.5)
api_cache
httparty (>= 0.4.5)
mechanize (>= 0.9.3)
nokogiri (>= 1.3.1)
rack (1.3.2)
rake (0.9.2)
rcov (0.9.10)
Expand All @@ -42,10 +57,10 @@ GEM
simple_oauth (0.1.5)
stemmer (1.0.1)
tinder (1.6.0)
activesupport (>= 2.3, < 4)
activesupport (< 4, >= 2.3)
eventmachine (~> 0.12)
faraday (>= 0.6, < 0.8)
faraday_middleware (>= 0.6, < 0.8)
faraday (< 0.8, >= 0.6)
faraday_middleware (< 0.8, >= 0.6)
hashie (~> 1.0)
mime-types (~> 1.16)
multi_json (~> 1.0)
Expand All @@ -61,6 +76,8 @@ GEM
webmock (1.7.6)
addressable (~> 2.2, > 2.2.5)
crack (>= 0.1.7)
webrobots (0.0.11)
nokogiri (>= 1.4.4)

PLATFORMS
ruby
Expand All @@ -70,6 +87,7 @@ DEPENDENCIES
json
mocha
nokogiri
octopi
rcov
rspec
tinder
Expand Down
1 change: 1 addition & 0 deletions lib/moneypenny.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require 'moneypenny/plugins/responders/help'
require 'moneypenny/plugins/responders/define'
require 'moneypenny/plugins/responders/version'
require 'moneypenny/plugins/responders/issues'

#listeners
require 'moneypenny/plugins/listeners/thats_what_she_said'
Expand Down
54 changes: 54 additions & 0 deletions lib/moneypenny/plugins/responders/issues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require 'json'
require 'open-uri'
require 'cgi'
require 'octopi'

module Moneypenny
module Plugins
module Responders
class Issues < Responder
def self.default_config
{ 'user' => 'moneypenny-bot',
'repo' => 'moneypenny',
'version' => '0.1' }
end

def help
[ 'show me moneypenny-bot/moneypenny issues', 'returns a list of public issues for the specified repository' ]
end

def respond(message)
case message
when /^show me ([\w\-\._]+)\/([\w\-\._]+) issues$/i #assigned to name
repo_user = $1
repo_name = $2
issue_response repo_user, repo_name
when /^show me issues$/i
issue_response
else
false
end
end

private
def repository(repo_user, repo_name)
# @cache ||= Hash.new({})
# cached_repo = @cache.fetch(repo_user) do |key|
# {key => Octopi::Repository.find(:name => repo_name, :user => repo_user)}
# end
# @cache
Octopi::Repository.find(:name => repo_name, :user => repo_user)
end

def issue_response(repo_user = config['user'], repo_name = config['repo'])
issues = repository(repo_user, repo_name).issues.map do |i|
issue_url = "https://github.com/#{repo_user}/#{repo_name}/issues/#{i.number}"
" * ##{i.number}: #{i.title} - #{issue_url}"
end.join("\n")
rescue NoMethodError
return "I was unable to find any issues, sir!"
end
end
end
end
end

0 comments on commit 0422f47

Please sign in to comment.