Skip to content

Commit

Permalink
Change DSL#write to DSL#write_to_stream so it doesn't mess with YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
sprsquish committed Oct 28, 2009
1 parent b1f2bd2 commit b4c77ec
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
v0.4.5
Bugfix: Change DSL#write to DSL#write_to_stream. Previous way was messing with YAML

v0.4.4
Add "disconnected" handler type to handle connection termination
Bugfix: Fix error with pubsub using the wrong client connection
Expand Down
4 changes: 2 additions & 2 deletions README.rdoc
Expand Up @@ -41,12 +41,12 @@ This will auto-accept any subscription requests and echo back any chat messages.

# Auto approve subscription requests
subscription :request? do |s|
write s.approve!
write_to_stream s.approve!
end

# Echo back what was said
message :chat?, :body do |m|
write m.reply
write_to_stream m.reply
end

== Handlers
Expand Down
2 changes: 1 addition & 1 deletion examples/echo.rb
Expand Up @@ -5,7 +5,7 @@
when_ready { puts "Connected ! send messages to #{jid.stripped}." }

subscription :request? do |s|
write s.approve!
write_to_stream s.approve!
end

message :chat?, :body => 'exit' do |m|
Expand Down
3 changes: 1 addition & 2 deletions lib/blather/client/client.rb
Expand Up @@ -167,8 +167,7 @@ def setup(jid, password, host = nil, port = nil) # :nodoc:

protected
def stream
raise 'Stream not ready!' unless @stream
@stream
@stream || raise('Stream not ready!')
end

def check_handler(type, guards)
Expand Down
6 changes: 3 additions & 3 deletions lib/blather/client/dsl.rb
Expand Up @@ -19,7 +19,7 @@ def pubsub
# This works such that it can be chained:
# self << stanza1 << stanza2 << "raw data"
def <<(stanza)
write stanza
client.write stanza
self
end

Expand Down Expand Up @@ -83,7 +83,7 @@ def my_roster
##
# Write data to the stream
# Anything that resonds to #to_s can be paseed to the stream
def write(stanza)
def write_to_stream(stanza)
client.write stanza
end

Expand Down Expand Up @@ -122,7 +122,7 @@ def discover(what, who, where, &callback)
stanza.node = where

client.register_tmp_handler stanza.id, &callback
write stanza
client.write stanza
end

##
Expand Down
2 changes: 1 addition & 1 deletion spec/blather/client/dsl_spec.rb
Expand Up @@ -89,7 +89,7 @@
it 'provides a writer' do
stanza = Blather::Stanza::Iq.new
@client.expects(:write).with stanza
@dsl.write stanza
@dsl.write_to_stream stanza
end

it 'provides a "say" helper' do
Expand Down

0 comments on commit b4c77ec

Please sign in to comment.