lita-hipchat 2.1.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3caf3e5aa475e362c0df849d97d9fb9aa6e357e9
4
- data.tar.gz: ed234aaa8462ea9ef2879be9a107df398d5a90f0
3
+ metadata.gz: 8ad7f231798e72ad24098c645a8fb7eeeba583f3
4
+ data.tar.gz: c39205b24b33b1e0274fab0575d97a873ecebffa
5
5
  SHA512:
6
- metadata.gz: a31c0c64b0d43365ad850eb21e7b2a98b9a65ad333495c3147259e2e27742dade106900a91a4b33fcf44c5a119a9bd9d31c38c9cf564daf53aebe2fd30bfe370
7
- data.tar.gz: 04616bc35f867a8116d81f27c36920493cac185b011fee812343c1cd0cf63c5c1766da88fffac25c9eb7f7f0bdf20aa8ff32119e2a1f3a8938942dfb1688a23b
6
+ metadata.gz: d461fa2c0b10cfeccea84474ba310f11130ef29b0578de1861af6290ffed2be679a6476c3bf09b214638cc107d28e24f99766ff8d4487d3c165dcbd1e4a47753
7
+ data.tar.gz: b1cf4ae4f3d3e5a92c043dc149c72193973fb04e792db88889ee5c6b867fcf013a7ead3dd11e1948069c74bd8160d4661e236b18605eaad022a2f5a4edcf5fd6
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
- - 2.0.0
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
4
7
  script: bundle exec rspec
5
8
  before_install:
6
9
  - gem update --system
data/README.md CHANGED
@@ -27,7 +27,7 @@ Values for all of the following attributes can be found on the "XMPP/Jabber info
27
27
 
28
28
  * `server` (String) - The HipChat Server address. Override this with the full domain of your server if using a private HipChat Server installation. Default: `"chat.hipchat.com"`
29
29
  * `debug` (Boolean) - If `true`, turns on the underlying Jabber library's (xmpp4r) logger, which is fairly verbose. Default: `false`.
30
- * `rooms` (Symbol, Array<String>) - An array of room JIDs that Lita should join upon connection. Can also be the symbol `:all`, which will cause Lita to discover and join all rooms. Default: `nil` (no rooms).
30
+ * **DEPRECATED** - `rooms` (Symbol, Array<String>) - An array of room JIDs that Lita should join upon connection. Can also be the symbol `:all`, which will cause Lita to discover and join all rooms. Default: `nil` (no rooms).
31
31
  * `muc_domain` (String) - The XMPP Multi-User Chat domain to use. Default: `"conf.hipchat.com"`.
32
32
  * `ignore_unknown_users` (Boolean) - Messages generated through HipChat's API which don't come from a real user account will be ignored by the robot. With the default setting of false, Lita will emit a warning but the message will be dispatched to any registered handlers as usual. Default: `false`.
33
33
 
@@ -55,6 +55,10 @@ end
55
55
  `:joined` - When the robot joins a room. Payload: `:room`: The String room ID that was joined.
56
56
  `:parted` - When the robot parts from a room. Payload: `:room`: The String room ID that was parted from.
57
57
 
58
+ ## Managing rooms
59
+
60
+ To make Lita join or part from rooms, use the [built-in `join` and `part` commands](http://docs.lita.io/getting-started/usage/#managing-rooms). For backwards compatibility, the `rooms` configuration attribute will be supported until lita-hipchat 4.0, but you should remove it and begin using the new command instead. If the configuration attribute is set, lita-hipchat will honor its value and join those rooms instead of the ones persisted to Redis from using the new commands.
61
+
58
62
  ## License
59
63
 
60
64
  [MIT](http://opensource.org/licenses/MIT)
data/lib/lita-hipchat.rb CHANGED
@@ -1 +1,7 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
1
7
  require "lita/adapters/hipchat"
@@ -41,7 +41,7 @@ module Lita
41
41
  def run
42
42
  connector.connect
43
43
  robot.trigger(:connected)
44
- rooms.each { |r| join(r) }
44
+ join_persisted_rooms
45
45
  sleep
46
46
  rescue Interrupt
47
47
  shut_down
@@ -67,18 +67,35 @@ module Lita
67
67
 
68
68
  private
69
69
 
70
- def rooms
71
- if config.rooms == :all
72
- connector.list_rooms(muc_domain)
73
- else
74
- Array(config.rooms)
75
- end
70
+ def join_all_rooms?
71
+ config.rooms == :all
72
+ end
73
+
74
+ def join_persisted_rooms
75
+ rooms.each { |room| join(room) }
76
76
  end
77
77
 
78
78
  def muc_domain
79
79
  config.muc_domain.dup
80
80
  end
81
81
 
82
+ def rooms_configured?
83
+ config.rooms.respond_to?(:empty?) && !config.rooms.empty?
84
+ end
85
+
86
+ def rooms
87
+ if join_all_rooms? || rooms_configured?
88
+ log.warn(t("config.rooms.deprecated"))
89
+
90
+ if config.rooms == :all
91
+ connector.list_rooms(muc_domain)
92
+ else
93
+ Array(config.rooms)
94
+ end
95
+ else
96
+ robot.persisted_rooms
97
+ end
98
+ end
82
99
  end
83
100
 
84
101
  Lita.register_adapter(:hipchat, HipChat)
@@ -111,6 +111,7 @@ module Lita
111
111
  def client_connect
112
112
  Lita.logger.info("Connecting to HipChat.")
113
113
  client.connect(@server)
114
+ sleep 0.0001 until client.is_connected?
114
115
  Lita.logger.debug("Authenticating with HipChat.")
115
116
  client.auth(@password)
116
117
  end
data/lita-hipchat.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-hipchat"
3
- spec.version = "2.1.3"
3
+ spec.version = "3.0.0"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{A HipChat adapter for Lita.}
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
15
  spec.require_paths = ["lib"]
16
16
 
17
- spec.add_runtime_dependency "lita", ">= 4.0"
17
+ spec.add_runtime_dependency "lita", ">= 4.4.3"
18
18
  spec.add_runtime_dependency "xmpp4r", ">= 0.5.6"
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.3"
data/locales/en.yml ADDED
@@ -0,0 +1,9 @@
1
+ en:
2
+ lita:
3
+ adapters:
4
+ hipchat:
5
+ config:
6
+ rooms:
7
+ deprecated: >-
8
+ config.rooms is deprecated and will be removed in lita-hipchat 4.0.
9
+ Use the built-in `join` and `part` commands to manage rooms instead.
@@ -10,6 +10,7 @@ describe Lita::Adapters::HipChat::Connector, lita: true do
10
10
  allow(client).to receive(:connect)
11
11
  allow(client).to receive(:send)
12
12
  allow(client).to receive(:on_exception)
13
+ allow(client).to receive(:is_connected?).and_return(true)
13
14
  client
14
15
  end
15
16
 
@@ -7,6 +7,8 @@ describe Lita::Adapters::HipChat, lita: true do
7
7
  registry.configure do |config|
8
8
  config.adapters.hipchat.jid = "jid"
9
9
  config.adapters.hipchat.password = "secret"
10
+ config.adapters.hipchat.muc_domain = domain
11
+ config.adapters.hipchat.rooms = rooms
10
12
  end
11
13
 
12
14
  allow(described_class::Connector).to receive(:new).and_return(connector)
@@ -17,6 +19,7 @@ describe Lita::Adapters::HipChat, lita: true do
17
19
  let(:robot) { Lita::Robot.new(registry) }
18
20
  let(:connector) { instance_double("Lita::Adapters::HipChat::Connector") }
19
21
  let(:domain) { "conf.hipchat.com" }
22
+ let(:rooms) { %w(room_1, room_2) }
20
23
 
21
24
  it "registers with Lita" do
22
25
  expect(Lita.adapters[:hipchat]).to eql(described_class)
@@ -51,8 +54,6 @@ describe Lita::Adapters::HipChat, lita: true do
51
54
  end
52
55
 
53
56
  describe "#run" do
54
- let(:rooms) { ["room_1_id", "room_2_id"] }
55
-
56
57
  before do
57
58
  allow(subject.connector).to receive(:connect)
58
59
  allow(robot).to receive(:trigger)
@@ -68,30 +69,67 @@ describe Lita::Adapters::HipChat, lita: true do
68
69
 
69
70
  context "with a custom domain" do
70
71
  let(:domain) { "foo.bar.com" }
72
+
71
73
  it "joins rooms with a custom muc_domain" do
72
- registry.config.adapters.hipchat.muc_domain = domain
73
- allow(subject).to receive(:rooms).and_return(rooms)
74
74
  expect(subject.connector).to receive(:join).with(domain, anything)
75
+
75
76
  subject.run
76
77
  end
77
78
  end
78
79
 
79
- it "joins all rooms when config.rooms is :all" do
80
- registry.config.adapters.hipchat.rooms = :all
81
- allow(subject.connector).to receive(:list_rooms).with(domain).and_return(rooms)
82
- rooms.each do |room|
83
- expect(subject).to receive(:join).with(room)
80
+ context "when config.rooms is :all" do
81
+ before do
82
+ allow(subject.connector).to receive(:list_rooms).and_return(%w(room_1 room_2))
83
+ allow(subject.connector).to receive(:join)
84
+ end
85
+
86
+ let(:rooms) { :all }
87
+
88
+ it "logs a deprecation warning" do
89
+ expect(Lita.logger).to receive(:warn) do |msg|
90
+ expect(msg).to include("config.rooms is deprecated")
91
+ end
92
+
93
+ subject.run
94
+ end
95
+
96
+ it "joins all rooms" do
97
+ %w(room_1 room_2).each do |room|
98
+ expect(subject.connector).to receive(:join).with(domain, room)
99
+ end
100
+
101
+ subject.run
102
+ end
103
+ end
104
+
105
+ context "when config.rooms contains individual room IDs" do
106
+ let(:rooms) { ["room_1_only"] }
107
+
108
+ it "logs a deprecation warning" do
109
+ expect(Lita.logger).to receive(:warn) do |msg|
110
+ expect(msg).to include("config.rooms is deprecated")
111
+ end
112
+
113
+ subject.run
114
+ end
115
+
116
+ it "joins the specified rooms" do
117
+ expect(subject.connector).to receive(:join).with(domain, "room_1_only")
118
+
119
+ subject.run
84
120
  end
85
- subject.run
86
121
  end
87
122
 
88
- it "joins rooms specified by config.rooms" do
89
- custom_rooms = rooms
90
- registry.config.adapters.hipchat.rooms = custom_rooms
91
- rooms.each do |room|
92
- expect(subject).to receive(:join).with(room)
123
+ context "when config.rooms is empty" do
124
+ before { allow(robot).to receive(:persisted_rooms).and_return(%w(persisted_room_1)) }
125
+
126
+ let(:rooms) { [] }
127
+
128
+ it "joins rooms persisted in robot.persisted_rooms" do
129
+ expect(subject.connector).to receive(:join).with(domain, "persisted_room_1")
130
+
131
+ subject.run
93
132
  end
94
- subject.run
95
133
  end
96
134
 
97
135
  it "sleeps the main thread" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 4.4.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: 4.4.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: xmpp4r
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -126,6 +126,7 @@ files:
126
126
  - lib/lita/adapters/hipchat/callback.rb
127
127
  - lib/lita/adapters/hipchat/connector.rb
128
128
  - lita-hipchat.gemspec
129
+ - locales/en.yml
129
130
  - spec/lita/adapters/hipchat/callback_spec.rb
130
131
  - spec/lita/adapters/hipchat/connector_spec.rb
131
132
  - spec/lita/adapters/hipchat_spec.rb
@@ -160,3 +161,4 @@ test_files:
160
161
  - spec/lita/adapters/hipchat/connector_spec.rb
161
162
  - spec/lita/adapters/hipchat_spec.rb
162
163
  - spec/spec_helper.rb
164
+ has_rdoc: