rets 0.1.2 → 0.1.3
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.md +4 -0
- data/lib/rets.rb +1 -1
- data/lib/rets/client.rb +2 -2
- data/lib/rets/parser/multipart.rb +1 -1
- data/test/fixtures.rb +43 -0
- data/test/test_client.rb +11 -0
- data/test/test_parser_multipart.rb +10 -0
- metadata +10 -25
data/CHANGELOG.md
CHANGED
data/lib/rets.rb
CHANGED
data/lib/rets/client.rb
CHANGED
|
@@ -157,7 +157,7 @@ module Rets
|
|
|
157
157
|
content_type = response["content-type"]
|
|
158
158
|
|
|
159
159
|
if content_type.include?("multipart")
|
|
160
|
-
boundary = content_type.scan(/boundary="(
|
|
160
|
+
boundary = content_type.scan(/boundary="?([^;"]*)?/).to_s
|
|
161
161
|
|
|
162
162
|
parts = Parser::Multipart.parse(response.body, boundary)
|
|
163
163
|
|
|
@@ -194,7 +194,7 @@ module Rets
|
|
|
194
194
|
"Resource" => opts[:resource],
|
|
195
195
|
"Type" => opts[:object_type],
|
|
196
196
|
"ID" => "#{opts[:resource_id]}:#{object_id}",
|
|
197
|
-
"Location" => 0
|
|
197
|
+
"Location" => opts[:location] || 0
|
|
198
198
|
)
|
|
199
199
|
|
|
200
200
|
headers = build_headers.merge(
|
|
@@ -20,7 +20,7 @@ module Rets
|
|
|
20
20
|
header_part, body_part = chunk.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
|
|
21
21
|
|
|
22
22
|
if header_part =~ HEADER_LINE
|
|
23
|
-
headers = header_part.split(/\r\n/).map { |kv|
|
|
23
|
+
headers = header_part.split(/\r\n/).map { |kv| p = kv.split(/:\s?/); [p[0].downcase, p[1..-1].join(':')] }
|
|
24
24
|
headers = Hash[*headers.flatten]
|
|
25
25
|
|
|
26
26
|
parts << Part.new(headers, body_part)
|
data/test/fixtures.rb
CHANGED
|
@@ -109,6 +109,49 @@ MULITPART_RESPONSE = [
|
|
|
109
109
|
""
|
|
110
110
|
].join("\r\n")
|
|
111
111
|
|
|
112
|
+
MULTIPART_RESPONSE_URLS = [
|
|
113
|
+
'--rets.object.content.boundary.1330546052739',
|
|
114
|
+
'Content-ID: 38845440',
|
|
115
|
+
'Object-ID: 1',
|
|
116
|
+
'Content-Type: text/xml',
|
|
117
|
+
'Location: http://foobarmls.com/RETS//MediaDisplay/98/hr2890998-1.jpg',
|
|
118
|
+
'',
|
|
119
|
+
'<RETS ReplyCode="0" ReplyText="Operation Successful" />',
|
|
120
|
+
'',
|
|
121
|
+
'--rets.object.content.boundary.1330546052739',
|
|
122
|
+
'Content-ID: 38845440',
|
|
123
|
+
'Object-ID: 2',
|
|
124
|
+
'Content-Type: text/xml',
|
|
125
|
+
'Location: http://foobarmls.com/RETS//MediaDisplay/98/hr2890998-2.jpg',
|
|
126
|
+
'',
|
|
127
|
+
'<RETS ReplyCode="0" ReplyText="Operation Successful" />',
|
|
128
|
+
'',
|
|
129
|
+
'--rets.object.content.boundary.1330546052739',
|
|
130
|
+
'Content-ID: 38845440',
|
|
131
|
+
'Object-ID: 3',
|
|
132
|
+
'Content-Type: text/xml',
|
|
133
|
+
'Location: http://foobarmls.com/RETS//MediaDisplay/98/hr2890998-3.jpg',
|
|
134
|
+
'',
|
|
135
|
+
'<RETS ReplyCode="0" ReplyText="Operation Successful" />',
|
|
136
|
+
'',
|
|
137
|
+
'--rets.object.content.boundary.1330546052739',
|
|
138
|
+
'Content-ID: 38845440',
|
|
139
|
+
'Object-ID: 4',
|
|
140
|
+
'Content-Type: text/xml',
|
|
141
|
+
'Location: http://foobarmls.com/RETS//MediaDisplay/98/hr2890998-4.jpg',
|
|
142
|
+
'',
|
|
143
|
+
'<RETS ReplyCode="0" ReplyText="Operation Successful" />',
|
|
144
|
+
'',
|
|
145
|
+
'--rets.object.content.boundary.1330546052739',
|
|
146
|
+
'Content-ID: 38845440',
|
|
147
|
+
'Object-ID: 5',
|
|
148
|
+
'Content-Type: text/xml',
|
|
149
|
+
'Location: http://foobarmls.com/RETS//MediaDisplay/98/hr2890998-5.jpg',
|
|
150
|
+
'',
|
|
151
|
+
'<RETS ReplyCode="0" ReplyText="Operation Successful" />',
|
|
152
|
+
'',
|
|
153
|
+
'--rets.object.content.boundary.1330546052739--'
|
|
154
|
+
].join("\r\n")
|
|
112
155
|
|
|
113
156
|
SAMPLE_COMPACT = <<XML
|
|
114
157
|
<RETS ReplyCode="0" ReplyText="Operation successful.">
|
data/test/test_client.rb
CHANGED
|
@@ -531,6 +531,17 @@ DIGEST
|
|
|
531
531
|
@client.create_parts_from_response(response)
|
|
532
532
|
end
|
|
533
533
|
|
|
534
|
+
def test_parse_boundary_wo_quotes
|
|
535
|
+
response = {"content-type" => 'multipart; boundary=simple boundary; foo;'}
|
|
536
|
+
response.stubs(:body => MULITPART_RESPONSE)
|
|
537
|
+
|
|
538
|
+
Rets::Parser::Multipart.expects(:parse).
|
|
539
|
+
with(MULITPART_RESPONSE, "simple boundary").
|
|
540
|
+
returns([])
|
|
541
|
+
|
|
542
|
+
@client.create_parts_from_response(response)
|
|
543
|
+
end
|
|
544
|
+
|
|
534
545
|
def test_create_parts_from_response_returns_a_single_part_when_not_multipart_response
|
|
535
546
|
response = {"content-type" => "text/plain"}
|
|
536
547
|
response.stubs(:body => "fakebody")
|
|
@@ -18,4 +18,14 @@ class TestParserMultipart < Test::Unit::TestCase
|
|
|
18
18
|
assert_equal headers.merge("object-id" => "2"), part.headers
|
|
19
19
|
assert_equal "yyyyyyyy", part.body.strip
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
def test_parse_real_mls_data
|
|
23
|
+
parts = Rets::Parser::Multipart.parse(MULTIPART_RESPONSE_URLS, "rets.object.content.boundary.1330546052739")
|
|
24
|
+
assert_equal 5, parts.size
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_parse_values_with_colon_data
|
|
28
|
+
parts = Rets::Parser::Multipart.parse(MULTIPART_RESPONSE_URLS, "rets.object.content.boundary.1330546052739")
|
|
29
|
+
assert_equal 'http://foobarmls.com/RETS//MediaDisplay/98/hr2890998-1.jpg', parts[0].headers['location']
|
|
30
|
+
end
|
|
21
31
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 29
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 0.1.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.1.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Estately, Inc. Open Source
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2012-
|
|
19
|
+
date: 2012-03-06 00:00:00 Z
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
22
22
|
name: net-http-persistent
|
|
@@ -65,36 +65,21 @@ dependencies:
|
|
|
65
65
|
version: 0.9.12
|
|
66
66
|
type: :development
|
|
67
67
|
version_requirements: *id003
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: rdoc
|
|
70
|
-
prerelease: false
|
|
71
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
|
72
|
-
none: false
|
|
73
|
-
requirements:
|
|
74
|
-
- - ~>
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
hash: 19
|
|
77
|
-
segments:
|
|
78
|
-
- 3
|
|
79
|
-
- 10
|
|
80
|
-
version: "3.10"
|
|
81
|
-
type: :development
|
|
82
|
-
version_requirements: *id004
|
|
83
68
|
- !ruby/object:Gem::Dependency
|
|
84
69
|
name: hoe
|
|
85
70
|
prerelease: false
|
|
86
|
-
requirement: &
|
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
87
72
|
none: false
|
|
88
73
|
requirements:
|
|
89
74
|
- - ~>
|
|
90
75
|
- !ruby/object:Gem::Version
|
|
91
|
-
hash:
|
|
76
|
+
hash: 27
|
|
92
77
|
segments:
|
|
93
78
|
- 2
|
|
94
|
-
-
|
|
95
|
-
version: "2.
|
|
79
|
+
- 12
|
|
80
|
+
version: "2.12"
|
|
96
81
|
type: :development
|
|
97
|
-
version_requirements: *
|
|
82
|
+
version_requirements: *id004
|
|
98
83
|
description: |-
|
|
99
84
|
A pure-ruby library for fetching data from [RETS] servers.
|
|
100
85
|
|
|
@@ -163,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
163
148
|
requirements: []
|
|
164
149
|
|
|
165
150
|
rubyforge_project: rets
|
|
166
|
-
rubygems_version: 1.8.
|
|
151
|
+
rubygems_version: 1.8.10
|
|
167
152
|
signing_key:
|
|
168
153
|
specification_version: 3
|
|
169
154
|
summary: A pure-ruby library for fetching data from [RETS] servers
|