blather 0.5.0 → 0.5.2

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/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ v0.5.2
2
+ Bugfix(benlangfeld): Remove specs for the Nokogiri extensions which were moved out
3
+
4
+ v0.5.1 - yanked
5
+ Feature(benlangfeld): Abstract out Nokogiri extensions and helpers into new Niceogiri gem for better sharing
6
+ Documentation(benlangfeld)
7
+
1
8
  v0.5.0
2
9
  Feature(radsaq): Add a #connected? method on Blather::Client
3
10
  Feature(benlangfeld)[API change]: Allow the removal of child nodes from an IQ reply
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Blather
2
2
 
3
- Copyright (c) 2009 Jeff Smick
3
+ Copyright (c) 2011 Jeff Smick
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -19,7 +19,7 @@ XMPP DSL (and more) for Ruby written on EventMachine and Nokogiri.
19
19
 
20
20
  ## Installation
21
21
 
22
- sudo gem install blather
22
+ gem install blather
23
23
 
24
24
  ## Example
25
25
 
@@ -173,4 +173,4 @@ than a change set made directly on master.
173
173
 
174
174
  # Copyright
175
175
 
176
- Copyright (c) 2009 Jeff Smick. See LICENSE for details.
176
+ Copyright (c) 2011 Jeff Smick. See LICENSE for details.
@@ -8,7 +8,6 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Jeff Smick"]
10
10
  s.email = %q{sprsquish@gmail.com}
11
- s.date = %q{2010-09-02}
12
11
  s.homepage = "http://github.com/sprsquish/blather"
13
12
  s.summary = %q{Simpler XMPP built for speed}
14
13
  s.description = %q{An XMPP DSL for Ruby written on top of EventMachine and Nokogiri}
@@ -23,6 +22,7 @@ Gem::Specification.new do |s|
23
22
 
24
23
  s.add_dependency("eventmachine", ["~> 0.12.6"])
25
24
  s.add_dependency("nokogiri", [">= 1.4.0"])
25
+ s.add_dependency("niceogiri", [">= 0.0.4"])
26
26
  s.add_dependency("minitest", [">= 1.7.1"])
27
27
  s.add_dependency("activesupport", [">= 3.0.7"])
28
28
 
@@ -2,7 +2,7 @@
2
2
  %w[
3
3
  rubygems
4
4
  eventmachine
5
- nokogiri
5
+ niceogiri
6
6
  ipaddr
7
7
  digest/md5
8
8
  digest/sha1
@@ -13,7 +13,6 @@
13
13
 
14
14
  blather/core_ext/eventmachine
15
15
  blather/core_ext/ipaddr
16
- blather/core_ext/nokogiri
17
16
 
18
17
  blather/errors
19
18
  blather/errors/sasl_error
@@ -1,4 +1,4 @@
1
1
  module Blather
2
2
  # Blather version number
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.2'
4
4
  end
@@ -2,15 +2,14 @@ module Blather
2
2
 
3
3
  # Base XML Node
4
4
  # All XML classes subclass XMPPNode it allows the addition of helpers
5
- class XMPPNode < Nokogiri::XML::Node
5
+ class XMPPNode < Niceogiri::XML::Node
6
6
  # @private
7
7
  BASE_NAMES = %w[presence message iq].freeze
8
8
 
9
9
  # @private
10
10
  @@registrations = {}
11
11
 
12
- class_inheritable_accessor :registered_ns,
13
- :registered_name
12
+ class_inheritable_accessor :registered_ns, :registered_name
14
13
 
15
14
  # Register a new stanza class to a name and/or namespace
16
15
  #
@@ -32,8 +31,7 @@ module Blather
32
31
  # @param [String, nil] xmlns the namespace the node belongs to
33
32
  # @return [Class, nil] the class appropriate for the name/ns combination
34
33
  def self.class_from_registration(name, ns = nil)
35
- name = name.to_s
36
- @@registrations[[name, ns]]
34
+ @@registrations[[name.to_s, ns]]
37
35
  end
38
36
 
39
37
  # Import an XML::Node to the appropriate class
@@ -58,43 +56,8 @@ module Blather
58
56
  # @param [XML::Document, nil] doc the document to attach the node to. If
59
57
  # not provided one will be created
60
58
  # @return a new object with the registered name and namespace
61
- def self.new(name = nil, doc = nil)
62
- name ||= self.registered_name
63
-
64
- node = super name.to_s, (doc || Nokogiri::XML::Document.new)
65
- node.document.root = node unless doc
66
- node.namespace = self.registered_ns unless BASE_NAMES.include?(name.to_s)
67
- node
68
- end
69
-
70
- # Helper method to read an attribute
71
- #
72
- # @param [#to_sym] attr_name the name of the attribute
73
- # @param [String, Symbol, nil] to_call the name of the method to call on
74
- # the returned value
75
- # @return nil or the value
76
- def read_attr(attr_name, to_call = nil)
77
- val = self[attr_name.to_sym]
78
- val && to_call ? val.__send__(to_call) : val
79
- end
80
-
81
- # Helper method to write a value to an attribute
82
- #
83
- # @param [#to_sym] attr_name the name of the attribute
84
- # @param [#to_s] value the value to set the attribute to
85
- def write_attr(attr_name, value)
86
- self[attr_name.to_sym] = value
87
- end
88
-
89
- # Helper method to read the content of a node
90
- #
91
- # @param [#to_sym] node the name of the node
92
- # @param [String, Symbol, nil] to_call the name of the method to call on
93
- # the returned value
94
- # @return nil or the value
95
- def read_content(node, to_call = nil)
96
- val = content_from node.to_sym
97
- val && to_call ? val.__send__(to_call) : val
59
+ def self.new(name = registered_name, doc = nil)
60
+ super name, doc, BASE_NAMES.include?(name.to_s) ? nil : self.registered_ns
98
61
  end
99
62
 
100
63
  # Turn the object into a proper stanza
@@ -103,133 +66,6 @@ module Blather
103
66
  def to_stanza
104
67
  self.class.import self
105
68
  end
106
-
107
- # @private
108
- alias_method :nokogiri_namespace=, :namespace=
109
- # Attach a namespace to the node
110
- #
111
- # @overload namespace=(ns)
112
- # Attach an already created XML::Namespace
113
- # @param [XML::Namespace] ns the namespace object
114
- # @overload namespace=(ns)
115
- # Create a new namespace and attach it
116
- # @param [String] ns the namespace uri
117
- # @overload namespace=(namespaces)
118
- # Createa and add new namespaces from a hash
119
- # @param [Hash] namespaces a hash of prefix => uri pairs
120
- def namespace=(namespaces)
121
- case namespaces
122
- when Nokogiri::XML::Namespace
123
- self.nokogiri_namespace = namespaces
124
- when String
125
- self.add_namespace nil, namespaces
126
- when Hash
127
- if ns = namespaces.delete(nil)
128
- self.add_namespace nil, ns
129
- end
130
- namespaces.each do |p, n|
131
- ns = self.add_namespace p, n
132
- self.nokogiri_namespace = ns
133
- end
134
- end
135
- end
136
-
137
- # Helper method to get the node's namespace
138
- #
139
- # @return [XML::Namespace, nil] The node's namespace object if it exists
140
- def namespace_href
141
- namespace.href if namespace
142
- end
143
-
144
- # Remove a child with the name and (optionally) namespace given
145
- #
146
- # @param [String] name the name or xpath of the node to remove
147
- # @param [String, nil] ns the namespace the node is in
148
- def remove_child(name, ns = nil)
149
- child = xpath(name, ns).first
150
- child.remove if child
151
- end
152
-
153
- # Remove all children with a given name regardless of namespace
154
- #
155
- # @param [String] name the name of the nodes to remove
156
- def remove_children(name)
157
- xpath("./*[local-name()='#{name}']").remove
158
- end
159
-
160
- # The content of the named node
161
- #
162
- # @param [String] name the name or xpath of the node
163
- # @param [String, nil] ns the namespace the node is in
164
- # @return [String, nil] the content of the node
165
- def content_from(name, ns = nil)
166
- child = xpath(name, ns).first
167
- child.content if child
168
- end
169
-
170
- # Sets the content for the specified node.
171
- # If the node exists it is updated. If not a new node is created
172
- # If the node exists and the content is nil, the node will be removed
173
- # entirely
174
- #
175
- # @param [String] node the name of the node to update/create
176
- # @param [String, nil] content the content to set within the node
177
- def set_content_for(node, content = nil)
178
- if content
179
- child = xpath(node).first
180
- self << (child = XMPPNode.new(node, self.document)) unless child
181
- child.content = content
182
- else
183
- remove_child node
184
- end
185
- end
186
-
187
- alias_method :copy, :dup
188
-
189
- # Inherit the attributes and children of an XML::Node
190
- #
191
- # @param [XML::Node] stanza the node to inherit
192
- # @return [self]
193
- def inherit(stanza)
194
- set_namespace stanza.namespace if stanza.namespace
195
- inherit_attrs stanza.attributes
196
- stanza.children.each do |c|
197
- self << (n = c.dup)
198
- ns = n.namespace_definitions.find { |ns| ns.prefix == c.namespace.prefix }
199
- n.namespace = ns if ns
200
- end
201
- self
202
- end
203
-
204
- # Inherit a set of attributes
205
- #
206
- # @param [Hash] attrs a hash of attributes to set on the node
207
- # @return [self]
208
- def inherit_attrs(attrs)
209
- attrs.each { |name, value| self[name] = value }
210
- self
211
- end
212
-
213
- # The node as XML
214
- #
215
- # @return [String] XML representation of the node
216
- def inspect
217
- self.to_xml
218
- end
219
-
220
- # Check that a set of fields are equal between nodes
221
- #
222
- # @param [XMPPNode] other the other node to compare against
223
- # @param [*#to_s] fields the set of fields to compare
224
- # @return [Fixnum<-1,0,1>]
225
- def eql?(o, *fields)
226
- o.is_a?(self.class) && fields.all? { |f| self.__send__(f) == o.__send__(f) }
227
- end
228
-
229
- # @private
230
- def ==(o)
231
- eql?(o)
232
- end
233
69
  end # XMPPNode
234
70
 
235
71
  end # Blather
@@ -3,28 +3,6 @@ require 'spec_helper'
3
3
  describe Blather::XMPPNode do
4
4
  before { @doc = Nokogiri::XML::Document.new }
5
5
 
6
- it 'generates a new node automatically setting the document' do
7
- n = Blather::XMPPNode.new 'foo'
8
- n.element_name.must_equal 'foo'
9
- n.document.wont_equal @doc
10
- end
11
-
12
- it 'sets the new document root to the node' do
13
- n = Blather::XMPPNode.new 'foo'
14
- n.document.root.must_equal n
15
- end
16
-
17
- it 'does not set the document root if the document is provided' do
18
- n = Blather::XMPPNode.new 'foo', @doc
19
- n.document.root.wont_equal n
20
- end
21
-
22
- it 'generates a new node with the given document' do
23
- n = Blather::XMPPNode.new 'foo', @doc
24
- n.element_name.must_equal 'foo'
25
- n.document.must_equal @doc
26
- end
27
-
28
6
  it 'generates a node based on the registered_name' do
29
7
  foo = Class.new(Blather::XMPPNode)
30
8
  foo.registered_name = 'foo'
@@ -51,182 +29,9 @@ describe Blather::XMPPNode do
51
29
  Blather::XMPPNode.import(n).must_be_kind_of ImportSubClass
52
30
  end
53
31
 
54
- it 'provides an attribute reader' do
55
- foo = Blather::XMPPNode.new
56
- foo.read_attr(:bar).must_be_nil
57
- foo[:bar] = 'baz'
58
- foo.read_attr(:bar).must_equal 'baz'
59
- end
60
-
61
- it 'provides an attribute reader with converstion' do
62
- foo = Blather::XMPPNode.new
63
- foo.read_attr(:bar, :to_sym).must_be_nil
64
- foo[:bar] = 'baz'
65
- foo.read_attr(:bar, :to_sym).must_equal :baz
66
- end
67
-
68
- it 'provides an attribute writer' do
69
- foo = Blather::XMPPNode.new
70
- foo[:bar].must_be_nil
71
- foo.write_attr(:bar, 'baz')
72
- foo[:bar].must_equal 'baz'
73
- end
74
-
75
- it 'provides a content reader' do
76
- foo = Blather::XMPPNode.new('foo')
77
- foo << (bar = Blather::XMPPNode.new('bar', foo.document))
78
- bar.content = 'baz'
79
- foo.read_content(:bar).must_equal 'baz'
80
- end
81
-
82
- it 'provides a content reader that converts the value' do
83
- foo = Blather::XMPPNode.new('foo')
84
- foo << (bar = Blather::XMPPNode.new('bar', foo.document))
85
- bar.content = 'baz'
86
- foo.read_content(:bar, :to_sym).must_equal :baz
87
- end
88
-
89
- it 'provides a content writer' do
90
- foo = Blather::XMPPNode.new('foo')
91
- foo.set_content_for :bar, 'baz'
92
- foo.content_from(:bar).must_equal 'baz'
93
- end
94
-
95
- it 'provides a content writer that removes a child when set to nil' do
96
- foo = Blather::XMPPNode.new('foo')
97
- foo << (bar = Blather::XMPPNode.new('bar', foo.document))
98
- bar.content = 'baz'
99
- foo.content_from(:bar).must_equal 'baz'
100
- foo.xpath('bar').wont_be_empty
101
-
102
- foo.set_content_for :bar, nil
103
- foo.content_from(:bar).must_be_nil
104
- foo.xpath('bar').must_be_empty
105
- end
106
-
107
32
  it 'can convert itself into a stanza' do
108
33
  class StanzaConvert < Blather::XMPPNode; register 'foo'; end
109
34
  n = Blather::XMPPNode.new('foo')
110
35
  n.to_stanza.must_be_kind_of StanzaConvert
111
36
  end
112
-
113
- it 'provides "attr_accessor" for namespace' do
114
- n = Blather::XMPPNode.new('foo')
115
- n.namespace.must_be_nil
116
-
117
- n.namespace = 'foo:bar'
118
- n.namespace_href.must_equal 'foo:bar'
119
- end
120
-
121
- it 'will remove a child element' do
122
- n = Blather::XMPPNode.new 'foo'
123
- n << Blather::XMPPNode.new('bar', n.document)
124
- n << Blather::XMPPNode.new('bar', n.document)
125
-
126
- n.find(:bar).size.must_equal 2
127
- n.remove_child 'bar'
128
- n.find(:bar).size.must_equal 1
129
- end
130
-
131
- it 'will remove a child with a specific xmlns' do
132
- n = Blather::XMPPNode.new 'foo'
133
- n << Blather::XMPPNode.new('bar')
134
- c = Blather::XMPPNode.new('bar')
135
- c.namespace = 'foo:bar'
136
- n << c
137
-
138
- n.find(:bar).size.must_equal 1
139
- n.find('//xmlns:bar', :xmlns => 'foo:bar').size.must_equal 1
140
- n.remove_child '//xmlns:bar', :xmlns => 'foo:bar'
141
- n.find(:bar).size.must_equal 1
142
- n.find('//xmlns:bar', :xmlns => 'foo:bar').size.must_equal 0
143
- end
144
-
145
- it 'will remove all child elements' do
146
- n = Blather::XMPPNode.new 'foo'
147
- n << Blather::XMPPNode.new('bar')
148
- n << Blather::XMPPNode.new('bar')
149
-
150
- n.find(:bar).size.must_equal 2
151
- n.remove_children 'bar'
152
- n.find(:bar).size.must_equal 0
153
- end
154
-
155
- it 'provides a copy mechanism' do
156
- n = Blather::XMPPNode.new 'foo'
157
- n2 = n.copy
158
- n2.object_id.wont_equal n.object_id
159
- n2.element_name.must_equal n.element_name
160
- end
161
-
162
- it 'provides an inherit mechanism' do
163
- n = Blather::XMPPNode.new 'foo'
164
- n2 = Blather::XMPPNode.new 'foo'
165
- n2.content = 'bar'
166
- n2['foo'] = 'bar'
167
-
168
- n.inherit(n2)
169
- n['foo'].must_equal 'bar'
170
- n.content.must_equal 'bar'
171
- n2.to_s.must_equal n.to_s
172
- end
173
-
174
- it 'holds on to namespaces when inheriting content' do
175
- n = parse_stanza('<message><bar:foo xmlns:bar="http://bar.com"></message>').root
176
- n2 = Blather::XMPPNode.new('message').inherit n
177
- n2.to_s.must_equal n.to_s
178
- end
179
-
180
- it 'provides a mechanism to inherit attrs' do
181
- n = Blather::XMPPNode.new 'foo'
182
- n2 = Blather::XMPPNode.new 'foo'
183
- n2['foo'] = 'bar'
184
-
185
- n.inherit_attrs(n2.attributes)
186
- n['foo'].must_equal 'bar'
187
- end
188
-
189
- it 'has a content_from helper that pulls the content from a child node' do
190
- f = Blather::XMPPNode.new('foo')
191
- f << (b = Blather::XMPPNode.new('bar'))
192
- b.content = 'content'
193
- f.content_from(:bar).must_equal 'content'
194
- end
195
-
196
- it 'returns nil when sent #content_from and a missing node' do
197
- f = Blather::XMPPNode.new('foo')
198
- f.content_from(:bar).must_be_nil
199
- end
200
-
201
- it 'creates a new node and sets content when sent #set_content_for' do
202
- f = Blather::XMPPNode.new('foo')
203
- f.must_respond_to :set_content_for
204
- f.xpath('bar').must_be_empty
205
- f.set_content_for :bar, :baz
206
- f.xpath('bar').wont_be_empty
207
- f.xpath('bar').first.content.must_equal 'baz'
208
- end
209
-
210
- it 'removes a child node when sent #set_content_for with nil' do
211
- f = Blather::XMPPNode.new('foo')
212
- f << (b = Blather::XMPPNode.new('bar'))
213
- f.must_respond_to :set_content_for
214
- f.xpath('bar').wont_be_empty
215
- f.set_content_for :bar, nil
216
- f.xpath('bar').must_be_empty
217
- end
218
-
219
- it 'will change the content of an existing node when sent #set_content_for' do
220
- f = Blather::XMPPNode.new('foo')
221
- f << (b = Blather::XMPPNode.new('bar'))
222
- b.content = 'baz'
223
- f.must_respond_to :set_content_for
224
- f.xpath('bar').wont_be_empty
225
- f.xpath('bar').first.content.must_equal 'baz'
226
- control = f.xpath('bar').first.pointer_id
227
-
228
- f.set_content_for :bar, 'fiz'
229
- f.xpath('bar').first.content.must_equal 'fiz'
230
- f.xpath('bar').first.pointer_id.must_equal control
231
- end
232
37
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blather
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 15
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 5
8
- - 0
9
- version: 0.5.0
9
+ - 2
10
+ version: 0.5.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jeff Smick
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-02 00:00:00 +01:00
18
+ date: 2011-06-09 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
29
+ hash: 35
28
30
  segments:
29
31
  - 0
30
32
  - 12
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 7
43
46
  segments:
44
47
  - 1
45
48
  - 4
@@ -48,138 +51,163 @@ dependencies:
48
51
  type: :runtime
49
52
  version_requirements: *id002
50
53
  - !ruby/object:Gem::Dependency
51
- name: minitest
54
+ name: niceogiri
52
55
  prerelease: false
53
56
  requirement: &id003 !ruby/object:Gem::Requirement
54
57
  none: false
55
58
  requirements:
56
59
  - - ">="
57
60
  - !ruby/object:Gem::Version
61
+ hash: 23
62
+ segments:
63
+ - 0
64
+ - 0
65
+ - 4
66
+ version: 0.0.4
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 9
58
78
  segments:
59
79
  - 1
60
80
  - 7
61
81
  - 1
62
82
  version: 1.7.1
63
83
  type: :runtime
64
- version_requirements: *id003
84
+ version_requirements: *id004
65
85
  - !ruby/object:Gem::Dependency
66
86
  name: activesupport
67
87
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
69
89
  none: false
70
90
  requirements:
71
91
  - - ">="
72
92
  - !ruby/object:Gem::Version
93
+ hash: 9
73
94
  segments:
74
95
  - 3
75
96
  - 0
76
97
  - 7
77
98
  version: 3.0.7
78
99
  type: :runtime
79
- version_requirements: *id004
100
+ version_requirements: *id005
80
101
  - !ruby/object:Gem::Dependency
81
102
  name: minitest
82
103
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
84
105
  none: false
85
106
  requirements:
86
107
  - - ~>
87
108
  - !ruby/object:Gem::Version
109
+ hash: 9
88
110
  segments:
89
111
  - 1
90
112
  - 7
91
113
  - 1
92
114
  version: 1.7.1
93
115
  type: :development
94
- version_requirements: *id005
116
+ version_requirements: *id006
95
117
  - !ruby/object:Gem::Dependency
96
118
  name: mocha
97
119
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
120
+ requirement: &id007 !ruby/object:Gem::Requirement
99
121
  none: false
100
122
  requirements:
101
123
  - - ~>
102
124
  - !ruby/object:Gem::Version
125
+ hash: 35
103
126
  segments:
104
127
  - 0
105
128
  - 9
106
129
  - 12
107
130
  version: 0.9.12
108
131
  type: :development
109
- version_requirements: *id006
132
+ version_requirements: *id007
110
133
  - !ruby/object:Gem::Dependency
111
134
  name: bundler
112
135
  prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
136
+ requirement: &id008 !ruby/object:Gem::Requirement
114
137
  none: false
115
138
  requirements:
116
139
  - - ~>
117
140
  - !ruby/object:Gem::Version
141
+ hash: 23
118
142
  segments:
119
143
  - 1
120
144
  - 0
121
145
  - 0
122
146
  version: 1.0.0
123
147
  type: :development
124
- version_requirements: *id007
148
+ version_requirements: *id008
125
149
  - !ruby/object:Gem::Dependency
126
150
  name: rcov
127
151
  prerelease: false
128
- requirement: &id008 !ruby/object:Gem::Requirement
152
+ requirement: &id009 !ruby/object:Gem::Requirement
129
153
  none: false
130
154
  requirements:
131
155
  - - ~>
132
156
  - !ruby/object:Gem::Version
157
+ hash: 41
133
158
  segments:
134
159
  - 0
135
160
  - 9
136
161
  - 9
137
162
  version: 0.9.9
138
163
  type: :development
139
- version_requirements: *id008
164
+ version_requirements: *id009
140
165
  - !ruby/object:Gem::Dependency
141
166
  name: yard
142
167
  prerelease: false
143
- requirement: &id009 !ruby/object:Gem::Requirement
168
+ requirement: &id010 !ruby/object:Gem::Requirement
144
169
  none: false
145
170
  requirements:
146
171
  - - ~>
147
172
  - !ruby/object:Gem::Version
173
+ hash: 5
148
174
  segments:
149
175
  - 0
150
176
  - 6
151
177
  - 1
152
178
  version: 0.6.1
153
179
  type: :development
154
- version_requirements: *id009
180
+ version_requirements: *id010
155
181
  - !ruby/object:Gem::Dependency
156
182
  name: bluecloth
157
183
  prerelease: false
158
- requirement: &id010 !ruby/object:Gem::Requirement
184
+ requirement: &id011 !ruby/object:Gem::Requirement
159
185
  none: false
160
186
  requirements:
161
187
  - - ~>
162
188
  - !ruby/object:Gem::Version
189
+ hash: 11
163
190
  segments:
164
191
  - 2
165
192
  - 1
166
193
  - 0
167
194
  version: 2.1.0
168
195
  type: :development
169
- version_requirements: *id010
196
+ version_requirements: *id011
170
197
  - !ruby/object:Gem::Dependency
171
198
  name: rake
172
199
  prerelease: false
173
- requirement: &id011 !ruby/object:Gem::Requirement
200
+ requirement: &id012 !ruby/object:Gem::Requirement
174
201
  none: false
175
202
  requirements:
176
203
  - - ">="
177
204
  - !ruby/object:Gem::Version
205
+ hash: 3
178
206
  segments:
179
207
  - 0
180
208
  version: "0"
181
209
  type: :development
182
- version_requirements: *id011
210
+ version_requirements: *id012
183
211
  description: An XMPP DSL for Ruby written on top of EventMachine and Nokogiri
184
212
  email: sprsquish@gmail.com
185
213
  executables: []
@@ -215,7 +243,6 @@ files:
215
243
  - lib/blather/client/dsl/pubsub.rb
216
244
  - lib/blather/core_ext/eventmachine.rb
217
245
  - lib/blather/core_ext/ipaddr.rb
218
- - lib/blather/core_ext/nokogiri.rb
219
246
  - lib/blather/errors.rb
220
247
  - lib/blather/errors/sasl_error.rb
221
248
  - lib/blather/errors/stanza_error.rb
@@ -274,7 +301,6 @@ files:
274
301
  - spec/blather/client/client_spec.rb
275
302
  - spec/blather/client/dsl/pubsub_spec.rb
276
303
  - spec/blather/client/dsl_spec.rb
277
- - spec/blather/core_ext/nokogiri_spec.rb
278
304
  - spec/blather/errors/sasl_error_spec.rb
279
305
  - spec/blather/errors/stanza_error_spec.rb
280
306
  - spec/blather/errors/stream_error_spec.rb
@@ -337,6 +363,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
363
  requirements:
338
364
  - - ">="
339
365
  - !ruby/object:Gem::Version
366
+ hash: 3
340
367
  segments:
341
368
  - 0
342
369
  version: "0"
@@ -345,13 +372,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
372
  requirements:
346
373
  - - ">="
347
374
  - !ruby/object:Gem::Version
375
+ hash: 3
348
376
  segments:
349
377
  - 0
350
378
  version: "0"
351
379
  requirements: []
352
380
 
353
381
  rubyforge_project:
354
- rubygems_version: 1.3.7
382
+ rubygems_version: 1.4.2
355
383
  signing_key:
356
384
  specification_version: 3
357
385
  summary: Simpler XMPP built for speed
@@ -359,7 +387,6 @@ test_files:
359
387
  - spec/blather/client/client_spec.rb
360
388
  - spec/blather/client/dsl/pubsub_spec.rb
361
389
  - spec/blather/client/dsl_spec.rb
362
- - spec/blather/core_ext/nokogiri_spec.rb
363
390
  - spec/blather/errors/sasl_error_spec.rb
364
391
  - spec/blather/errors/stanza_error_spec.rb
365
392
  - spec/blather/errors/stream_error_spec.rb
@@ -1,44 +0,0 @@
1
- # @private
2
- module Nokogiri
3
- module XML
4
-
5
- # Nokogiri::Node extensions
6
- class Node
7
- # Alias #name to #element_name so we can use #name in an XMPP Stanza context
8
- alias_method :element_name, :name
9
- alias_method :element_name=, :name=
10
-
11
- alias_method :attr_set, :[]=
12
- # Override Nokogiri's attribute setter to add the ability to kill an attribute
13
- # by setting it to nil and to be able to lookup an attribute by symbol
14
- #
15
- # @param [#to_s] name the name of the attribute
16
- # @param [#to_s, nil] value the new value or nil to remove it
17
- def []=(name, value)
18
- name = name.to_s
19
- value.nil? ? remove_attribute(name) : attr_set(name, value.to_s)
20
- end
21
-
22
- alias_method :nokogiri_xpath, :xpath
23
- # Override Nokogiri's #xpath method to add the ability to use symbols for lookup
24
- # and namespace designation
25
- def xpath(*paths)
26
- paths[0] = paths[0].to_s
27
-
28
- if paths.size > 1 && (namespaces = paths.pop).is_a?(Hash)
29
- paths << namespaces.inject({}) { |h,v| h[v[0].to_s] = v[1]; h }
30
- end
31
-
32
- nokogiri_xpath *paths
33
- end
34
- alias_method :find, :xpath
35
-
36
- # Return the first element at a specified xpath
37
- # @see #xpath
38
- def find_first(*paths)
39
- xpath(*paths).first
40
- end
41
- end
42
-
43
- end #XML
44
- end #Blather
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Nokogiri::XML::Node' do
4
- before { @doc = Nokogiri::XML::Document.new }
5
-
6
- it 'aliases #name to #element_name' do
7
- node = Nokogiri::XML::Node.new 'foo', @doc
8
- node.must_respond_to :element_name
9
- node.element_name.must_equal node.name
10
- end
11
-
12
- it 'aliases #name= to #element_name=' do
13
- node = Nokogiri::XML::Node.new 'foo', @doc
14
- node.must_respond_to :element_name=
15
- node.element_name.must_equal node.name
16
- node.element_name = 'bar'
17
- node.element_name.must_equal 'bar'
18
- end
19
-
20
- it 'allows symbols as hash keys for attributes' do
21
- attrs = Nokogiri::XML::Node.new('foo', @doc)
22
- attrs['foo'] = 'bar'
23
-
24
- attrs['foo'].must_equal 'bar'
25
- attrs[:foo].must_equal 'bar'
26
- end
27
-
28
- it 'ensures a string is passed to the attribute setter' do
29
- attrs = Nokogiri::XML::Node.new('foo', @doc)
30
- attrs[:foo] = 1
31
- attrs[:foo].must_equal '1'
32
-
33
- attrs[:jid] = Blather::JID.new('n@d/r')
34
- attrs[:jid].must_equal 'n@d/r'
35
- end
36
-
37
- it 'removes an attribute when set to nil' do
38
- attrs = Nokogiri::XML::Node.new('foo', @doc)
39
- attrs['foo'] = 'bar'
40
-
41
- attrs['foo'].must_equal 'bar'
42
- attrs['foo'] = nil
43
- attrs['foo'].must_be_nil
44
- end
45
-
46
- it 'allows attribute values to change' do
47
- attrs = Nokogiri::XML::Node.new('foo', @doc)
48
- attrs['foo'] = 'bar'
49
-
50
- attrs['foo'].must_equal 'bar'
51
- attrs['foo'] = 'baz'
52
- attrs['foo'].must_equal 'baz'
53
- end
54
-
55
- it 'allows symbols as the path in #xpath' do
56
- node = Nokogiri::XML::Node.new('foo', @doc)
57
- node.must_respond_to :find
58
- @doc.root = node
59
- @doc.xpath(:foo).first.wont_be_nil
60
- @doc.xpath(:foo).first.must_equal @doc.xpath('/foo').first
61
- end
62
-
63
- it 'allows symbols as namespace names in #xpath' do
64
- node = Nokogiri::XML::Node.new('foo', @doc)
65
- node.namespace = node.add_namespace('bar', 'baz')
66
- @doc.root = node
67
- node.xpath('/bar:foo', :bar => 'baz').first.wont_be_nil
68
- end
69
-
70
- it 'aliases #xpath to #find' do
71
- node = Nokogiri::XML::Node.new('foo', @doc)
72
- node.must_respond_to :find
73
- @doc.root = node
74
- node.find('/foo').first.wont_be_nil
75
- end
76
-
77
- it 'has a helper function #find_first' do
78
- node = Nokogiri::XML::Node.new('foo', @doc)
79
- node.must_respond_to :find
80
- @doc.root = node
81
- node.find_first('/foo').must_equal node.find('/foo').first
82
- end
83
- end