lita 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/lita/robot.rb +3 -0
- data/lib/lita/version.rb +1 -1
- data/lita.gemspec +8 -8
- data/spec/lita/robot_spec.rb +11 -0
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e05fe1e0cb321abc7f328ade3580833013f91650
|
4
|
+
data.tar.gz: 150331c84e76818a44f66f2759a965aed8d8fa75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af679c53aaa2fd86fedfa2c69b984d0961f9d7af73cf371a7c3a8148101dbae94396d078331b19fd2dcddaf1bd12b2bcf8e73dbed00bfbdda0134b3475ce8a2a
|
7
|
+
data.tar.gz: f61fd270bd693b01bc78ccd5e07062bf4838ca5265c25fa08394cf6b63f25a93fb48e655377b83b1f93a3550a86bd5ded52401d82a269b3d3d28a53261955df0
|
data/README.md
CHANGED
@@ -261,6 +261,14 @@ robot.trigger(:connected, room: "#litabot")
|
|
261
261
|
|
262
262
|
Since the `trigger` method is available on `Lita::Robot`, it can be used from anywhere in the Lita runtime (both adapters and handlers).
|
263
263
|
|
264
|
+
### Built-in events
|
265
|
+
|
266
|
+
Lita has a few built-in events:
|
267
|
+
|
268
|
+
* `:loaded` - Fired when the `Lita::Robot` object has been initialized during start up. This can be used as a hook point for handlers to define routes that depend on user configuration not known until runtime, run migrations on data in Redis, or other start up tasks.
|
269
|
+
* `:shut_down_started` - Fired when the robot first begins shutting down.
|
270
|
+
* `:shut_down_completed` - Fired when the robot has finished shutting down both the built-in web server and the chat adapter.
|
271
|
+
|
264
272
|
### Handler-specific configuration
|
265
273
|
|
266
274
|
If you want your handler to expose config settings to the user, use the class-level `default_config` method. This method accepts a single config object as an argument, which will be exposed to the user as `Lita.config.handlers.your_handler_namespace`.
|
data/lib/lita/robot.rb
CHANGED
@@ -22,6 +22,7 @@ module Lita
|
|
22
22
|
@mention_name = Lita.config.robot.mention_name || @name
|
23
23
|
@app = RackApp.new(self).to_app
|
24
24
|
load_adapter
|
25
|
+
trigger(:loaded)
|
25
26
|
end
|
26
27
|
|
27
28
|
# The primary entry point from the adapter for an incoming message.
|
@@ -66,9 +67,11 @@ module Lita
|
|
66
67
|
# service.
|
67
68
|
# @return [void]
|
68
69
|
def shut_down
|
70
|
+
trigger(:shut_down_started)
|
69
71
|
@server.stop if @server
|
70
72
|
@server_thread.join if @server_thread
|
71
73
|
@adapter.shut_down
|
74
|
+
trigger(:shut_down_complete)
|
72
75
|
end
|
73
76
|
|
74
77
|
# Triggers an event, instructing all registered handlers to invoke any
|
data/lib/lita/version.rb
CHANGED
data/lita.gemspec
CHANGED
@@ -20,16 +20,16 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = ">= 2.0.0"
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "bundler", "
|
24
|
-
spec.add_runtime_dependency "faraday", "
|
25
|
-
spec.add_runtime_dependency "multi_json", "
|
26
|
-
spec.add_runtime_dependency "rack", "
|
27
|
-
spec.add_runtime_dependency "redis-namespace", "
|
28
|
-
spec.add_runtime_dependency "thin", "
|
29
|
-
spec.add_runtime_dependency "thor", "
|
23
|
+
spec.add_runtime_dependency "bundler", ">= 1.3"
|
24
|
+
spec.add_runtime_dependency "faraday", ">= 0.8.7"
|
25
|
+
spec.add_runtime_dependency "multi_json", ">= 1.7.7"
|
26
|
+
spec.add_runtime_dependency "rack", ">= 1.5.2"
|
27
|
+
spec.add_runtime_dependency "redis-namespace", ">= 1.3.0"
|
28
|
+
spec.add_runtime_dependency "thin", ">= 1.5.1"
|
29
|
+
spec.add_runtime_dependency "thor", ">= 0.18.1"
|
30
30
|
|
31
31
|
spec.add_development_dependency "rake"
|
32
|
-
spec.add_development_dependency "rspec", "
|
32
|
+
spec.add_development_dependency "rspec", ">= 2.14"
|
33
33
|
spec.add_development_dependency "simplecov"
|
34
34
|
spec.add_development_dependency "coveralls"
|
35
35
|
spec.add_development_dependency "pry"
|
data/spec/lita/robot_spec.rb
CHANGED
@@ -9,6 +9,11 @@ describe Lita::Robot do
|
|
9
9
|
expect { subject }.to raise_error(SystemExit)
|
10
10
|
end
|
11
11
|
|
12
|
+
it "triggers a loaded event after initialization" do
|
13
|
+
expect_any_instance_of(described_class).to receive(:trigger).with(:loaded)
|
14
|
+
subject
|
15
|
+
end
|
16
|
+
|
12
17
|
context "with registered handlers" do
|
13
18
|
let(:handler1) { double("Handler 1").as_null_object }
|
14
19
|
let(:handler2) { double("Handler 2").as_null_object }
|
@@ -102,5 +107,11 @@ describe Lita::Robot do
|
|
102
107
|
expect_any_instance_of(Lita::Adapters::Shell).to receive(:shut_down)
|
103
108
|
subject.shut_down
|
104
109
|
end
|
110
|
+
|
111
|
+
it "triggers events for shut_down_started and shut_down_complete" do
|
112
|
+
expect(subject).to receive(:trigger).with(:shut_down_started).ordered
|
113
|
+
expect(subject).to receive(:trigger).with(:shut_down_complete).ordered
|
114
|
+
subject.shut_down
|
115
|
+
end
|
105
116
|
end
|
106
117
|
end
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.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: 2013-10-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.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
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.8.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.8.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: multi_json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.7.7
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.7.7
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.5.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.5.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: redis-namespace
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.3.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.3.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: thin
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 1.5.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.5.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: thor
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.18.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.18.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
@@ -126,14 +126,14 @@ dependencies:
|
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '2.14'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '2.14'
|
139
139
|
- !ruby/object:Gem::Dependency
|