robut 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,51 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: robut
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
4
5
  prerelease:
5
- version: 0.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Justin Weiss
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-19 00:00:00 -07:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-09-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: xmpp4r
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70105702412820 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
18
+ requirements:
22
19
  - - ~>
23
- - !ruby/object:Gem::Version
20
+ - !ruby/object:Gem::Version
24
21
  version: 0.5.0
25
22
  type: :runtime
26
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *70105702412820
27
25
  description: A simple plugin-enabled HipChat bot
28
- email:
26
+ email:
29
27
  - justin@uberweiss.org
30
- executables:
28
+ executables:
31
29
  - robut
32
30
  extensions: []
33
-
34
31
  extra_rdoc_files: []
35
-
36
- files:
32
+ files:
37
33
  - .gitignore
38
34
  - Gemfile
39
35
  - README.rdoc
40
36
  - Rakefile
41
37
  - bin/robut
42
38
  - examples/Chatfile
39
+ - lib/rexml_patches.rb
43
40
  - lib/robut.rb
44
41
  - lib/robut/connection.rb
45
42
  - lib/robut/plugin.rb
46
- - lib/robut/plugin/base.rb
43
+ - lib/robut/plugin/alias.rb
47
44
  - lib/robut/plugin/calc.rb
48
45
  - lib/robut/plugin/echo.rb
46
+ - lib/robut/plugin/help.rb
49
47
  - lib/robut/plugin/later.rb
50
48
  - lib/robut/plugin/lunch.rb
51
49
  - lib/robut/plugin/meme.rb
@@ -66,64 +64,81 @@ files:
66
64
  - lib/robut/plugin/say.rb
67
65
  - lib/robut/plugin/sayings.rb
68
66
  - lib/robut/plugin/twss.rb
67
+ - lib/robut/plugin/weather.rb
69
68
  - lib/robut/storage.rb
70
69
  - lib/robut/storage/base.rb
71
70
  - lib/robut/storage/hash_store.rb
72
71
  - lib/robut/storage/yaml_store.rb
73
72
  - lib/robut/version.rb
74
73
  - robut.gemspec
74
+ - test/fixtures/bad_location.xml
75
+ - test/fixtures/las_vegas.xml
76
+ - test/fixtures/seattle.xml
77
+ - test/fixtures/tacoma.xml
75
78
  - test/mocks/connection_mock.rb
76
79
  - test/simplecov_helper.rb
77
80
  - test/test_helper.rb
78
81
  - test/unit/connection_test.rb
79
- - test/unit/plugin/base_test.rb
82
+ - test/unit/plugin/alias_test.rb
80
83
  - test/unit/plugin/echo_test.rb
84
+ - test/unit/plugin/help_test.rb
81
85
  - test/unit/plugin/later_test.rb
82
86
  - test/unit/plugin/lunch_test.rb
83
87
  - test/unit/plugin/ping_test.rb
84
88
  - test/unit/plugin/say_test.rb
89
+ - test/unit/plugin/weather_test.rb
90
+ - test/unit/plugin_test.rb
85
91
  - test/unit/storage/hash_store_test.rb
86
92
  - test/unit/storage/yaml_store_test.rb
87
93
  - test/unit/storage/yaml_test.yml
88
- has_rdoc: true
89
94
  homepage: http://rdoc.info/github/justinweiss/robut/master/frames
90
95
  licenses: []
91
-
92
96
  post_install_message:
93
97
  rdoc_options: []
94
-
95
- require_paths:
98
+ require_paths:
96
99
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
100
+ required_ruby_version: !ruby/object:Gem::Requirement
98
101
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ segments:
107
+ - 0
108
+ hash: 1156497835208409562
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
110
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: "0"
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ segments:
116
+ - 0
117
+ hash: 1156497835208409562
109
118
  requirements: []
110
-
111
119
  rubyforge_project: robut
112
- rubygems_version: 1.6.2
120
+ rubygems_version: 1.8.10
113
121
  signing_key:
114
122
  specification_version: 3
115
123
  summary: A simple plugin-enabled HipChat bot
116
- test_files:
124
+ test_files:
125
+ - test/fixtures/bad_location.xml
126
+ - test/fixtures/las_vegas.xml
127
+ - test/fixtures/seattle.xml
128
+ - test/fixtures/tacoma.xml
117
129
  - test/mocks/connection_mock.rb
118
130
  - test/simplecov_helper.rb
119
131
  - test/test_helper.rb
120
132
  - test/unit/connection_test.rb
121
- - test/unit/plugin/base_test.rb
133
+ - test/unit/plugin/alias_test.rb
122
134
  - test/unit/plugin/echo_test.rb
135
+ - test/unit/plugin/help_test.rb
123
136
  - test/unit/plugin/later_test.rb
124
137
  - test/unit/plugin/lunch_test.rb
125
138
  - test/unit/plugin/ping_test.rb
126
139
  - test/unit/plugin/say_test.rb
140
+ - test/unit/plugin/weather_test.rb
141
+ - test/unit/plugin_test.rb
127
142
  - test/unit/storage/hash_store_test.rb
128
143
  - test/unit/storage/yaml_store_test.rb
129
144
  - test/unit/storage/yaml_test.yml
@@ -1,70 +0,0 @@
1
- # All Robut plugins inherit from this base class. Plugins should
2
- # implement the +handle+ method to implement their functionality.
3
- class Robut::Plugin::Base
4
-
5
- # A reference to the connection attached to this instance of the
6
- # plugin. This is mostly used to communicate back to the server.
7
- attr_accessor :connection
8
-
9
- # If we are handling a private message, holds a reference to the
10
- # sender of the message. +nil+ if the message was sent to the entire
11
- # room.
12
- attr_accessor :private_sender
13
-
14
- # Creates a new instance of this plugin that references the
15
- # specified connection.
16
- def initialize(connection, private_sender = nil)
17
- self.connection = connection
18
- self.private_sender = private_sender
19
- end
20
-
21
- # Send +message+ back to the HipChat server. If +to+ == +:room+,
22
- # replies to the room. If +to+ == nil, responds in the manner the
23
- # original message was sent. Otherwise, PMs the message to +to+.
24
- def reply(message, to = nil)
25
- if to == :room
26
- connection.reply(message, nil)
27
- else
28
- connection.reply(message, to || private_sender)
29
- end
30
- end
31
-
32
- # An ordered list of all words in the message with any reference to
33
- # the bot's nick stripped out. If +command+ is passed in, it is also
34
- # stripped out. This is useful to separate the 'parameters' from the
35
- # 'commands' in a message.
36
- def words(message, command = nil)
37
- reply = at_nick
38
- command = command.downcase if command
39
- message.split.reject {|word| word.downcase == reply || word.downcase == command }
40
- end
41
-
42
- # The bot's nickname, for @-replies.
43
- def nick
44
- connection.config.nick.split.first
45
- end
46
-
47
- # #nick with the @-symbol prepended
48
- def at_nick
49
- "@#{nick.downcase}"
50
- end
51
-
52
- # Was +message+ sent to Robut as an @reply?
53
- def sent_to_me?(message)
54
- message =~ /(^|\s)@#{nick}(\s|$)/i
55
- end
56
-
57
- # Do whatever you need to do to handle this message.
58
- # If you want to stop the plugin execution chain, return +true+ from this
59
- # method. Plugins are handled in the order that they appear in
60
- # Robut::Plugin.plugins
61
- def handle(time, sender_nick, message)
62
- raise NotImplementedError, "Implement me in #{self.class.name}!"
63
- end
64
-
65
- # Accessor for the store instance
66
- def store
67
- connection.store
68
- end
69
-
70
- end
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Robut::Plugin::BaseTest < Test::Unit::TestCase
4
-
5
- def test_sent_to_me?
6
- plugin = Robut::Plugin::Base.new(Robut::ConnectionMock.new)
7
-
8
- assert plugin.sent_to_me?("@Robut hello there")
9
- assert !plugin.sent_to_me?("@Robuto hello there")
10
- assert !plugin.sent_to_me?("@David hello there")
11
- assert plugin.sent_to_me?("this is a @Robut message")
12
- assert plugin.sent_to_me?("this is a message to @robut")
13
- assert !plugin.sent_to_me?("this is a message to@robut")
14
- end
15
-
16
- end