hipbot 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -3
  4. data/Gemfile +12 -1
  5. data/README.md +16 -8
  6. data/bin/hipbot +5 -0
  7. data/hipbot.gemspec +2 -1
  8. data/lib/hipbot.rb +7 -10
  9. data/lib/hipbot/adaptable.rb +60 -0
  10. data/lib/hipbot/adapter.rb +6 -6
  11. data/lib/hipbot/adapters/hipchat.rb +5 -48
  12. data/lib/hipbot/adapters/hipchat/client.rb +8 -0
  13. data/lib/hipbot/adapters/shell.rb +2 -9
  14. data/lib/hipbot/adapters/slack.rb +10 -0
  15. data/lib/hipbot/adapters/slack/client.rb +47 -0
  16. data/lib/hipbot/adapters/telnet.rb +2 -9
  17. data/lib/hipbot/adapters/xmpp.rb +59 -0
  18. data/lib/hipbot/adapters/{hipchat/initializer.rb → xmpp/client.rb} +35 -21
  19. data/lib/hipbot/bot.rb +5 -1
  20. data/lib/hipbot/callbacks/base.rb +20 -2
  21. data/lib/hipbot/callbacks/lobby_presence.rb +2 -1
  22. data/lib/hipbot/callbacks/presence.rb +1 -5
  23. data/lib/hipbot/callbacks/room_invite.rb +13 -0
  24. data/lib/hipbot/callbacks/room_message.rb +3 -9
  25. data/lib/hipbot/callbacks/room_presence.rb +10 -8
  26. data/lib/hipbot/callbacks/room_topic.rb +18 -0
  27. data/lib/hipbot/configuration.rb +11 -6
  28. data/lib/hipbot/helpers.rb +2 -0
  29. data/lib/hipbot/{http.rb → helpers/http.rb} +11 -7
  30. data/lib/hipbot/message.rb +2 -2
  31. data/lib/hipbot/presence.rb +0 -6
  32. data/lib/hipbot/reaction.rb +9 -7
  33. data/lib/hipbot/response.rb +1 -1
  34. data/lib/hipbot/room.rb +1 -1
  35. data/lib/hipbot/storages/hash.rb +5 -5
  36. data/lib/hipbot/storages/mongoid.rb +1 -1
  37. data/lib/hipbot/user.rb +4 -0
  38. data/lib/hipbot/{cache.rb → utilities/cache.rb} +0 -0
  39. data/lib/hipbot/{logger.rb → utilities/logger.rb} +0 -0
  40. data/lib/hipbot/version.rb +1 -1
  41. data/spec/integration/my_hipbot_spec.rb +1 -1
  42. data/spec/spec_helper.rb +7 -2
  43. data/spec/unit/match_spec.rb +7 -7
  44. data/spec/unit/message_spec.rb +2 -2
  45. data/spec/unit/reaction_spec.rb +14 -14
  46. metadata +28 -8
  47. data/lib/hipbot/callbacks/invite.rb +0 -11
@@ -34,10 +34,6 @@ module Hipbot
34
34
  !!options[:global]
35
35
  end
36
36
 
37
- def inspect
38
- "#<Hipbot::Reaction #{options}>"
39
- end
40
-
41
37
  def plugin_name
42
38
  plugin.name.demodulize
43
39
  end
@@ -53,10 +49,16 @@ module Hipbot
53
49
  attr_cache :readable_command do
54
50
  regexps.map(&:source).join(' or ').gsub(/\^|\\z|\$|\\/, '')
55
51
  end
52
+ delegate :to_s, to: :readable_command
56
53
 
57
54
  attr_cache :regexps do
58
- Array(options[:regexps]).map do |regexp|
59
- Regexp.new(regexp.source, Regexp::IGNORECASE)
55
+ regexps = Array(options[:regexps])
56
+ if Hipbot.configuration.case_insensitive
57
+ regexps.map do |regexp|
58
+ Regexp.new(regexp.source, Regexp::IGNORECASE)
59
+ end
60
+ else
61
+ regexps
60
62
  end
61
63
  end
62
64
 
@@ -71,7 +73,7 @@ module Hipbot
71
73
  protected
72
74
 
73
75
  def replace_symbols values, replacements_hash
74
- Array(values).flat_map{ |v| replacements_hash[v] || v }.map(&:to_s)
76
+ Array(values).flat_map{ |v| replacements_hash[v] || v }.uniq
75
77
  end
76
78
  end
77
79
  end
@@ -7,7 +7,7 @@ module Hipbot
7
7
 
8
8
  def initialize *_
9
9
  super
10
- Hipbot.logger.info("RESPONSE WITH #{reaction.inspect}")
10
+ Hipbot.logger.info("RESPONSE WITH #{reaction}")
11
11
  end
12
12
 
13
13
  def invoke arguments
@@ -41,7 +41,7 @@ module Hipbot
41
41
  end
42
42
 
43
43
  def archived?
44
- !!attributes[:archived]
44
+ !!attributes[:is_archived]
45
45
  end
46
46
  end
47
47
  end
@@ -77,12 +77,12 @@ module Hipbot
77
77
  end
78
78
  end
79
79
 
80
- protected
80
+ # protected
81
81
 
82
- def method_missing name, *args, &block
83
- return all.public_send(name, *args, &block) if Array.instance_methods.include?(name)
84
- super
85
- end
82
+ # def method_missing name, *args, &block
83
+ # return all.public_send(name, *args, &block) if Array.instance_methods.include?(name)
84
+ # super
85
+ # end
86
86
  end
87
87
  end
88
88
  end
@@ -11,7 +11,7 @@ module Hipbot
11
11
 
12
12
  alias_method :to_s, :name
13
13
 
14
- validate :name, presence: true
14
+ validates :name, presence: true
15
15
  end
16
16
  end
17
17
  end
@@ -15,5 +15,9 @@ module Hipbot
15
15
  def myself?
16
16
  self == Hipbot.user
17
17
  end
18
+
19
+ def guest?
20
+ attributes[:role] == 'visitor'
21
+ end
18
22
  end
19
23
  end
@@ -1,3 +1,3 @@
1
1
  module Hipbot
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -16,7 +16,7 @@ describe MyHipbot do
16
16
  end
17
17
 
18
18
  it 'should set hipchat token' do
19
- subject.jid.should == 'robbot@chat.hipchat.com'
19
+ subject.configuration.jid.should == 'robbot@chat.hipchat.com'
20
20
  end
21
21
  end
22
22
 
@@ -1,7 +1,12 @@
1
+ require 'rspec/its'
2
+
1
3
  require_relative '../lib/hipbot'
2
4
 
3
- require 'coveralls'
4
- Coveralls.wear!
5
+ begin
6
+ require 'coveralls'
7
+ Coveralls.wear!
8
+ rescue LoadError
9
+ end
5
10
 
6
11
  RSpec.configure do |config|
7
12
  config.mock_with :rspec
@@ -24,7 +24,7 @@ describe Hipbot::Match do
24
24
  end
25
25
 
26
26
  describe "#matches?" do
27
- its(:matches?) { should be_true }
27
+ its(:matches?) { should be_truthy }
28
28
 
29
29
  describe "specific regexp" do
30
30
  describe "matching the message body" do
@@ -33,7 +33,7 @@ describe Hipbot::Match do
33
33
  reaction.stub(regexps: [/\Atest/])
34
34
  end
35
35
 
36
- its(:matches?) { should be_true }
36
+ its(:matches?) { should be_truthy }
37
37
  end
38
38
 
39
39
  describe "not matching message body" do
@@ -42,7 +42,7 @@ describe Hipbot::Match do
42
42
  reaction.stub(regexps: [/\Arandom/])
43
43
  end
44
44
 
45
- its(:matches?) { should be_false }
45
+ its(:matches?) { should be_falsy }
46
46
  end
47
47
  end
48
48
 
@@ -53,7 +53,7 @@ describe Hipbot::Match do
53
53
  reaction.stub(regexps: [/\Awat/, /\Atest/])
54
54
  end
55
55
 
56
- its(:matches?) { should be_true }
56
+ its(:matches?) { should be_truthy }
57
57
  end
58
58
 
59
59
  describe "not matching message body" do
@@ -62,7 +62,7 @@ describe Hipbot::Match do
62
62
  reaction.stub(regexps: [/\Awat/, /\Arandom/])
63
63
  end
64
64
 
65
- its(:matches?) { should be_false }
65
+ its(:matches?) { should be_falsy }
66
66
  end
67
67
  end
68
68
 
@@ -72,7 +72,7 @@ describe Hipbot::Match do
72
72
  reaction.stub(condition: proc { true })
73
73
  end
74
74
 
75
- its(:matches?) { should be_true }
75
+ its(:matches?) { should be_truthy }
76
76
  end
77
77
 
78
78
  describe "returning false" do
@@ -80,7 +80,7 @@ describe Hipbot::Match do
80
80
  reaction.stub(condition: proc { false })
81
81
  end
82
82
 
83
- its(:matches?) { should be_false }
83
+ its(:matches?) { should be_falsy }
84
84
  end
85
85
  end
86
86
  end
@@ -56,13 +56,13 @@ describe Hipbot::Message do
56
56
  it "should be for bot" do
57
57
  user = double(mention: 'robot')
58
58
  message = subject.new('hello @robot!', room, sender)
59
- message.for?(user).should be_true
59
+ message.for?(user).should be_truthy
60
60
  end
61
61
 
62
62
  it "should not be for bot" do
63
63
  user = double(mention: 'robot')
64
64
  message = subject.new('hello @tom!', room, sender)
65
- message.for?(user).should be_false
65
+ message.for?(user).should be_falsy
66
66
  end
67
67
 
68
68
  it 'knows its recipients' do
@@ -8,27 +8,27 @@ describe Hipbot::Reaction do
8
8
  let(:reaction){ subject.new(@plugin, options, @block) }
9
9
 
10
10
  it '#in_any_room?' do
11
- reaction.in_any_room?.should be_false
11
+ reaction.in_any_room?.should be_falsy
12
12
  options[:room] = true
13
- reaction.in_any_room?.should be_true
13
+ reaction.in_any_room?.should be_truthy
14
14
  end
15
15
 
16
16
  it '#to_anything?' do
17
- reaction.to_anything?.should be_true
17
+ reaction.to_anything?.should be_truthy
18
18
  reaction.options[:regexps] = nil
19
- reaction.to_anything?.should be_true
19
+ reaction.to_anything?.should be_truthy
20
20
  end
21
21
 
22
22
  it '#from_anywhere?' do
23
- reaction.from_anywhere?.should be_true
23
+ reaction.from_anywhere?.should be_truthy
24
24
  reaction.options[:room] = nil
25
- reaction.from_anywhere?.should be_true
25
+ reaction.from_anywhere?.should be_truthy
26
26
  end
27
27
 
28
28
  it '#condition' do
29
- reaction.condition.call.should be_true
29
+ reaction.condition.call.should be_truthy
30
30
  reaction.options[:if] = proc{ false }
31
- reaction.condition.call.should be_false
31
+ reaction.condition.call.should be_falsy
32
32
  end
33
33
 
34
34
  it '#delete' do
@@ -45,15 +45,15 @@ describe Hipbot::Reaction do
45
45
  end
46
46
 
47
47
  it '#from_all?' do
48
- reaction.from_all?.should be_true
48
+ reaction.from_all?.should be_truthy
49
49
  reaction.options[:room] = nil
50
- reaction.from_all?.should be_true
50
+ reaction.from_all?.should be_truthy
51
51
  end
52
52
 
53
53
  it '#global?' do
54
- reaction.global?.should be_false
54
+ reaction.global?.should be_falsy
55
55
  reaction.options = { global: true }
56
- reaction.global?.should be_true
56
+ reaction.global?.should be_truthy
57
57
  end
58
58
 
59
59
  it '#plugin_name' do
@@ -67,9 +67,9 @@ describe Hipbot::Reaction do
67
67
  end
68
68
 
69
69
  it '#to_private_message?' do
70
- reaction.to_private_message?.should be_false
70
+ reaction.to_private_message?.should be_falsy
71
71
  reaction.options[:room] = false
72
- reaction.to_private_message?.should be_true
72
+ reaction.to_private_message?.should be_truthy
73
73
  end
74
74
 
75
75
  it '#regexps' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Kopiński
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-08 00:00:00.000000000 Z
12
+ date: 2016-07-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xmpp4r-hipchat
@@ -109,6 +109,20 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rspec-its
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
112
126
  - !ruby/object:Gem::Dependency
113
127
  name: guard-rspec
114
128
  requirement: !ruby/object:Gem::Requirement
@@ -143,26 +157,30 @@ files:
143
157
  - bin/hipbot
144
158
  - hipbot.gemspec
145
159
  - lib/hipbot.rb
160
+ - lib/hipbot/adaptable.rb
146
161
  - lib/hipbot/adapter.rb
147
162
  - lib/hipbot/adapters/hipchat.rb
148
- - lib/hipbot/adapters/hipchat/initializer.rb
163
+ - lib/hipbot/adapters/hipchat/client.rb
149
164
  - lib/hipbot/adapters/shell.rb
165
+ - lib/hipbot/adapters/slack.rb
166
+ - lib/hipbot/adapters/slack/client.rb
150
167
  - lib/hipbot/adapters/telnet.rb
168
+ - lib/hipbot/adapters/xmpp.rb
169
+ - lib/hipbot/adapters/xmpp/client.rb
151
170
  - lib/hipbot/bot.rb
152
- - lib/hipbot/cache.rb
153
171
  - lib/hipbot/callbacks/base.rb
154
- - lib/hipbot/callbacks/invite.rb
155
172
  - lib/hipbot/callbacks/lobby_presence.rb
156
173
  - lib/hipbot/callbacks/message.rb
157
174
  - lib/hipbot/callbacks/presence.rb
158
175
  - lib/hipbot/callbacks/private_message.rb
176
+ - lib/hipbot/callbacks/room_invite.rb
159
177
  - lib/hipbot/callbacks/room_message.rb
160
178
  - lib/hipbot/callbacks/room_presence.rb
179
+ - lib/hipbot/callbacks/room_topic.rb
161
180
  - lib/hipbot/configurable.rb
162
181
  - lib/hipbot/configuration.rb
163
182
  - lib/hipbot/helpers.rb
164
- - lib/hipbot/http.rb
165
- - lib/hipbot/logger.rb
183
+ - lib/hipbot/helpers/http.rb
166
184
  - lib/hipbot/match.rb
167
185
  - lib/hipbot/matchable.rb
168
186
  - lib/hipbot/message.rb
@@ -178,6 +196,8 @@ files:
178
196
  - lib/hipbot/storages/hash.rb
179
197
  - lib/hipbot/storages/mongoid.rb
180
198
  - lib/hipbot/user.rb
199
+ - lib/hipbot/utilities/cache.rb
200
+ - lib/hipbot/utilities/logger.rb
181
201
  - lib/hipbot/version.rb
182
202
  - spec/integration/my_hipbot.rb
183
203
  - spec/integration/my_hipbot_spec.rb
@@ -211,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
231
  version: '0'
212
232
  requirements: []
213
233
  rubyforge_project:
214
- rubygems_version: 2.2.0.rc.1
234
+ rubygems_version: 2.5.1
215
235
  signing_key:
216
236
  specification_version: 4
217
237
  summary: Hipbot is a XMPP bot for HipChat, written in Ruby with EventMachine.
@@ -1,11 +0,0 @@
1
- module Hipbot
2
- module Callbacks
3
- class Invite < Base
4
- def initialize room_id, user_name, room_name, topic
5
- with_room(id: room_id, name: room_name, topic: topic) do |room|
6
- Hipbot.join_room(room)
7
- end
8
- end
9
- end
10
- end
11
- end