tp-blather 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/.autotest +13 -0
  2. data/.gemtest +0 -0
  3. data/.gitignore +19 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +8 -0
  6. data/CHANGELOG.md +249 -0
  7. data/Gemfile +4 -0
  8. data/Guardfile +5 -0
  9. data/LICENSE +22 -0
  10. data/README.md +413 -0
  11. data/Rakefile +20 -0
  12. data/TODO.md +2 -0
  13. data/blather.gemspec +51 -0
  14. data/examples/certs/README +20 -0
  15. data/examples/certs/ca-bundle.crt +3987 -0
  16. data/examples/echo.rb +19 -0
  17. data/examples/execute.rb +17 -0
  18. data/examples/ping_pong.rb +38 -0
  19. data/examples/print_hierarchy.rb +77 -0
  20. data/examples/rosterprint.rb +15 -0
  21. data/examples/stream_only.rb +28 -0
  22. data/examples/trusted_echo.rb +21 -0
  23. data/examples/xmpp4r/echo.rb +36 -0
  24. data/lib/blather.rb +112 -0
  25. data/lib/blather/cert_store.rb +53 -0
  26. data/lib/blather/client.rb +95 -0
  27. data/lib/blather/client/client.rb +345 -0
  28. data/lib/blather/client/dsl.rb +320 -0
  29. data/lib/blather/client/dsl/pubsub.rb +174 -0
  30. data/lib/blather/core_ext/eventmachine.rb +125 -0
  31. data/lib/blather/core_ext/ipaddr.rb +20 -0
  32. data/lib/blather/errors.rb +69 -0
  33. data/lib/blather/errors/sasl_error.rb +44 -0
  34. data/lib/blather/errors/stanza_error.rb +110 -0
  35. data/lib/blather/errors/stream_error.rb +84 -0
  36. data/lib/blather/file_transfer.rb +107 -0
  37. data/lib/blather/file_transfer/ibb.rb +68 -0
  38. data/lib/blather/file_transfer/s5b.rb +114 -0
  39. data/lib/blather/jid.rb +141 -0
  40. data/lib/blather/roster.rb +118 -0
  41. data/lib/blather/roster_item.rb +146 -0
  42. data/lib/blather/stanza.rb +167 -0
  43. data/lib/blather/stanza/disco.rb +32 -0
  44. data/lib/blather/stanza/disco/capabilities.rb +161 -0
  45. data/lib/blather/stanza/disco/disco_info.rb +205 -0
  46. data/lib/blather/stanza/disco/disco_items.rb +134 -0
  47. data/lib/blather/stanza/iq.rb +144 -0
  48. data/lib/blather/stanza/iq/command.rb +339 -0
  49. data/lib/blather/stanza/iq/ibb.rb +86 -0
  50. data/lib/blather/stanza/iq/ping.rb +50 -0
  51. data/lib/blather/stanza/iq/query.rb +53 -0
  52. data/lib/blather/stanza/iq/roster.rb +185 -0
  53. data/lib/blather/stanza/iq/s5b.rb +208 -0
  54. data/lib/blather/stanza/iq/si.rb +415 -0
  55. data/lib/blather/stanza/iq/vcard.rb +149 -0
  56. data/lib/blather/stanza/message.rb +428 -0
  57. data/lib/blather/stanza/message/muc_user.rb +119 -0
  58. data/lib/blather/stanza/muc/muc_user_base.rb +54 -0
  59. data/lib/blather/stanza/presence.rb +172 -0
  60. data/lib/blather/stanza/presence/c.rb +100 -0
  61. data/lib/blather/stanza/presence/muc.rb +35 -0
  62. data/lib/blather/stanza/presence/muc_user.rb +147 -0
  63. data/lib/blather/stanza/presence/status.rb +218 -0
  64. data/lib/blather/stanza/presence/subscription.rb +100 -0
  65. data/lib/blather/stanza/pubsub.rb +119 -0
  66. data/lib/blather/stanza/pubsub/affiliations.rb +79 -0
  67. data/lib/blather/stanza/pubsub/create.rb +65 -0
  68. data/lib/blather/stanza/pubsub/errors.rb +18 -0
  69. data/lib/blather/stanza/pubsub/event.rb +139 -0
  70. data/lib/blather/stanza/pubsub/items.rb +103 -0
  71. data/lib/blather/stanza/pubsub/publish.rb +103 -0
  72. data/lib/blather/stanza/pubsub/retract.rb +92 -0
  73. data/lib/blather/stanza/pubsub/subscribe.rb +68 -0
  74. data/lib/blather/stanza/pubsub/subscription.rb +135 -0
  75. data/lib/blather/stanza/pubsub/subscriptions.rb +83 -0
  76. data/lib/blather/stanza/pubsub/unsubscribe.rb +84 -0
  77. data/lib/blather/stanza/pubsub_owner.rb +51 -0
  78. data/lib/blather/stanza/pubsub_owner/delete.rb +52 -0
  79. data/lib/blather/stanza/pubsub_owner/purge.rb +52 -0
  80. data/lib/blather/stanza/x.rb +416 -0
  81. data/lib/blather/stream.rb +266 -0
  82. data/lib/blather/stream/client.rb +32 -0
  83. data/lib/blather/stream/component.rb +39 -0
  84. data/lib/blather/stream/features.rb +70 -0
  85. data/lib/blather/stream/features/register.rb +38 -0
  86. data/lib/blather/stream/features/resource.rb +63 -0
  87. data/lib/blather/stream/features/sasl.rb +190 -0
  88. data/lib/blather/stream/features/session.rb +45 -0
  89. data/lib/blather/stream/features/tls.rb +29 -0
  90. data/lib/blather/stream/parser.rb +102 -0
  91. data/lib/blather/version.rb +3 -0
  92. data/lib/blather/xmpp_node.rb +94 -0
  93. data/spec/blather/client/client_spec.rb +687 -0
  94. data/spec/blather/client/dsl/pubsub_spec.rb +492 -0
  95. data/spec/blather/client/dsl_spec.rb +266 -0
  96. data/spec/blather/errors/sasl_error_spec.rb +33 -0
  97. data/spec/blather/errors/stanza_error_spec.rb +129 -0
  98. data/spec/blather/errors/stream_error_spec.rb +108 -0
  99. data/spec/blather/errors_spec.rb +33 -0
  100. data/spec/blather/file_transfer_spec.rb +135 -0
  101. data/spec/blather/jid_spec.rb +87 -0
  102. data/spec/blather/roster_item_spec.rb +134 -0
  103. data/spec/blather/roster_spec.rb +107 -0
  104. data/spec/blather/stanza/discos/disco_info_spec.rb +247 -0
  105. data/spec/blather/stanza/discos/disco_items_spec.rb +154 -0
  106. data/spec/blather/stanza/iq/command_spec.rb +206 -0
  107. data/spec/blather/stanza/iq/ibb_spec.rb +124 -0
  108. data/spec/blather/stanza/iq/ping_spec.rb +45 -0
  109. data/spec/blather/stanza/iq/query_spec.rb +64 -0
  110. data/spec/blather/stanza/iq/roster_spec.rb +139 -0
  111. data/spec/blather/stanza/iq/s5b_spec.rb +57 -0
  112. data/spec/blather/stanza/iq/si_spec.rb +98 -0
  113. data/spec/blather/stanza/iq/vcard_spec.rb +93 -0
  114. data/spec/blather/stanza/iq_spec.rb +61 -0
  115. data/spec/blather/stanza/message/muc_user_spec.rb +152 -0
  116. data/spec/blather/stanza/message_spec.rb +282 -0
  117. data/spec/blather/stanza/presence/c_spec.rb +56 -0
  118. data/spec/blather/stanza/presence/muc_spec.rb +37 -0
  119. data/spec/blather/stanza/presence/muc_user_spec.rb +83 -0
  120. data/spec/blather/stanza/presence/status_spec.rb +144 -0
  121. data/spec/blather/stanza/presence/subscription_spec.rb +102 -0
  122. data/spec/blather/stanza/presence_spec.rb +125 -0
  123. data/spec/blather/stanza/pubsub/affiliations_spec.rb +57 -0
  124. data/spec/blather/stanza/pubsub/create_spec.rb +56 -0
  125. data/spec/blather/stanza/pubsub/event_spec.rb +98 -0
  126. data/spec/blather/stanza/pubsub/items_spec.rb +79 -0
  127. data/spec/blather/stanza/pubsub/publish_spec.rb +83 -0
  128. data/spec/blather/stanza/pubsub/retract_spec.rb +75 -0
  129. data/spec/blather/stanza/pubsub/subscribe_spec.rb +61 -0
  130. data/spec/blather/stanza/pubsub/subscription_spec.rb +97 -0
  131. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +59 -0
  132. data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +74 -0
  133. data/spec/blather/stanza/pubsub_owner/delete_spec.rb +50 -0
  134. data/spec/blather/stanza/pubsub_owner/purge_spec.rb +50 -0
  135. data/spec/blather/stanza/pubsub_owner_spec.rb +27 -0
  136. data/spec/blather/stanza/pubsub_spec.rb +68 -0
  137. data/spec/blather/stanza/x_spec.rb +231 -0
  138. data/spec/blather/stanza_spec.rb +134 -0
  139. data/spec/blather/stream/client_spec.rb +1090 -0
  140. data/spec/blather/stream/component_spec.rb +108 -0
  141. data/spec/blather/stream/parser_spec.rb +152 -0
  142. data/spec/blather/stream/ssl_spec.rb +32 -0
  143. data/spec/blather/xmpp_node_spec.rb +47 -0
  144. data/spec/blather_spec.rb +34 -0
  145. data/spec/fixtures/pubsub.rb +311 -0
  146. data/spec/spec_helper.rb +17 -0
  147. data/yard/templates/default/class/html/handlers.erb +18 -0
  148. data/yard/templates/default/class/setup.rb +10 -0
  149. data/yard/templates/default/class/text/handlers.erb +1 -0
  150. metadata +459 -0
data/.autotest ADDED
@@ -0,0 +1,13 @@
1
+ Autotest.add_hook :initialize do |at|
2
+ ignore = %w[.git examples ext pkg .DS_Store CHANGELOG LICENSE VERSION.yml README.rdoc .autotest Rakefile blather.gemspec]
3
+
4
+ ignore.each { |exception| at.add_exception(exception) }
5
+
6
+ at.clear_mappings
7
+
8
+ at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _| filename }
9
+ at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/#{m[1]}_spec.rb"] }
10
+ at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
11
+ at.files_matching %r%^spec/.*_spec\.rb$%
12
+ }
13
+ end
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ pkg
2
+ Manifest
3
+ doc
4
+ coverage
5
+ *.bundle
6
+ Gemfile.lock
7
+ mkmf.log
8
+ *.o
9
+ Makefile
10
+ rdoc
11
+ *.gem
12
+ *.log
13
+ *.pid
14
+ notes
15
+ .yardoc
16
+ *.rbc
17
+ vendor
18
+ .rvmrc
19
+ .rbx
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --colour
3
+ --tty
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - jruby-18mode
5
+ - jruby-19mode
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ - ruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,249 @@
1
+ # [develop](https://github.com/adhearsion/blather/compare/master...develop)
2
+
3
+ # [v0.8.1](https://github.com/adhearsion/blather/compare/v0.8.0...v0.8.1) - [2012-09-17](https://rubygems.org/gems/blather/versions/0.8.1)
4
+ * Project moved to the Adhearsion Foundation
5
+ * Fixes for EventMachine 1.0.x
6
+ * Simplify booting client using the DSL in the varying supported modes
7
+ * Documentation fixes
8
+
9
+ # [v0.8.0](https://github.com/adhearsion/blather/compare/v0.7.1...v0.8.0) - [2012-07-09](https://rubygems.org/gems/blather/versions/0.8.0)
10
+ * Feature(jmkeys): DSL methods for joining and sending messages to MUC rooms
11
+ * Feature(jackhong): Inband registration support
12
+ * Bugfix(benlangfeld): Ensure that presence nodes which are both status and subscription may be responded to
13
+ * Bugfix(benlangfeld): A whole bunch of JRuby fixes
14
+
15
+ # [v0.7.1](https://github.com/adhearsion/blather/compare/v0.7.0...v0.7.1) - [2012-04-29](https://rubygems.org/gems/blather/versions/0.7.1)
16
+ * Documentation updates
17
+ * Bugfix(benlangfeld): Relax Nokogiri dependency to allow 1.5
18
+ * Bugfix(benlangfeld): Fix some nokogiri 1.5 related bugs on JRuby (some remain)
19
+ * Bugfix(benlangfeld): Set namespaces correctly on some tricky nodes
20
+ * Bugfix(benlangfeld): Ensure all presence sub-types trigger the correct handlers
21
+
22
+ # [v0.7.0](https://github.com/adhearsion/blather/compare/v0.6.2...v0.7.0) - [2012-03-15](https://rubygems.org/gems/blather/versions/0.7.0)
23
+ * Change(benlangfeld): Drop Ruby 1.8.7 compatability
24
+ * Change(bklang): Remove the wire log, which duplicated the parsed logging
25
+ * Feature(benlangfeld): Stanza handlers are now executed outside of the EM reactor, so it is not blocked on stanza processing
26
+ * Bugfix(benlangfeld): MUC user presence and messages now have separate handler names
27
+ * Feature(benlangfeld): Stanzas may now be imported from a string using `XMPPNode.parse`
28
+ * Bugfix(benlangfeld): All `Blather::Stanza::Presence::C` attributes are now accessible on importing
29
+ * Bugfix(benlangfeld): Presence stanzas are now composed on import, including all children
30
+ * Bugfix(mtrudel): JIDs in roster item stanzas are now stripped of resources
31
+
32
+ # [v0.6.2](https://github.com/adhearsion/blather/compare/v0.6.1...v0.6.2) - [2012-02-28](https://rubygems.org/gems/blather/versions/0.6.2)
33
+ * Feature(benlangfeld): Add password support to `MUCUser`
34
+ * Feature(benlangfeld): Add support for invitation elements to `MUCUser` messages
35
+ * Feature(benlangfeld): Add support for MUC invite declines
36
+ * Bugfix(benlangfeld): Don't implicitly create an invite node when checking invite status
37
+ * Bugfix(benlangfeld): Ensure that form nodes are not duplicated on muc/muc_user presence stanzas
38
+
39
+ # [v0.6.1](https://github.com/adhearsion/blather/compare/v0.6.0...v0.6.1) - [2012-02-25](https://rubygems.org/gems/blather/versions/0.6.1)
40
+ * Bugfix(benlangfeld): Ensure MUC presence nodes (joining) have a form element on creation
41
+
42
+ # [v0.6.0](https://github.com/adhearsion/blather/compare/v0.5.12...v0.6.0) - [2012-02-24](https://rubygems.org/gems/blather/versions/0.6.0)
43
+ * Feature(benlangfeld): Very basic MUC and delayed message support
44
+ * Bugfix(theozaurus): Disable connection timeout timer if client deliberately disconnects
45
+ * Bugfix(mtrudel): Fix `Roster#each` to return roster_items as per documentation
46
+
47
+ # [v0.5.12](https://github.com/adhearsion/blather/compare/v0.5.11...v0.5.12) - [2012-01-06](https://rubygems.org/gems/blather/versions/0.5.12)
48
+ * Bugfix(benlangfeld): Allow specifying the connection timeout in DSL setup
49
+
50
+ # [v0.5.11](https://github.com/adhearsion/blather/compare/v0.5.10...v0.5.11) - [2012-01-06](https://rubygems.org/gems/blather/versions/0.5.11)
51
+ * Feature(benlangfeld): Allow specifying a connection timeout
52
+ * Raise `Blather::Stream::ConnectionTimeout` if timeout is exceeded
53
+ * Default to 180 seconds
54
+
55
+ # [v0.5.10](https://github.com/adhearsion/blather/compare/v0.5.9...v0.5.10) - [2011-12-02](https://rubygems.org/gems/blather/versions/0.5.10)
56
+ * Feature(juandebravo): Allow configuring the wire log level
57
+ * Bugfix(benlangfeld): Checking connection status before the stream is established
58
+
59
+ # [v0.5.9](https://github.com/adhearsion/blather/compare/v0.5.8...v0.5.9) - [2011-11-24](https://rubygems.org/gems/blather/versions/0.5.9)
60
+ * Bugfix(benlangfeld): Failed connections now raise a Blather::Stream::ConnectionFailed exception
61
+ * Bugfix(crohr): Blather now supports EventMachine 1.0
62
+
63
+ # v0.5.8
64
+ * Bugfix(benlangfeld): JIDs now maintain case, but still compare case insensitively
65
+ * Bugfix(jmazzi): Development dependencies now resolve correctly on JRuby and Rubinius
66
+
67
+ # v0.5.7
68
+ * Bugfix(benlangfeld): Don't install BlueCloth as a development dependency when on JRuby
69
+
70
+ # v0.5.6
71
+ * Changes from 0.5.5, this time without a bug when using the namespaced DSL approach
72
+
73
+ # v0.5.5 (yanked)
74
+ * Bugfix(benlangfeld/kibs): ActiveSupport was overriding the presence DSL method
75
+ * Feature(fyafighter): Adds SSL peer verification to TLS
76
+
77
+ # v0.5.4
78
+ * Bugfix(fyafighter): Regression related to earlier refactoring: https://github.com/sprsquish/blather/issues/53
79
+ * Feature(fyafighter): Make it much easier to allow private network addresses
80
+ * Bugfix(benlangfeld): Fix the Nokogiri dependency to the 1.4.x series, due to a bug in 1.5.x
81
+ * Bugfix(zlu): Replace class_inheritable_attribute with class_attribute because it is deprecated in ActiveSupport 3.1
82
+
83
+ # v0.5.3
84
+ * Feature(benlangfeld): Add XMPP Ping (XEP-0199) support
85
+
86
+ # v0.5.2
87
+ * Bugfix(benlangfeld): Remove specs for the Nokogiri extensions which were moved out
88
+
89
+ # v0.5.1 - yanked
90
+ * Feature(benlangfeld): Abstract out Nokogiri extensions and helpers into new Niceogiri gem for better sharing
91
+ * Documentation(benlangfeld)
92
+
93
+ # v0.5.0
94
+ * Feature(radsaq): Add a #connected? method on Blather::Client
95
+ * Feature(benlangfeld)[API change]: Allow the removal of child nodes from an IQ reply
96
+ * Bugfix(zlu): Use rubygems properly in examples
97
+ * Bugfix(benlangfeld): Remove code borrowed from ActiveSupport and instead depend on it to avoid version conflicts
98
+ * Documentation(sprsquish)
99
+
100
+ # v0.4.16
101
+ * Feature(benlangfeld): switch from jeweler to bundler
102
+ * Feature(benlangfeld): add cap support (XEP-0115)
103
+ * Bugfix(sprsquish): Better equality checking
104
+ * Bugfix(sprsquish): Fix #to_proc
105
+ * Bugfix(mironov): Skip private IPs by default
106
+
107
+ # v0.4.15
108
+ * Feature(mironov): Implement XEP-0054: vcard-temp
109
+ * Feature(benlangfeld): Basic support for PubSub subscription notifications as PubSub events
110
+ * Feature(mironov): Ability to clear handlers
111
+ * Feature(mironov): Implement incoming file transfers (XEP-0096, XEP-0065, XEP-0047)
112
+ * Bugfix(mironov): Fix for importing messages with chat states
113
+ * Bugfix(mironov): Added Symbol#to_proc method to work on ruby 1.8.6
114
+ * Bugfix(mironov): Fix roster items .status method to return highest priority presence
115
+ * Bugfix(mironov): Remove old unavailable presences while adding new one
116
+ * Bugfix(mironov): Use Nokogiri::XML::ParseOptions::NOENT to prevent double-encoding of entities
117
+ * Bugfix(benlangfeld): Disco Info Identities should have an xml:lang attribute
118
+ * Bugfix(mironov): Fix lookup path for ruby 1.9
119
+ * Bugfix(mironov): stanza_error.to_node must set type of the error
120
+ * Bugfix(mironov): Allow message to have iq child
121
+ * Bugfix(mironov): Find xhtml body in messages sent from iChat 5.0.3
122
+
123
+ # v0.4.14
124
+ * Tests: get specs fully passing on rubinius
125
+ * Feature(mironov): Implement XEP-0085 Chat State Notifications
126
+ * Bugfix(mironov): send stanzas unformatted
127
+ * Bugfix(mironov): Message#xhtml uses inner_html so tags aren't escaped
128
+ * Bugfix(mironov): Message#xhtml= now works with multiple root nodes
129
+
130
+ # v0.4.13
131
+ * Bugfix: Place form child of command inside command element
132
+
133
+ # v0.4.12
134
+ * API Change: Switch order of var and type arguments to X::Field.new since var is always required but type is not
135
+ * API Change: PubSub payloads can be strings or nodes and can be set nil. PubSub#payload will always return a string
136
+ * Feature: Add forms to Message stanzas
137
+
138
+ # v0.4.11
139
+ * Bugfix: command nodes where generating the wrong xml
140
+ * Bugfix: x nodes where generating the wrong xml
141
+ * Feature: ability to set identities and features on disco info nodes
142
+ * Feature: ability to set items on disco item nodes
143
+
144
+ # v0.4.10
145
+ * no change
146
+
147
+ # v0.4.9
148
+ * Feature: XEP-0004 x:data (benlangfeld)
149
+ * Feature: XEP-0050 Ad-Hoc commands (benlangfeld)
150
+ * Minor bugfixes for the specs
151
+
152
+ # v0.4.8
153
+ * Feature: add xhtml getter/setter to Message stanza
154
+ * Bugfix: heirarchy -> hierarchy spelling mistake
155
+ * Hella documentation
156
+
157
+ # v0.4.7
158
+ * Update to work with Nokogiri 1.4.0
159
+
160
+ # v0.4.6
161
+ * Bugfix: prioritize authentication mechanisms
162
+
163
+ # v0.4.5
164
+ * Bugfix: Change DSL#write to DSL#write_to_stream. Previous way was messing with YAML
165
+
166
+ # v0.4.4
167
+ * Add "disconnected" handler type to handle connection termination
168
+ * Bugfix: Fix error with pubsub using the wrong client connection
169
+
170
+ # v0.4.3
171
+ * Bugfix: status stanza with a blank state will be considered :available (GH-23)
172
+ * Bugfix: ensure regexp guards try to match against a string (GH-24)
173
+ * Stream creation is now evented. The stream object will be sent to #post_init
174
+ * Parser debugging disabled by default
175
+ * Update parser to work with Nokogiri 1.3.2
176
+ * Bugfix: discover helper now calls the correct method on client
177
+ * Bugfix: ensure XMPPNode#inherit properly sets namespaces on inherited nodes
178
+ * Bugfix: xpath guards with namespaces work properly (GH-25)
179
+
180
+ # v0.4.2
181
+ * Fix -D option to actually put Blather in debug mode
182
+ * Stanzas over a client connection will either have the full JID or no JID
183
+ * Regexp guards can be anything that implements #last_match (Regexp or Oniguruma)
184
+ * Add "halt" and "pass" to allow handlers to either halt the handler chain or pass to the next handler
185
+ * Fix default status handler so it doesn't eat the stanza
186
+ * Add before and after filters. Filters, like handlers, can have guards.
187
+
188
+ # v0.4.1
189
+ * Bugfix in roster: trying to call the wrong method on client
190
+
191
+ # v0.4.0
192
+ * Switch from LibXML-Ruby to Nokogiri
193
+ * Update test suite to run on Ruby 1.9
194
+ * Add "<<" style writer to the DSL to provide for chaining outbound writes
195
+ * SRV lookup support
196
+ * Add XPath type of handler guard
197
+ * PubSub support
198
+
199
+ # v0.3.4
200
+ * Remove unneeded functions from the push parser.
201
+ * Create a ParseWarning error that doesn't kill the stream.
202
+ * When a parse error comes in the reply should let the other side know it screwed up before dying.
203
+ * Add the LibXML::XML::Error node to the ParseError/ParseWarning objects.
204
+
205
+ # v0.3.3
206
+ * Fix the load error related to not pushing Blather's dir into the load path
207
+
208
+ # v0.3.2
209
+ * Switch the push parser from chunking to streaming.
210
+ * Don't push Blather's dir into the load paths
211
+
212
+ # v0.3.1
213
+ * Small changes to the DSL due to handler collisions:
214
+ "status" -> "set_status"
215
+ "roster" -> "my_roster"
216
+ * Small changes to the Blather::Client API to keep it feeling more like EM's API:
217
+ #stream_started -> #post_init
218
+ #call -> #receive_data
219
+ #stop -> #close
220
+ #stopped -> #unbind
221
+ * Refactored some of the code internal to Blather::Client
222
+ * Added command line option handler to default use method (see README)
223
+ * require libxml-ruby >=1.1.2 (1.1.3 has an inconsistent malloc err on OS X 10.5)
224
+ * complete specs
225
+ * add single process ping-pong example
226
+
227
+ # v0.3.0
228
+ * Remove autotest discover.rb (created all sorts of conflicts)
229
+ * Added Hash with Array guard
230
+ * Added a hirrarchy printer to examples directory
231
+ * Moved Disco to be in the Stanza namespace (staves off deeply namespaced classes)
232
+ * Namespaced the DSL methods to Blather::DSL. These can be included in any object you like now. "require 'blather/client'" will still include them directly in Kernel to keep the simple one-file dsl
233
+ * Stopped doing one class per error type. This created a giant hierarchy tree that was just unnecessary. The error name is now #name. Errors can be matched with a combination of handler and guard.
234
+ * Fixed XML namespaces. Previous versions weren't actually adding the node to the namespace making xpath queries inconsistent at best.
235
+ * Added support for anonymous authentication by providing a blank node on the jid ("@[host]")
236
+
237
+ # v0.2.3
238
+ * Go back to using the master branch for gems (stupid mistake)
239
+
240
+ # v0.2.2
241
+ * Switch to Jeweler.
242
+ * Move from custom libxml to just a custom push parser
243
+ * Add guards to handlers
244
+
245
+ # v0.2.1 Upgrade to libxml 0.9.7
246
+
247
+ # v0.2 Overhaul the DSL to look more like Sinatra
248
+
249
+ # v0.1 Initial release (birth!)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in blather.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2, :cli => '--format documentation' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec/" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Blather
2
+
3
+ Copyright (c) 2012 Adhearsion Foundation Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,413 @@
1
+ # Blather [ ![Build status](http://travis-ci.org/adhearsion/blather.png) ](http://travis-ci.org/adhearsion/blather)
2
+
3
+ XMPP DSL (and more) for Ruby written on [EventMachine](http://rubyeventmachine.com/) and [Nokogiri](http://nokogiri.org/).
4
+
5
+ ## Features
6
+
7
+ * evented architecture
8
+ * uses Nokogiri
9
+ * simplified starting point
10
+
11
+ ## Project Pages
12
+
13
+ * [GitHub](https://github.com/adhearsion/blather)
14
+ * [Gemcutter](http://gemcutter.org/gems/blather)
15
+ * [API Documentation](http://rdoc.info/gems/blather/file/README.md)
16
+ * [Google Group](http://groups.google.com/group/xmpp-blather)
17
+
18
+ # Usage
19
+
20
+ ## Installation
21
+
22
+ gem install blather
23
+
24
+ ## Example
25
+
26
+ Blather comes with a DSL that makes writing XMPP bots quick and easy. See the examples directory for more advanced examples.
27
+
28
+ ```ruby
29
+ require 'rubygems'
30
+ require 'blather/client'
31
+
32
+ setup 'echo@jabber.local', 'echo'
33
+
34
+ # Auto approve subscription requests
35
+ subscription :request? do |s|
36
+ write_to_stream s.approve!
37
+ end
38
+
39
+ # Echo back what was said
40
+ message :chat?, :body do |m|
41
+ write_to_stream m.reply
42
+ end
43
+ ```
44
+
45
+ ## Handlers
46
+
47
+ 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.
48
+
49
+ XMPP is built on top of three main stanza types (presence, message, and iq). All other stanzas are built on these three base types. This creates a natural hierarchy of handlers. For example a subscription stanza is a type of presence stanza and can be processed by a subscription handler or a presence handler. Likewise, a PubSub::Items stanza has its own identifier :pubsub_items but it's also a :pubsub_node, :iq and :staza. Any or each of these could be used to handle the PubSub::Items stanza. If you've done any DOM programming you'll be familiar with this.
50
+
51
+ Incoming stanzas will be handled by the first handler found. Unlike the DOM this will stop the handling bubble unless the handler returns false.
52
+
53
+ The entire handler hierarchy can be seen below.
54
+
55
+ ### Example
56
+
57
+ Here we have a presence handler and a subscription handler. When this script receives a subscription stanza the subscription handler will be notified first. If that handler doesn't know what to do it can return false and let the stanza bubble up to the presence handler.
58
+
59
+ ```ruby
60
+ # Handle all presence stanzas
61
+ presence do |stanza|
62
+ # do stuff
63
+ end
64
+
65
+ # Handle all subscription stanzas
66
+ subscription do |stanza|
67
+ # do stuff
68
+ end
69
+ ```
70
+
71
+ Additionally, handlers may be 'guarded'. That is, they may have conditions set declaratively, against which the stanza must match in order to trigger the handler.
72
+
73
+ ```ruby
74
+ # Will only be called for messages where #chat? responds positively
75
+ # and #body == 'exit'
76
+ message :chat?, :body => 'exit'
77
+ ```
78
+
79
+ ### Non-Stanza Handlers
80
+
81
+ So far there are two non-stanza related handlers.
82
+
83
+ ```ruby
84
+ # Called after the connection has been connected. It's good for initializing
85
+ # your system.
86
+ # DSL:
87
+ when_ready {}
88
+ # Client:
89
+ client.register_handler(:ready) {}
90
+
91
+ # Called after the connection has been terminated. Good for teardown or
92
+ # automatic reconnection.
93
+ # DSL:
94
+ disconnected {}
95
+ # Client
96
+ client.register_handler(:disconnected) {}
97
+ # The following will reconnect every time the connection is lost:
98
+ disconnected { client.connect }
99
+ ```
100
+
101
+ ### Handler Guards
102
+
103
+ Guards are a concept borrowed from Erlang. They help to better compartmentalize handlers.
104
+
105
+ There are a number of guard types and one bit of special syntax. Guards act like AND statements. Each condition must be met if the handler is to
106
+ be used.
107
+
108
+ ```ruby
109
+ # Equivalent to saying (stanza.chat? && stanza.body)
110
+ message :chat?, :body
111
+ ```
112
+
113
+ The different types of guards are:
114
+
115
+ ```ruby
116
+ # Symbol
117
+ # Checks for a non-false reply to calling the symbol on the stanza
118
+ # Equivalent to stanza.chat?
119
+ message :chat?
120
+
121
+ # Hash with any value (:body => 'exit')
122
+ # Calls the key on the stanza and checks for equality
123
+ # Equivalent to stanza.body == 'exit'
124
+ message :body => 'exit'
125
+
126
+ # Hash with regular expression (:body => /exit/)
127
+ # Calls the key on the stanza and checks for a match
128
+ # Equivalent to stanza.body.match /exit/
129
+ message :body => /exit/
130
+
131
+ # Hash with array (:name => [:gone, :forbidden])
132
+ # Calls the key on the stanza and check for inclusion in the array
133
+ # Equivalent to [:gone, :forbidden].include?(stanza.name)
134
+ stanza_error :name => [:gone, :fobidden]
135
+
136
+ # Proc
137
+ # Calls the proc passing in the stanza
138
+ # Checks that the ID is modulo 3
139
+ message proc { |m| m.id % 3 == 0 }
140
+
141
+ # Array
142
+ # Use arrays with the previous types effectively turns the guard into
143
+ # an OR statement.
144
+ # Equivalent to stanza.body == 'foo' || stanza.body == 'baz'
145
+ message [{:body => 'foo'}, {:body => 'baz'}]
146
+
147
+ # XPath
148
+ # Runs the xpath query on the stanza and checks for results
149
+ # This guard type cannot be combined with other guards
150
+ # Equivalent to !stanza.find('/iq/ns:pubsub', :ns => 'pubsub:namespace').empty?
151
+ # It also passes two arguments into the handler block: the stanza and the result
152
+ # of the xpath query.
153
+ iq '/iq/ns:pubsub', :ns => 'pubsub:namespace' do |stanza, xpath_result|
154
+ # stanza will be the original stanza
155
+ # xpath_result will be the pubsub node in the stanza
156
+ end
157
+ ```
158
+
159
+ ### Filters
160
+
161
+ Blather provides before and after filters that work much the way regular
162
+ handlers work. Filters come in a before and after flavor. They're called in
163
+ order of definition and can be guarded like handlers.
164
+
165
+ ```ruby
166
+ before { |s| "I'm run before any handler" }
167
+ before { |s| "I'm run next" }
168
+
169
+ before(:message) { |s| "I'm only run in front of message stanzas" }
170
+ before(nil, :id => 1) { |s| "I'll only be run when the stanza's ID == 1" }
171
+
172
+ # ... handlers
173
+
174
+ after { |s| "I'm run after everything" }
175
+ ```
176
+
177
+ ### Handlers Hierarchy
178
+
179
+ ```
180
+ stanza
181
+ |- iq
182
+ | |- pubsub_node
183
+ | | |- pubsub_affiliations
184
+ | | |- pubsub_create
185
+ | | |- pubsub_items
186
+ | | |- pubsub_publish
187
+ | | |- pubsub_retract
188
+ | | |- pubsub_subscribe
189
+ | | |- pubsub_subscription
190
+ | | |- pubsub_subscriptions
191
+ | | `- pubsub_unsubscribe
192
+ | |- pubsub_owner
193
+ | | |- pubsub_delete
194
+ | | `- pubsub_purge
195
+ | `- query
196
+ | |- disco_info
197
+ | |- disco_items
198
+ | `- roster
199
+ |- message
200
+ | `- pubsub_event
201
+ `- presence
202
+ |- status
203
+ `- subscription
204
+
205
+ error
206
+ |- argument_error
207
+ |- parse_error
208
+ |- sasl_error
209
+ |- sasl_unknown_mechanism
210
+ |- stanza_error
211
+ |- stream_error
212
+ |- tls_failure
213
+ `- unknown_response_error
214
+ ```
215
+
216
+ ## On the Command Line
217
+
218
+ Default usage is:
219
+
220
+ ```
221
+ [blather_script] [options] node@domain.com/resource password [host] [port]
222
+ ```
223
+
224
+ Command line options:
225
+
226
+ ```
227
+ -D, --debug Run in debug mode (you will see all XMPP communication)
228
+ -d, --daemonize Daemonize the process
229
+ --pid=[PID] Write the PID to this file
230
+ --log=[LOG] Write to the [LOG] file instead of stdout/stderr
231
+ -h, --help Show this message
232
+ -v, --version Show version
233
+ ```
234
+
235
+ ## Health warning
236
+
237
+ Some parts of Blather will allow you to do stupid things that don't conform to XMPP
238
+ spec. You should exercise caution and read the relevant specifications (indicated in
239
+ the preamble to most relevant classes).
240
+
241
+ ## Spec compliance
242
+
243
+ Blather provides support in one way or another for many XMPP specifications. Below is a list of specifications and the status of support for them in Blather. This list *may not be correct*. If the list indicates a lack of support for a specification you wish to use, you are encouraged to check that this is correct. Likewise, if you find an overstatement of Blather's spec compliance, please point this out. Also note that even without built-in support for a specification, you can still manually construct and parse stanzas alongside use of Blather's built-in helpers.
244
+
245
+ Specification | Support | Notes
246
+ ------------- | ------- | -----
247
+ RFC 6120 | Full |
248
+ RFC 6121 | Full |
249
+ RFC 6122 | Full |
250
+ XEP-0001 | N/A |
251
+ XEP-0002 | N/A |
252
+ XEP-0004 | Partial |
253
+ XEP-0009 | None |
254
+ XEP-0012 | None |
255
+ XEP-0013 | None |
256
+ XEP-0016 | None |
257
+ XEP-0019 | N/A |
258
+ XEP-0020 | Partial |
259
+ XEP-0027 | None |
260
+ XEP-0030 | Partial |
261
+ XEP-0033 | None |
262
+ XEP-0045 | Partial |
263
+ XEP-0047 | None |
264
+ XEP-0048 | None |
265
+ XEP-0049 | None |
266
+ XEP-0050 | Partial |
267
+ XEP-0053 | None |
268
+ XEP-0054 | None |
269
+ XEP-0055 | None |
270
+ XEP-0059 | None |
271
+ XEP-0060 | Partial |
272
+ XEP-0065 | None |
273
+ XEP-0066 | None |
274
+ XEP-0068 | None |
275
+ XEP-0070 | None |
276
+ XEP-0071 | Partial |
277
+ XEP-0072 | None |
278
+ XEP-0076 | None |
279
+ XEP-0077 | None |
280
+ XEP-0079 | None |
281
+ XEP-0080 | None |
282
+ XEP-0082 | None |
283
+ XEP-0083 | None |
284
+ XEP-0084 | None |
285
+ XEP-0085 | Partial |
286
+ XEP-0092 | None |
287
+ XEP-0095 | Partial |
288
+ XEP-0096 | Partial |
289
+ XEP-0100 | None |
290
+ XEP-0106 | None |
291
+ XEP-0107 | None |
292
+ XEP-0108 | None |
293
+ XEP-0114 | Full |
294
+ XEP-0115 | Partial |
295
+ XEP-0118 | None |
296
+ XEP-0122 | None |
297
+ XEP-0124 | None |
298
+ XEP-0126 | None |
299
+ XEP-0127 | None |
300
+ XEP-0128 | None |
301
+ XEP-0130 | None |
302
+ XEP-0131 | None |
303
+ XEP-0132 | None |
304
+ XEP-0133 | None |
305
+ XEP-0134 | None |
306
+ XEP-0136 | None |
307
+ XEP-0137 | None |
308
+ XEP-0138 | None |
309
+ XEP-0141 | None |
310
+ XEP-0143 | None |
311
+ XEP-0144 | N/A |
312
+ XEP-0145 | None |
313
+ XEP-0146 | None |
314
+ XEP-0147 | None |
315
+ XEP-0148 | None |
316
+ XEP-0149 | None |
317
+ XEP-0153 | None |
318
+ XEP-0155 | None |
319
+ XEP-0156 | None |
320
+ XEP-0157 | None |
321
+ XEP-0158 | None |
322
+ XEP-0160 | None |
323
+ XEP-0163 | Partial |
324
+ XEP-0166 | None |
325
+ XEP-0167 | None |
326
+ XEP-0169 | None |
327
+ XEP-0170 | None |
328
+ XEP-0171 | None |
329
+ XEP-0172 | None |
330
+ XEP-0174 | None |
331
+ XEP-0175 | None |
332
+ XEP-0176 | None |
333
+ XEP-0177 | None |
334
+ XEP-0178 | None |
335
+ XEP-0182 | N/A |
336
+ XEP-0183 | None |
337
+ XEP-0184 | None |
338
+ XEP-0185 | None |
339
+ XEP-0191 | None |
340
+ XEP-0198 | None |
341
+ XEP-0199 | Partial |
342
+ XEP-0201 | None |
343
+ XEP-0202 | None |
344
+ XEP-0203 | Partial |
345
+ XEP-0205 | None |
346
+ XEP-0206 | None |
347
+ XEP-0207 | None |
348
+ XEP-0220 | None |
349
+ XEP-0221 | None |
350
+ XEP-0222 | None |
351
+ XEP-0223 | None |
352
+ XEP-0224 | None |
353
+ XEP-0227 | None |
354
+ XEP-0229 | None |
355
+ XEP-0231 | None |
356
+ XEP-0233 | None |
357
+ XEP-0234 | None |
358
+ XEP-0239 | None |
359
+ XEP-0242 | None |
360
+ XEP-0243 | None |
361
+ XEP-0245 | None |
362
+ XEP-0249 | None |
363
+ XEP-0256 | None |
364
+ XEP-0258 | None |
365
+ XEP-0260 | None |
366
+ XEP-0261 | None |
367
+ XEP-0262 | None |
368
+ XEP-0263 | None |
369
+ XEP-0266 | None |
370
+ XEP-0267 | None |
371
+ XEP-0270 | None |
372
+ XEP-0273 | None |
373
+ XEP-0277 | None |
374
+ XEP-0278 | None |
375
+ XEP-0280 | None |
376
+ XEP-0288 | None |
377
+ XEP-0292 | None |
378
+ XEP-0293 | None |
379
+ XEP-0294 | None |
380
+ XEP-0295 | None |
381
+ XEP-0296 | None |
382
+ XEP-0297 | None |
383
+ XEP-0298 | None |
384
+ XEP-0299 | None |
385
+ XEP-0300 | None |
386
+ XEP-0301 | None |
387
+ XEP-0302 | None |
388
+ XEP-0303 | None |
389
+ XEP-0304 | None |
390
+ XEP-0305 | None |
391
+ XEP-0306 | None |
392
+ XEP-0307 | None |
393
+ XEP-0308 | None |
394
+ XEP-0309 | None |
395
+ XEP-0310 | None |
396
+ XEP-0311 | None |
397
+ XEP-0312 | None |
398
+
399
+
400
+ # Contributions
401
+
402
+ All contributions are welcome, even encouraged. However, contributions must be
403
+ well tested. If you send me a branch name to merge that'll get my attention faster
404
+ than a change set made directly on master.
405
+
406
+ # Author
407
+
408
+ * [Jeff Smick](http://github.com/sprsquish)
409
+ * [Other Contributors](https://github.com/adhearsion/blather/contributors)
410
+
411
+ # Copyright
412
+
413
+ Copyright (c) 2012 Adhearsion Foundation Inc. See LICENSE for details.