partigi-partigirb 0.2.4 → 0.2.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/README.rdoc +2 -2
- data/VERSION +1 -1
- data/lib/partigirb/handlers/xml_handler.rb +16 -3
- data/partigirb.gemspec +2 -2
- data/test/xml_handler_test.rb +16 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -49,7 +49,7 @@ For POST requests just change <tt>?</tt> by <tt>!</tt>:
|
|
49
49
|
=== Parameter handling
|
50
50
|
|
51
51
|
- All parameters are URL encoded as necessary.
|
52
|
-
- If you use a File object as a parameter it will be POSTed to
|
52
|
+
- If you use a File object as a parameter it will be POSTed to Partigi in a multipart request.
|
53
53
|
- If you use a Time object as a parameter, .httpdate will be called on it and that value will be used
|
54
54
|
|
55
55
|
=== Return values
|
@@ -62,7 +62,7 @@ When using Atom format Partigi returns some XML elements using namespaces. In th
|
|
62
62
|
|
63
63
|
=== Error handling
|
64
64
|
|
65
|
-
In case Partigi returns an error response, this is turned into a PartigiError object
|
65
|
+
In case Partigi returns an error response, this is turned into a PartigiError object with message attribute set to the error string returned in the XML response.
|
66
66
|
|
67
67
|
== Requirements
|
68
68
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
@@ -11,7 +11,7 @@ module Partigirb
|
|
11
11
|
def load_recursive(node)
|
12
12
|
if array_node?(node)
|
13
13
|
node.elements.map {|e| load_recursive(e)}
|
14
|
-
elsif node.elements.size > 0 || node.attributes.size > 0
|
14
|
+
elsif (node.elements.size > 0 || node.attributes.size > 0) && !ignore_attributes?(node)
|
15
15
|
build_struct(node)
|
16
16
|
else
|
17
17
|
value = node.text
|
@@ -37,8 +37,7 @@ module Partigirb
|
|
37
37
|
node.elements.each do |e|
|
38
38
|
property = ""
|
39
39
|
|
40
|
-
if
|
41
|
-
ns = e.namespaces.invert[e.namespace]
|
40
|
+
if ns = node_namespace(e)
|
42
41
|
property << "#{ns}_" unless ns == 'xmlns'
|
43
42
|
end
|
44
43
|
|
@@ -64,6 +63,20 @@ module Partigirb
|
|
64
63
|
def fixnum?(value)
|
65
64
|
value =~ /^\d+$/
|
66
65
|
end
|
66
|
+
|
67
|
+
def node_namespace(node)
|
68
|
+
node.namespace.blank? ? nil : node.namespaces.invert[node.namespace]
|
69
|
+
end
|
70
|
+
|
71
|
+
def ignore_attributes?(node)
|
72
|
+
element_name = node.name
|
73
|
+
ns = node_namespace(node)
|
74
|
+
element_name.insert(0, "#{ns}:") if ns
|
75
|
+
|
76
|
+
IGNORE_ATTRIBUTES_FOR.include?(element_name)
|
77
|
+
end
|
78
|
+
|
79
|
+
IGNORE_ATTRIBUTES_FOR = ['ptItem:synopsis', 'ptItem:title']
|
67
80
|
end
|
68
81
|
end
|
69
82
|
end
|
data/partigirb.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{partigirb}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Alvaro Bautista", "Fernando Blat"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-08-03}
|
10
10
|
s.email = ["alvarobp@gmail.com", "ferblape@gmail.com"]
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
data/test/xml_handler_test.rb
CHANGED
@@ -101,4 +101,20 @@ class XMLHandlerTest < Test::Unit::TestCase
|
|
101
101
|
assert_equal 'alternate', res.links.first.rel
|
102
102
|
assert_equal 'self', res.links[1].rel
|
103
103
|
end
|
104
|
+
|
105
|
+
should "extract values and ignore attributes for elements in IGNORE_ATTRIBUTES_FOR" do
|
106
|
+
xmls = build_xml_string do |xml|
|
107
|
+
xml.instruct!
|
108
|
+
xml.entry({"xmlns:ptItem" => 'http://schemas.overtheworld.com/v200/ptItem'}) do
|
109
|
+
xml.id 123
|
110
|
+
xml.ptItem :synopsis, {:lang => 'en', :type => 'text'}, 'In my opinion...'
|
111
|
+
xml.ptItem :title, {:lang => 'en'}, 'Wadus Movie'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
res = @handler.decode_response(xmls)
|
116
|
+
assert res.is_a?(Partigirb::PartigiStruct)
|
117
|
+
assert_equal 'In my opinion...', res.ptItem_synopsis
|
118
|
+
assert_equal 'Wadus Movie', res.ptItem_title
|
119
|
+
end
|
104
120
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partigi-partigirb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alvaro Bautista
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-08-03 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|