moneypenny 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +25 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/moneypenny +19 -0
- data/lib/moneypenny.rb +12 -0
- data/lib/moneypenny/connections/campfire.rb +51 -0
- data/lib/moneypenny/connections/echo.rb +13 -0
- data/lib/moneypenny/moneypenny.rb +40 -0
- data/lib/moneypenny/null_logger.rb +5 -0
- data/lib/moneypenny/responders/help.rb +27 -0
- data/lib/moneypenny/responders/image.rb +28 -0
- data/lib/moneypenny/responders/weather.rb +27 -0
- data/lib/moneypenny/responders/wikipedia.rb +30 -0
- data/moneypenny.gemspec +81 -0
- data/spec/moneypenny_spec.rb +24 -0
- data/spec/spec_helper.rb +14 -0
- metadata +167 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.1.0)
|
5
|
+
multi_json (~> 1.0)
|
6
|
+
addressable (2.2.6)
|
7
|
+
diff-lcs (1.1.3)
|
8
|
+
eventmachine (0.12.10)
|
9
|
+
faraday (0.7.4)
|
10
|
+
addressable (~> 2.2.6)
|
11
|
+
multipart-post (~> 1.1.0)
|
12
|
+
rack (>= 1.1.0, < 2)
|
13
|
+
faraday_middleware (0.7.0)
|
14
|
+
faraday (~> 0.7.3)
|
15
|
+
git (1.2.5)
|
16
|
+
hashie (1.1.0)
|
17
|
+
http_parser.rb (0.5.2)
|
18
|
+
jeweler (1.6.4)
|
19
|
+
bundler (~> 1.0)
|
20
|
+
git (>= 1.2.5)
|
21
|
+
rake
|
22
|
+
json (1.5.4)
|
23
|
+
mime-types (1.16)
|
24
|
+
mocha (0.9.12)
|
25
|
+
multi_json (1.0.3)
|
26
|
+
multipart-post (1.1.3)
|
27
|
+
nokogiri (1.5.0)
|
28
|
+
rack (1.3.2)
|
29
|
+
rake (0.9.2)
|
30
|
+
rcov (0.9.10)
|
31
|
+
rspec (2.6.0)
|
32
|
+
rspec-core (~> 2.6.0)
|
33
|
+
rspec-expectations (~> 2.6.0)
|
34
|
+
rspec-mocks (~> 2.6.0)
|
35
|
+
rspec-core (2.6.4)
|
36
|
+
rspec-expectations (2.6.0)
|
37
|
+
diff-lcs (~> 1.1.2)
|
38
|
+
rspec-mocks (2.6.0)
|
39
|
+
simple_oauth (0.1.5)
|
40
|
+
tinder (1.6.0)
|
41
|
+
activesupport (>= 2.3, < 4)
|
42
|
+
eventmachine (~> 0.12)
|
43
|
+
faraday (>= 0.6, < 0.8)
|
44
|
+
faraday_middleware (>= 0.6, < 0.8)
|
45
|
+
hashie (~> 1.0)
|
46
|
+
mime-types (~> 1.16)
|
47
|
+
multi_json (~> 1.0)
|
48
|
+
multipart-post (~> 1.1)
|
49
|
+
twitter-stream (~> 0.1)
|
50
|
+
twitter-stream (0.1.14)
|
51
|
+
eventmachine (>= 0.12.8)
|
52
|
+
http_parser.rb (~> 0.5.1)
|
53
|
+
simple_oauth (~> 0.1.4)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
jeweler
|
60
|
+
json
|
61
|
+
mocha
|
62
|
+
nokogiri
|
63
|
+
rcov
|
64
|
+
rspec
|
65
|
+
tinder
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 John Wulff
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= Moneypenny
|
2
|
+
|
3
|
+
Moneypenny is a simple chat bot. Moneypenny works with Campfire but could be
|
4
|
+
made to work with other chat rooms easily. See lib/moneypenny/responders,
|
5
|
+
it's very easy to add more responders.
|
6
|
+
|
7
|
+
== Campfire Usage
|
8
|
+
|
9
|
+
bundle exec bin/moneypenny SUBDOMAIN ROOM API_TOKEN
|
10
|
+
|
11
|
+
== Contributing to moneypenny
|
12
|
+
|
13
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
14
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
15
|
+
* Fork the project
|
16
|
+
* Start a feature/bugfix branch
|
17
|
+
* Commit and push until you are happy with your contribution
|
18
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
19
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
20
|
+
|
21
|
+
== Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2011 John Wulff. See LICENSE.txt for
|
24
|
+
further details.
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "moneypenny"
|
18
|
+
gem.homepage = "http://github.com/jwulff/moneypenny"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Moneypenny is a chat bot.}
|
21
|
+
gem.description = %Q{Moneypenny is a chat bot.}
|
22
|
+
gem.email = "johnw@orcasnet.com"
|
23
|
+
gem.authors = [ 'John Wulff', 'Doug Cole' ]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "moneypenny #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/moneypenny
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../lib/moneypenny'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
subdomain = ARGV[0]
|
6
|
+
room = ARGV[1]
|
7
|
+
api_token = ARGV[2]
|
8
|
+
|
9
|
+
if !subdomain || !room || !api_token
|
10
|
+
puts "./moneypenny SUBDOMAIN ROOM API_TOKEN"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
connection = Moneypenny::Connections::Campfire.new subdomain, room, api_token
|
15
|
+
logger = Logger.new STDOUT
|
16
|
+
logger.level = Logger::DEBUG
|
17
|
+
moneypenny = Moneypenny::Moneypenny.new connection, logger
|
18
|
+
moneypenny.say 'Hello, Moneypenny here at your service.'
|
19
|
+
moneypenny.listen!
|
data/lib/moneypenny.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
5
|
+
|
6
|
+
require 'moneypenny/moneypenny'
|
7
|
+
require 'moneypenny/connections/campfire'
|
8
|
+
require 'moneypenny/connections/echo'
|
9
|
+
require 'moneypenny/responders/weather'
|
10
|
+
require 'moneypenny/responders/wikipedia'
|
11
|
+
require 'moneypenny/responders/image'
|
12
|
+
require 'moneypenny/responders/help'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'tinder'
|
2
|
+
|
3
|
+
module Moneypenny
|
4
|
+
module Connections
|
5
|
+
class Campfire
|
6
|
+
def initialize(subdomain, room_name, api_token)
|
7
|
+
@subdomain = subdomain
|
8
|
+
@room_name = room_name
|
9
|
+
@api_token = api_token
|
10
|
+
end
|
11
|
+
|
12
|
+
def room
|
13
|
+
unless @room
|
14
|
+
campfire = Tinder::Campfire.new @subdomain, :token => @api_token
|
15
|
+
@id = campfire.me['id']
|
16
|
+
@room = campfire.find_room_by_name @room_name
|
17
|
+
raise 'Unknown Room' unless @room
|
18
|
+
end
|
19
|
+
@room
|
20
|
+
end
|
21
|
+
|
22
|
+
def reconnect
|
23
|
+
@room = nil
|
24
|
+
room
|
25
|
+
end
|
26
|
+
|
27
|
+
def say(message)
|
28
|
+
if message.include?("\n")
|
29
|
+
room.paste message
|
30
|
+
else
|
31
|
+
room.speak message
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def listen(&block)
|
36
|
+
begin
|
37
|
+
room.listen do |message|
|
38
|
+
begin
|
39
|
+
block.call(message['body']) if message['user']['id'] != @id
|
40
|
+
rescue Exception => exception
|
41
|
+
puts exception.to_s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue Tinder::ListenFailed
|
45
|
+
reconnect
|
46
|
+
retry
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Moneypenny
|
2
|
+
class Moneypenny
|
3
|
+
attr_accessor :connection, :logger
|
4
|
+
|
5
|
+
def initialize(connection, logger)
|
6
|
+
@connection = connection
|
7
|
+
@logger = logger
|
8
|
+
end
|
9
|
+
|
10
|
+
def listen!
|
11
|
+
@connection.listen do |message|
|
12
|
+
hear message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def say(message)
|
17
|
+
@connection.say message
|
18
|
+
logger.debug "Said: #{message}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def hear(message)
|
22
|
+
logger.debug "Heard: #{message}"
|
23
|
+
if message.match(/\A(mp|moneypenny)/i)
|
24
|
+
message.gsub! /\A(mp|moneypenny)(\,|)/i, ''
|
25
|
+
message.strip!
|
26
|
+
responded = false
|
27
|
+
Responders.constants.each do |responder|
|
28
|
+
response = eval("Responders::#{responder}").respond message
|
29
|
+
if response
|
30
|
+
say response
|
31
|
+
responded = true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
unless responded
|
35
|
+
say "Sorry, I do not know how to respond to that."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Moneypenny
|
6
|
+
module Responders
|
7
|
+
class Help
|
8
|
+
def self.help
|
9
|
+
[ 'help', 'returns a list of available commands' ]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.respond(message)
|
13
|
+
if (query = message.match(/\Ahelp\z/i))
|
14
|
+
helps = []
|
15
|
+
Responders.constants.each do |responder|
|
16
|
+
helps << eval("Responders::#{responder}").help rescue nil
|
17
|
+
end
|
18
|
+
ljust = helps.collect{|x| x[0].size }.max + 3
|
19
|
+
helps.collect!{ |x| x[0].to_s.ljust(ljust) + x[1].to_s }
|
20
|
+
helps.join("\n")
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Moneypenny
|
6
|
+
module Responders
|
7
|
+
class Image
|
8
|
+
def self.help
|
9
|
+
[ 'find a kitten image', 'returns a random kitten picture from Google Image search' ]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.respond(message)
|
13
|
+
if (match = message.match(/\Afind\ (a|an)\ (.+)\ (image|picture|photo)\z/i))
|
14
|
+
query = match[2]
|
15
|
+
url = "https://ajax.googleapis.com/ajax/services/search/images?safe=off&rsz=8&v=1.0&q=#{CGI::escape query}"
|
16
|
+
images = JSON.parse(open(url).read)['responseData']['results'] rescue []
|
17
|
+
if images.any?
|
18
|
+
images[rand(8)]['url']
|
19
|
+
else
|
20
|
+
"I couldn't find #{match[1]} #{match[2]} image."
|
21
|
+
end
|
22
|
+
else
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Moneypenny
|
6
|
+
module Responders
|
7
|
+
class Weather
|
8
|
+
def self.help
|
9
|
+
[ 'weather in Seattle?', 'returns the current weather in Seattle' ]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.respond(message)
|
13
|
+
if message.downcase.include?('weather') && (query = message.match(/in\ (.+)(\?|)\z/i))
|
14
|
+
doc = Nokogiri::HTML open("http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=#{CGI::escape query[1]}")
|
15
|
+
location = doc.xpath('//current_observation/display_location/full').text.gsub(',', '')
|
16
|
+
weather = doc.xpath('//current_observation/weather').text.downcase.strip
|
17
|
+
temperature = doc.xpath('//current_observation/temp_f').text.downcase.strip
|
18
|
+
wind = doc.xpath('//current_observation/wind_string').text.downcase.strip
|
19
|
+
visibility = doc.xpath('//current_observation/visibility_mi').text.downcase.strip
|
20
|
+
"It's #{temperature}° in #{location}, #{weather}, wind #{wind}, #{visibility} miles visibility."
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Moneypenny
|
6
|
+
module Responders
|
7
|
+
class Wikipedia
|
8
|
+
def self.help
|
9
|
+
[ 'what is Soap?', 'returns Wikipedia description for Soap' ]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.respond(message)
|
13
|
+
if (query = message.match(/\Awhat\ is\ (.+)(\?|)\z/i))
|
14
|
+
query = query[1]
|
15
|
+
agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1'
|
16
|
+
response = open("http://en.wikipedia.org/w/api.php?action=opensearch&search=#{CGI::escape query}&format=xml&limit=1", 'User-Agent' => agent).read
|
17
|
+
description = response.match(/\<Description\ xml\:space\=\"preserve\"\>(.+)\<\/Description\>/m)[1] rescue nil
|
18
|
+
url = response.match(/\<Url\ xml\:space\=\"preserve\"\>(.+)\<\/Url\>/m)[1] rescue nil
|
19
|
+
if description
|
20
|
+
description + " (#{url})"
|
21
|
+
else
|
22
|
+
"I couldn't find any information on #{query}."
|
23
|
+
end
|
24
|
+
else
|
25
|
+
false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/moneypenny.gemspec
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{moneypenny}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["John Wulff", "Doug Cole"]
|
12
|
+
s.date = %q{2011-09-03}
|
13
|
+
s.default_executable = %q{moneypenny}
|
14
|
+
s.description = %q{Moneypenny is a chat bot.}
|
15
|
+
s.email = %q{johnw@orcasnet.com}
|
16
|
+
s.executables = ["moneypenny"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"bin/moneypenny",
|
31
|
+
"lib/moneypenny.rb",
|
32
|
+
"lib/moneypenny/connections/campfire.rb",
|
33
|
+
"lib/moneypenny/connections/echo.rb",
|
34
|
+
"lib/moneypenny/moneypenny.rb",
|
35
|
+
"lib/moneypenny/null_logger.rb",
|
36
|
+
"lib/moneypenny/responders/help.rb",
|
37
|
+
"lib/moneypenny/responders/image.rb",
|
38
|
+
"lib/moneypenny/responders/weather.rb",
|
39
|
+
"lib/moneypenny/responders/wikipedia.rb",
|
40
|
+
"moneypenny.gemspec",
|
41
|
+
"spec/moneypenny_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
s.homepage = %q{http://github.com/jwulff/moneypenny}
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = %q{1.3.6}
|
48
|
+
s.summary = %q{Moneypenny is a chat bot.}
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
+
s.specification_version = 3
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
55
|
+
s.add_runtime_dependency(%q<tinder>, [">= 0"])
|
56
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
57
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
60
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<tinder>, [">= 0"])
|
64
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
65
|
+
s.add_dependency(%q<json>, [">= 0"])
|
66
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
67
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
68
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<tinder>, [">= 0"])
|
73
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
74
|
+
s.add_dependency(%q<json>, [">= 0"])
|
75
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
77
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Moneypenny" do
|
4
|
+
before(:each) do
|
5
|
+
@connection = mock('connection', :listen => nil)
|
6
|
+
@logger = NullLogger.new
|
7
|
+
@bot = Moneypenny::Moneypenny.new(@connection, @logger)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "say" do
|
11
|
+
it "delegates to the @connection" do
|
12
|
+
message = stub('message')
|
13
|
+
@connection.expects(:say).with(message)
|
14
|
+
@bot.say( message )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "hear" do
|
19
|
+
it "ignores messages that don't start with moneypenny or mp" do
|
20
|
+
@connection.expects(:say).never
|
21
|
+
@bot.hear('foo')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'mocha'
|
5
|
+
require 'moneypenny'
|
6
|
+
require 'moneypenny/null_logger'
|
7
|
+
|
8
|
+
# Requires supporting files with custom matchers and macros, etc,
|
9
|
+
# in ./support/ and its subdirectories.
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moneypenny
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- John Wulff
|
13
|
+
- Doug Cole
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-09-03 00:00:00 -07:00
|
19
|
+
default_executable: moneypenny
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 0
|
28
|
+
version: "0"
|
29
|
+
requirement: *id001
|
30
|
+
name: tinder
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
segments:
|
39
|
+
- 0
|
40
|
+
version: "0"
|
41
|
+
requirement: *id002
|
42
|
+
name: nokogiri
|
43
|
+
prerelease: false
|
44
|
+
type: :runtime
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
requirement: *id003
|
54
|
+
name: json
|
55
|
+
prerelease: false
|
56
|
+
type: :runtime
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirement: *id004
|
66
|
+
name: jeweler
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirement: *id005
|
78
|
+
name: rspec
|
79
|
+
prerelease: false
|
80
|
+
type: :development
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirement: *id006
|
90
|
+
name: mocha
|
91
|
+
prerelease: false
|
92
|
+
type: :development
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
requirement: *id007
|
102
|
+
name: rcov
|
103
|
+
prerelease: false
|
104
|
+
type: :development
|
105
|
+
description: Moneypenny is a chat bot.
|
106
|
+
email: johnw@orcasnet.com
|
107
|
+
executables:
|
108
|
+
- moneypenny
|
109
|
+
extensions: []
|
110
|
+
|
111
|
+
extra_rdoc_files:
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.rdoc
|
114
|
+
files:
|
115
|
+
- .document
|
116
|
+
- .rspec
|
117
|
+
- Gemfile
|
118
|
+
- Gemfile.lock
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.rdoc
|
121
|
+
- Rakefile
|
122
|
+
- VERSION
|
123
|
+
- bin/moneypenny
|
124
|
+
- lib/moneypenny.rb
|
125
|
+
- lib/moneypenny/connections/campfire.rb
|
126
|
+
- lib/moneypenny/connections/echo.rb
|
127
|
+
- lib/moneypenny/moneypenny.rb
|
128
|
+
- lib/moneypenny/null_logger.rb
|
129
|
+
- lib/moneypenny/responders/help.rb
|
130
|
+
- lib/moneypenny/responders/image.rb
|
131
|
+
- lib/moneypenny/responders/weather.rb
|
132
|
+
- lib/moneypenny/responders/wikipedia.rb
|
133
|
+
- moneypenny.gemspec
|
134
|
+
- spec/moneypenny_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
has_rdoc: true
|
137
|
+
homepage: http://github.com/jwulff/moneypenny
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
version: "0"
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
segments:
|
157
|
+
- 0
|
158
|
+
version: "0"
|
159
|
+
requirements: []
|
160
|
+
|
161
|
+
rubyforge_project:
|
162
|
+
rubygems_version: 1.3.6
|
163
|
+
signing_key:
|
164
|
+
specification_version: 3
|
165
|
+
summary: Moneypenny is a chat bot.
|
166
|
+
test_files: []
|
167
|
+
|