strophe_ruby 0.0.4 → 0.0.5
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.
- data/Manifest.txt +4 -0
- data/README.rdoc +56 -66
- data/Rakefile +4 -5
- data/ext/strophe_ruby/libexpat.a +0 -0
- data/ext/strophe_ruby/libexpat32.a +0 -0
- data/ext/strophe_ruby/libexpat64.a +0 -0
- data/ext/strophe_ruby/libstrophe.a +0 -0
- data/ext/strophe_ruby/libstrophe32.a +0 -0
- data/ext/strophe_ruby/libstrophe64.a +0 -0
- data/lib/strophe_ruby.rb +2 -3
- metadata +17 -3
data/Manifest.txt
CHANGED
@@ -6,7 +6,11 @@ README.rdoc
|
|
6
6
|
Rakefile
|
7
7
|
ext/strophe_ruby/extconf.rb
|
8
8
|
ext/strophe_ruby/libexpat.a
|
9
|
+
ext/strophe_ruby/libexpat32.a
|
10
|
+
ext/strophe_ruby/libexpat64.a
|
9
11
|
ext/strophe_ruby/libstrophe.a
|
12
|
+
ext/strophe_ruby/libstrophe32.a
|
13
|
+
ext/strophe_ruby/libstrophe64.a
|
10
14
|
ext/strophe_ruby/strophe.h
|
11
15
|
ext/strophe_ruby/strophe/common.h
|
12
16
|
ext/strophe_ruby/strophe/expat.h
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= strophe_ruby
|
2
2
|
|
3
|
-
|
3
|
+
http://stropheruby.rubyforge.org
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
@@ -24,8 +24,6 @@ syntax. I didn't use SWIG to generate the bindings for 2 reasons :
|
|
24
24
|
My other project, XMPPBot, is an implementation of Strophe Ruby that
|
25
25
|
allows the ruby developer to write a XMPP bot in a few lines of code.
|
26
26
|
|
27
|
-
License: GNU General Public License (GPL)
|
28
|
-
|
29
27
|
== CURRENT PROBLEMS:
|
30
28
|
|
31
29
|
- Currently no Support for TLS encryption (Coming soon as it's rather important)
|
@@ -33,104 +31,96 @@ License: GNU General Public License (GPL)
|
|
33
31
|
- Socket disconnects after being inactive for too long
|
34
32
|
- Cannot output log data in a file
|
35
33
|
|
36
|
-
|
34
|
+
|
35
|
+
== EXAMPLE OF USE
|
37
36
|
|
38
37
|
require 'strophe_ruby'
|
38
|
+
|
39
39
|
def announce_presence
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@conn.send(presence)
|
40
|
+
stanza = StropheRuby::Stanza.new
|
41
|
+
stanza.name = "presence"
|
42
|
+
@conn.send(stanza)
|
44
43
|
end
|
45
44
|
|
46
45
|
def register_callbacks
|
46
|
+
#Accept all subscriptions
|
47
47
|
@conn.add_handler("presence") do |pres|
|
48
48
|
if pres.type == "subscribe"
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
stanza.set_attribute("to",pres.attribute("from"))
|
63
|
-
@conn.send(stanza)
|
49
|
+
#we accept
|
50
|
+
p = StropheRuby::Stanza.new
|
51
|
+
p.name = "presence"
|
52
|
+
p.type = "subscribed"
|
53
|
+
p.set_attribute("to",pres.attribute("from"))
|
54
|
+
@conn.send(p)
|
55
|
+
|
56
|
+
#then it's our turn to send our subscription request
|
57
|
+
p = StropheRuby::Stanza.new
|
58
|
+
p.name = "presence"
|
59
|
+
p.type = "subscribe"
|
60
|
+
p.set_attribute("to",pres.attribute("from"))
|
61
|
+
@conn.send(p)
|
64
62
|
end
|
65
63
|
end
|
66
|
-
|
67
|
-
#
|
64
|
+
|
65
|
+
#simple echo for messages
|
68
66
|
@conn.add_handler("message") do |msg|
|
69
|
-
|
70
|
-
if body
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
stanza.add_child(body_stanza)
|
86
|
-
|
87
|
-
@conn.send(stanza)
|
88
|
-
end
|
67
|
+
|
68
|
+
if msg.child_by_name("body")
|
69
|
+
top_stanza = StropheRuby::Stanza.new
|
70
|
+
top_stanza.name="message"
|
71
|
+
top_stanza.type="chat"
|
72
|
+
top_stanza.set_attribute("to", msg.attribute("from"))
|
73
|
+
|
74
|
+
body_stanza = StropheRuby::Stanza.new
|
75
|
+
body_stanza.name="body"
|
76
|
+
|
77
|
+
text_stanza = StropheRuby::Stanza.new
|
78
|
+
text_stanza.text = msg.child_by_name("body").text
|
79
|
+
|
80
|
+
body_stanza.add_child(text_stanza)
|
81
|
+
top_stanza.add_child(body_stanza)
|
82
|
+
@conn.send(top_stanza)
|
89
83
|
end
|
90
84
|
end
|
91
85
|
end
|
92
86
|
|
93
|
-
def disconnect
|
94
|
-
StropheRuby::EventLoop.stop(@ctx)
|
95
|
-
end
|
96
87
|
|
88
|
+
#Prepare the strophe library
|
97
89
|
StropheRuby::EventLoop.prepare
|
98
90
|
|
99
|
-
|
100
|
-
@
|
91
|
+
#create the runtime context and specify the logging level (WARN,INFO,ERROR or DEBUG)
|
92
|
+
@ctx=StropheRuby::Context.new(StropheRuby::Logging::DEBUG)
|
93
|
+
|
94
|
+
#create the connection passing it the context
|
95
|
+
@conn=StropheRuby::Connection.new(@ctx)
|
101
96
|
|
102
|
-
|
103
|
-
@conn.
|
97
|
+
#set the jid and password
|
98
|
+
@conn.jid = 'bot@example.com'
|
99
|
+
@conn.password = 'secret'
|
104
100
|
|
101
|
+
#Try to connect
|
105
102
|
@conn.connect do |status|
|
106
103
|
if status == StropheRuby::ConnectionEvents::CONNECT
|
104
|
+
#We are connected.
|
107
105
|
announce_presence
|
108
106
|
register_callbacks
|
109
107
|
else
|
110
|
-
|
108
|
+
@conn.disconnect
|
111
109
|
end
|
112
110
|
end
|
113
111
|
|
114
|
-
#This is a blocking call
|
115
|
-
StropheRuby::EventLoop.run(@ctx)
|
116
|
-
|
117
|
-
#Once the loop has exit, we can shutdown strophe
|
118
|
-
StropheRuby::EventLoop.shutdown
|
119
|
-
puts "Program has ended normally"
|
120
|
-
exit
|
121
112
|
|
122
|
-
|
113
|
+
#Start the event loop
|
114
|
+
StropheRuby::EventLoop.run(@ctx)
|
123
115
|
|
124
|
-
|
116
|
+
puts 'Disconnected'
|
125
117
|
|
126
118
|
== INSTALL:
|
127
119
|
|
128
|
-
|
120
|
+
gem install strophe_ruby
|
129
121
|
|
130
122
|
== LICENSE:
|
131
123
|
|
132
|
-
(The MIT License)
|
133
|
-
|
134
124
|
Copyright (c) 2008 François Lamontagne
|
135
125
|
|
136
126
|
Permission is hereby granted, free of charge, to any person obtaining
|
@@ -150,4 +140,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
150
140
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
151
141
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
152
142
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
153
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
143
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
-
#require File.dirname(__FILE__) + '/lib/strophe_ruby'
|
3
2
|
|
4
3
|
# Generate all the Rake tasks
|
5
4
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
-
$hoe = Hoe.new('strophe_ruby', '0.0.
|
5
|
+
$hoe = Hoe.new('strophe_ruby', '0.0.5') do |p|
|
7
6
|
p.developer('François Lamontagne', 'flamontagne@gmail.com')
|
8
7
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
8
|
p.rubyforge_name = p.name # TODO this is default value
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
p.extra_dev_deps = [
|
10
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
11
|
+
]
|
13
12
|
|
14
13
|
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
15
14
|
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
data/ext/strophe_ruby/libexpat.a
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/strophe_ruby.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strophe_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Fran\xC3\xA7ois Lamontagne"
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-14 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.0
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: hoe
|
17
27
|
type: :development
|
@@ -22,7 +32,7 @@ dependencies:
|
|
22
32
|
- !ruby/object:Gem::Version
|
23
33
|
version: 1.8.0
|
24
34
|
version:
|
25
|
-
description: "Ruby bindings for Strophe 'http://code.stanziq.com/strophe/', a C library for writing XMPP clients. If all you need is a simple XMPP bot that react to message and presence notifications, you might be better off with XMPPBot, which is an implementation I wrote on top of StropheRuby. IMPORTANT : This gem is quite experimental currently... it is not ready for production! Strophe 'http://code.stanziq.com/strophe/' is a robust and well written C library that allows the developer to implement XMPP clients. I wanted to be able to use the power of this library with the ruby syntax. I didn't use SWIG to generate the bindings for 2 reasons : 1. I wanted to learn how to write a C extension for ruby 2. I didn't like how SWIG generate gazilions of lines of code My other project, XMPPBot, is an implementation of Strophe Ruby that allows the ruby developer to write a XMPP bot in a few lines of code.
|
35
|
+
description: "Ruby bindings for Strophe 'http://code.stanziq.com/strophe/', a C library for writing XMPP clients. If all you need is a simple XMPP bot that react to message and presence notifications, you might be better off with XMPPBot, which is an implementation I wrote on top of StropheRuby. IMPORTANT : This gem is quite experimental currently... it is not ready for production! Strophe 'http://code.stanziq.com/strophe/' is a robust and well written C library that allows the developer to implement XMPP clients. I wanted to be able to use the power of this library with the ruby syntax. I didn't use SWIG to generate the bindings for 2 reasons : 1. I wanted to learn how to write a C extension for ruby 2. I didn't like how SWIG generate gazilions of lines of code My other project, XMPPBot, is an implementation of Strophe Ruby that allows the ruby developer to write a XMPP bot in a few lines of code."
|
26
36
|
email:
|
27
37
|
- flamontagne@gmail.com
|
28
38
|
executables: []
|
@@ -43,7 +53,11 @@ files:
|
|
43
53
|
- Rakefile
|
44
54
|
- ext/strophe_ruby/extconf.rb
|
45
55
|
- ext/strophe_ruby/libexpat.a
|
56
|
+
- ext/strophe_ruby/libexpat32.a
|
57
|
+
- ext/strophe_ruby/libexpat64.a
|
46
58
|
- ext/strophe_ruby/libstrophe.a
|
59
|
+
- ext/strophe_ruby/libstrophe32.a
|
60
|
+
- ext/strophe_ruby/libstrophe64.a
|
47
61
|
- ext/strophe_ruby/strophe.h
|
48
62
|
- ext/strophe_ruby/strophe/common.h
|
49
63
|
- ext/strophe_ruby/strophe/expat.h
|