blather 0.8.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/CHANGELOG.md +4 -0
- data/README.md +43 -1
- data/blather.gemspec +1 -0
- data/lib/blather/client/dsl.rb +12 -0
- data/lib/blather/version.rb +1 -1
- data/spec/blather/client/dsl_spec.rb +16 -2
- data/spec/spec_helper.rb +4 -0
- metadata +41 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 821cfa57a4b4d947dfe64d18c05c0bd31b8e33bc
|
4
|
+
data.tar.gz: 5f4ed8978cbda2d5c422b5334c87bb02c918896b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69222c73bc14ba562a45e56681e7cfa868a1ed4c6a492ddbee36a8bcaca6abbf3f571e126eab05c5a589143d4151c6ea16bced0d97a0f3c7e86ccdb28d2afce7
|
7
|
+
data.tar.gz: 92c7c2ba080d2da3143c0fa796c783e5697d3b39079a423aa42295b7eb68b858214c547f7e05d6344967e5effb4925c3e786a24860c05a542703b29e22c21086
|
data/.travis.yml
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.9.2
|
4
3
|
- 1.9.3
|
5
4
|
- 2.0.0
|
6
|
-
-
|
7
|
-
-
|
5
|
+
- 2.1.0
|
6
|
+
- jruby
|
7
|
+
- rbx-2.1.1
|
8
8
|
- ruby-head
|
9
9
|
matrix:
|
10
10
|
allow_failures:
|
11
|
-
- rvm: jruby
|
11
|
+
- rvm: jruby
|
12
12
|
- rvm: ruby-head
|
13
|
+
- rvm: rbx-2.1.1
|
13
14
|
notifications:
|
14
15
|
irc: "irc.freenode.org#adhearsion"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# [develop](https://github.com/adhearsion/blather/compare/master...develop)
|
2
2
|
|
3
|
+
# [v1.0.0](https://github.com/adhearsion/blather/compare/v0.8.8...v1.0.0) - [2014-02-10](https://rubygems.org/gems/blather/versions/1.0.0)
|
4
|
+
* Stable API promise
|
5
|
+
* Bugfix: Fix the DSL module-extended API that was broken by 8327184acc57c20daeaebb975729ff70207eab67
|
6
|
+
|
3
7
|
# [v0.8.8](https://github.com/adhearsion/blather/compare/v0.8.7...v0.8.8) - [2013-09-30](https://rubygems.org/gems/blather/versions/0.8.8)
|
4
8
|
* Bugfix: Warn about local file transfers being disabled by default
|
5
9
|
* Bugfix: Ensure that file transfers are accepted instantly. See https://groups.google.com/forum/#!topic/xmpp-blather/LMl6pR9qHfA
|
data/README.md
CHANGED
@@ -26,7 +26,6 @@ XMPP DSL (and more) for Ruby written on [EventMachine](http://rubyeventmachine.c
|
|
26
26
|
Blather comes with a DSL that makes writing XMPP bots quick and easy. See the examples directory for more advanced examples.
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
require 'rubygems'
|
30
29
|
require 'blather/client'
|
31
30
|
|
32
31
|
setup 'echo@jabber.local', 'echo'
|
@@ -42,6 +41,49 @@ message :chat?, :body do |m|
|
|
42
41
|
end
|
43
42
|
```
|
44
43
|
|
44
|
+
The above example is for a standalone script, and [can be run as a command line program](https://github.com/adhearsion/blather#on-the-command-line). If you wish to integrate Blather into an existing application, you will need to avoid `blather/client` and instead do something like this:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'blather/client/dsl'
|
48
|
+
|
49
|
+
module App
|
50
|
+
extend Blather::DSL
|
51
|
+
|
52
|
+
def self.run
|
53
|
+
EM.run { client.run }
|
54
|
+
end
|
55
|
+
|
56
|
+
setup 'echo@jabber.local', 'echo'
|
57
|
+
|
58
|
+
# Auto approve subscription requests
|
59
|
+
subscription :request? do |s|
|
60
|
+
write_to_stream s.approve!
|
61
|
+
end
|
62
|
+
|
63
|
+
# Echo back what was said
|
64
|
+
message :chat?, :body do |m|
|
65
|
+
write_to_stream m.reply
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
trap(:INT) { EM.stop }
|
70
|
+
trap(:TERM) { EM.stop }
|
71
|
+
|
72
|
+
App.run
|
73
|
+
```
|
74
|
+
|
75
|
+
If you need to ensure that Blather does not block the rest of your application, run the reactor in a new thread:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Thread.new { App.run }
|
79
|
+
```
|
80
|
+
|
81
|
+
You can additionally send messages like so:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
App.say 'foo@bar.com', 'Hello there!'
|
85
|
+
```
|
86
|
+
|
45
87
|
## Handlers
|
46
88
|
|
47
89
|
Handlers let Blather know how you'd like each type of stanza to be well.. handled. Each type of stanza has an associated handler which is part of a handler hierarchy. In the example above we're handling message and subscription stanzas.
|
data/blather.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.homepage = "http://adhearsion.com/blather"
|
25
25
|
s.summary = %q{Simpler XMPP built for speed}
|
26
26
|
s.description = %q{An XMPP DSL for Ruby written on top of EventMachine and Nokogiri}
|
27
|
+
s.license = 'MIT'
|
27
28
|
|
28
29
|
s.files = `git ls-files`.split("\n")
|
29
30
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/blather/client/dsl.rb
CHANGED
@@ -94,6 +94,18 @@ module Blather
|
|
94
94
|
super
|
95
95
|
end
|
96
96
|
|
97
|
+
def self.extended(o)
|
98
|
+
# Generate a method for every stanza handler that exists.
|
99
|
+
Blather::Stanza.handler_list.each do |handler_name|
|
100
|
+
module_eval <<-METHOD, __FILE__, __LINE__
|
101
|
+
def #{handler_name}(*args, &callback)
|
102
|
+
handle :#{handler_name}, *args, &callback
|
103
|
+
end
|
104
|
+
METHOD
|
105
|
+
end
|
106
|
+
super
|
107
|
+
end
|
108
|
+
|
97
109
|
# The actual client connection
|
98
110
|
#
|
99
111
|
# @return [Blather::Client]
|
data/lib/blather/version.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'blather/client/dsl'
|
3
3
|
|
4
|
-
include Blather::DSL
|
5
|
-
|
6
4
|
describe Blather::DSL do
|
7
5
|
before do
|
8
6
|
@client = Blather::Client.new
|
@@ -266,6 +264,22 @@ describe Blather::DSL do
|
|
266
264
|
@dsl.pubsub.host.should == jid.domain
|
267
265
|
end
|
268
266
|
|
267
|
+
context "extending a module" do
|
268
|
+
let(:test_module) do
|
269
|
+
Module.new do
|
270
|
+
extend Blather::DSL
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
Blather::Stanza.handler_list.each do |handler_method|
|
275
|
+
it "provides a helper method for #{handler_method}" do
|
276
|
+
guards = [:chat?, {:body => 'exit'}]
|
277
|
+
@client.expects(:register_handler).with handler_method, *guards
|
278
|
+
test_module.__send__(handler_method, *guards)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
269
283
|
context "included in a class which defines methods which collide with handler names" do
|
270
284
|
class CollisionTarget
|
271
285
|
include Blather::DSL
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Smick
|
@@ -9,208 +9,208 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: nokogiri
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.5'
|
35
|
-
- -
|
35
|
+
- - ">="
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 1.5.6
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- - ~>
|
42
|
+
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '1.5'
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.5.6
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: niceogiri
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: activesupport
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.3.11
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 2.3.11
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: girl_friday
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: bundler
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.0'
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.0'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: rake
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: rspec
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '2.7'
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '2.7'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: mocha
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.9'
|
139
139
|
type: :development
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - ~>
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0.9'
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: guard-rspec
|
148
148
|
requirement: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
type: :development
|
154
154
|
prerelease: false
|
155
155
|
version_requirements: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
- !ruby/object:Gem::Dependency
|
161
161
|
name: yard
|
162
162
|
requirement: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - ~>
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.6'
|
167
167
|
type: :development
|
168
168
|
prerelease: false
|
169
169
|
version_requirements: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - ~>
|
171
|
+
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0.6'
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
175
|
name: bluecloth
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
type: :development
|
182
182
|
prerelease: false
|
183
183
|
version_requirements: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
- !ruby/object:Gem::Dependency
|
189
189
|
name: countdownlatch
|
190
190
|
requirement: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
type: :development
|
196
196
|
prerelease: false
|
197
197
|
version_requirements: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- -
|
199
|
+
- - ">="
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
- !ruby/object:Gem::Dependency
|
203
203
|
name: rb-fsevent
|
204
204
|
requirement: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- - ~>
|
206
|
+
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0.9'
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
211
|
version_requirements: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- - ~>
|
213
|
+
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0.9'
|
216
216
|
description: An XMPP DSL for Ruby written on top of EventMachine and Nokogiri
|
@@ -221,9 +221,9 @@ extra_rdoc_files:
|
|
221
221
|
- LICENSE
|
222
222
|
- README.md
|
223
223
|
files:
|
224
|
-
- .gitignore
|
225
|
-
- .rspec
|
226
|
-
- .travis.yml
|
224
|
+
- ".gitignore"
|
225
|
+
- ".rspec"
|
226
|
+
- ".travis.yml"
|
227
227
|
- CHANGELOG.md
|
228
228
|
- Gemfile
|
229
229
|
- Guardfile
|
@@ -370,26 +370,27 @@ files:
|
|
370
370
|
- yard/templates/default/class/setup.rb
|
371
371
|
- yard/templates/default/class/text/handlers.erb
|
372
372
|
homepage: http://adhearsion.com/blather
|
373
|
-
licenses:
|
373
|
+
licenses:
|
374
|
+
- MIT
|
374
375
|
metadata: {}
|
375
376
|
post_install_message:
|
376
377
|
rdoc_options:
|
377
|
-
- --charset=UTF-8
|
378
|
+
- "--charset=UTF-8"
|
378
379
|
require_paths:
|
379
380
|
- lib
|
380
381
|
required_ruby_version: !ruby/object:Gem::Requirement
|
381
382
|
requirements:
|
382
|
-
- -
|
383
|
+
- - ">="
|
383
384
|
- !ruby/object:Gem::Version
|
384
385
|
version: '0'
|
385
386
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
386
387
|
requirements:
|
387
|
-
- -
|
388
|
+
- - ">="
|
388
389
|
- !ruby/object:Gem::Version
|
389
390
|
version: '0'
|
390
391
|
requirements: []
|
391
392
|
rubyforge_project:
|
392
|
-
rubygems_version: 2.0
|
393
|
+
rubygems_version: 2.2.0
|
393
394
|
signing_key:
|
394
395
|
specification_version: 4
|
395
396
|
summary: Simpler XMPP built for speed
|