blather 0.4.15 → 0.4.16

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.
Files changed (75) hide show
  1. data/.autotest +13 -0
  2. data/.gitignore +18 -0
  3. data/CHANGELOG +150 -0
  4. data/Gemfile +4 -0
  5. data/Rakefile +32 -0
  6. data/TODO.md +2 -0
  7. data/blather.gemspec +49 -0
  8. data/lib/blather.rb +3 -0
  9. data/lib/blather/client/client.rb +139 -1
  10. data/lib/blather/client/dsl.rb +16 -0
  11. data/lib/blather/core_ext/active_support.rb +1 -1
  12. data/lib/blather/core_ext/ipaddr.rb +19 -0
  13. data/lib/blather/file_transfer/s5b.rb +8 -0
  14. data/lib/blather/roster_item.rb +5 -2
  15. data/lib/blather/stanza/disco.rb +7 -0
  16. data/lib/blather/stanza/disco/disco_info.rb +13 -19
  17. data/lib/blather/stanza/disco/disco_items.rb +5 -11
  18. data/lib/blather/stanza/presence.rb +15 -5
  19. data/lib/blather/stanza/presence/c.rb +103 -0
  20. data/lib/blather/stanza/x.rb +2 -4
  21. data/lib/blather/version.rb +3 -0
  22. data/lib/blather/xmpp_node.rb +8 -0
  23. data/spec/blather/client/client_spec.rb +87 -1
  24. data/spec/blather/client/dsl/pubsub_spec.rb +2 -2
  25. data/spec/blather/client/dsl_spec.rb +85 -5
  26. data/spec/blather/core_ext/nokogiri_spec.rb +1 -1
  27. data/spec/blather/errors/sasl_error_spec.rb +1 -1
  28. data/spec/blather/errors/stanza_error_spec.rb +2 -2
  29. data/spec/blather/errors/stream_error_spec.rb +2 -2
  30. data/spec/blather/errors_spec.rb +1 -1
  31. data/spec/blather/file_transfer_spec.rb +2 -2
  32. data/spec/blather/jid_spec.rb +1 -1
  33. data/spec/blather/roster_item_spec.rb +1 -1
  34. data/spec/blather/roster_spec.rb +1 -1
  35. data/spec/blather/stanza/discos/disco_info_spec.rb +1 -11
  36. data/spec/blather/stanza/discos/disco_items_spec.rb +1 -6
  37. data/spec/blather/stanza/iq/command_spec.rb +3 -3
  38. data/spec/blather/stanza/iq/ibb_spec.rb +2 -2
  39. data/spec/blather/stanza/iq/query_spec.rb +1 -1
  40. data/spec/blather/stanza/iq/roster_spec.rb +1 -1
  41. data/spec/blather/stanza/iq/s5b_spec.rb +2 -2
  42. data/spec/blather/stanza/iq/si_spec.rb +2 -2
  43. data/spec/blather/stanza/iq/vcard_spec.rb +3 -3
  44. data/spec/blather/stanza/iq_spec.rb +1 -1
  45. data/spec/blather/stanza/message_spec.rb +2 -2
  46. data/spec/blather/stanza/presence/c_spec.rb +46 -0
  47. data/spec/blather/stanza/presence/status_spec.rb +1 -1
  48. data/spec/blather/stanza/presence/subscription_spec.rb +1 -1
  49. data/spec/blather/stanza/presence_spec.rb +1 -1
  50. data/spec/blather/stanza/pubsub/affiliations_spec.rb +2 -2
  51. data/spec/blather/stanza/pubsub/create_spec.rb +3 -3
  52. data/spec/blather/stanza/pubsub/event_spec.rb +2 -2
  53. data/spec/blather/stanza/pubsub/items_spec.rb +2 -2
  54. data/spec/blather/stanza/pubsub/publish_spec.rb +2 -2
  55. data/spec/blather/stanza/pubsub/retract_spec.rb +2 -2
  56. data/spec/blather/stanza/pubsub/subscribe_spec.rb +2 -2
  57. data/spec/blather/stanza/pubsub/subscription_spec.rb +3 -3
  58. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +2 -2
  59. data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +2 -2
  60. data/spec/blather/stanza/pubsub_owner/delete_spec.rb +2 -2
  61. data/spec/blather/stanza/pubsub_owner/purge_spec.rb +3 -3
  62. data/spec/blather/stanza/pubsub_owner_spec.rb +2 -2
  63. data/spec/blather/stanza/pubsub_spec.rb +2 -8
  64. data/spec/blather/stanza/x_spec.rb +1 -6
  65. data/spec/blather/stanza_spec.rb +1 -1
  66. data/spec/blather/stream/client_spec.rb +3 -3
  67. data/spec/blather/stream/component_spec.rb +1 -1
  68. data/spec/blather/stream/parser_spec.rb +1 -1
  69. data/spec/blather/xmpp_node_spec.rb +1 -1
  70. data/spec/spec_helper.rb +5 -12
  71. data/yard/templates/default/class/html/handlers.erb +18 -0
  72. data/yard/templates/default/class/setup.rb +10 -0
  73. data/yard/templates/default/class/text/handlers.erb +1 -0
  74. metadata +123 -13
  75. data/lib/test.rb +0 -55
data/lib/test.rb DELETED
@@ -1,55 +0,0 @@
1
- require "blather/client/client"
2
- require "openssl"
3
- require "em-http"
4
- require "cgi"
5
-
6
- module S3FileReceiver
7
- def initialize(iq)
8
- p "initialize"
9
- @filename = iq.si.file["name"]
10
- @size = iq.si.file["size"].to_i
11
- end
12
-
13
- def post_init
14
- p "post_init"
15
- time = Time.now.httpdate
16
- sign = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), "qHG5ywFiZR2EK7oUvLVLhGHr2Rp05ggriTdExw0I", "PUT\n\n\n#{time}\n/jaconda-dev/#{CGI::escape(@filename)}")).strip
17
- @s3 = EM::HttpRequest.new("https://jaconda-dev.s3.amazonaws.com:443/#{CGI::escape(@filename)}").put({:timeout => 10, :head => {'date' => time, 'url' => "/jaconda-dev/#{CGI::escape(@filename)}", 'Content-Length' => @size, "Authorization" => "AWS AKIAIVULGEHUOR7PIR4Q:#{sign}"}})
18
- @s3.errback do |e|
19
- p "error: #{e.response_header.inspect}"
20
- end
21
- @s3.callback do |s|
22
- p "success: #{s.response.inspect}"
23
- end
24
- EM::enable_proxy(self, @s3)
25
- end
26
-
27
- def proxy_target_unbound
28
- close_connection_after_writing
29
- end
30
- end
31
-
32
- EM.run do
33
- Blather.logger = Logger.new("/Users/antonmironov/Desktop/blather.log")
34
- Blather.logger.level = Logger::DEBUG
35
-
36
- im = Blather::Client.setup "ant.mironov@jabber.ru/test", "zzzxxx"
37
-
38
- im.register_handler :disco_info, :type => :get do |iq|
39
- answer = iq.reply
40
- answer.identities = [{:type => 'pc', :category => 'client'}]
41
- answer.features = ["http://jabber.org/protocol/si/profile/file-transfer", "http://jabber.org/protocol/si", "http://jabber.org/protocol/bytestreams", "http://jabber.org/protocol/ibb"]
42
-
43
- im.write answer
44
- end
45
-
46
- im.register_handler :file_transfer do |iq|
47
- transfer = Blather::FileTransfer.new(im, iq)
48
- # transfer.allow_bytestreams = false
49
-
50
- transfer.accept(S3FileReceiver, iq)
51
-
52
- true
53
- end
54
- im.connect
55
- end