rets4r 0.8.4 → 0.8.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/CHANGELOG CHANGED
@@ -1,6 +1,13 @@
1
+ 0.8.5
2
+ Parser#parse_compact_line now once again ignores beginning and ending delimiters. (Scott Patterson)
3
+ Parser#parse_data now ignores header fields that are nil or blank when stripped. (Scott Patterson)
4
+ Updated test to use the rets client version of the client, not hardcoded for post and get tests. (Scott Patterson)
5
+
1
6
  0.8.4
2
7
  Fixed auth issue with authenticate headers with spaces after commas. (Ken Wiesner, Scott Patterson)
3
- When an exception is raised in the authentication parsing code, complain by raising a new exception, but also report anything of interest at the same time: request, response, response's body. (Fran�ois Beausoleil)
8
+ When an exception is raised in the authentication parsing code, complain by raising
9
+ a new exception, but also report anything of interest at the same time: request,
10
+ response, response's body. (Fran�ois Beausoleil)
4
11
  Fixed Client#request to actually respect the specified request method instead of always using GET requests. (Scott Patterson)
5
12
  Set default request method to POST since some RETS servers seem to have trouble with GET requests. (Scott Patterson)
6
13
 
@@ -32,7 +32,7 @@ module RETS4R
32
32
  DEFAULT_OUTPUT = OUTPUT_RUBY
33
33
  DEFAULT_METHOD = METHOD_POST
34
34
  DEFAULT_RETRY = 2
35
- DEFAULT_USER_AGENT = 'RETS4R/0.8.4'
35
+ DEFAULT_USER_AGENT = 'RETS4R/0.8.5'
36
36
  DEFAULT_RETS_VERSION = '1.7'
37
37
  SUPPORTED_RETS_VERSIONS = ['1.5', '1.7']
38
38
  CAPABILITY_LIST = ['Action', 'ChangePassword', 'GetObject', 'Login', 'LoginComplete', 'Logout', 'Search', 'GetMetadata', 'Update']
@@ -102,7 +102,9 @@ module RETS4R
102
102
 
103
103
  def parse_compact_line(data, delim = "\t")
104
104
  begin
105
- return data.to_s.split(delim)
105
+ # We need to remove the beginning and ending delimiters prior to splitting
106
+ string_data = data.to_s
107
+ return string_data[1, string_data.length - 2].split(delim, -1)
106
108
  rescue
107
109
  raise "Error while parsing compact line: #{$!} with data: #{data}"
108
110
  end
@@ -114,7 +116,11 @@ module RETS4R
114
116
  parsed_data = parse_compact_line(data, @transaction.ascii_delimiter)
115
117
 
116
118
  header.length.times do |pos|
117
- results[header[pos]] = parsed_data[pos]
119
+ # The removal of delimiters in #parse_compact_line prevents blank fields in newer
120
+ # version of Ruby, but on older versions (specifically 1.8.5 from 2006) a blank
121
+ # field would still manage to sneak in, so we now explicitly prevent them from going
122
+ # to the results.
123
+ results[header[pos]] = parsed_data[pos] unless header[pos].nil? || header[pos].strip == ""
118
124
  end
119
125
 
120
126
  results
@@ -290,7 +290,7 @@ module RETS4R
290
290
  response.stubs(:code).returns('500')
291
291
  response.stubs(:message).returns('Move along, nothing to see here.')
292
292
 
293
- http.expects(:get).with('', {'RETS-Session-ID' => '0', 'User-Agent' => 'RETS4R/0.8.2', 'RETS-Version' => 'RETS/1.7', 'Accept' => '*/*'}).at_least_once.returns(response)
293
+ http.expects(:get).with('', {'RETS-Session-ID' => '0', 'User-Agent' => @rets.user_agent, 'RETS-Version' => "RETS/#{@rets.rets_version}", 'Accept' => '*/*'}).at_least_once.returns(response)
294
294
  http.expects(:post).never
295
295
  Net::HTTP.any_instance.expects(:start).at_least_once.yields(http)
296
296
 
@@ -307,7 +307,7 @@ module RETS4R
307
307
  response.stubs(:code).returns('500')
308
308
  response.stubs(:message).returns('Move along, nothing to see here.')
309
309
 
310
- http.expects(:post).with('', '', {'RETS-Session-ID' => '0', 'User-Agent' => 'RETS4R/0.8.2', 'RETS-Version' => 'RETS/1.7', 'Accept' => '*/*'}).at_least_once.returns(response)
310
+ http.expects(:post).with('', '', {'RETS-Session-ID' => '0', 'User-Agent' => @rets.user_agent, 'RETS-Version' => "RETS/#{@rets.rets_version}", 'Accept' => '*/*'}).at_least_once.returns(response)
311
311
  http.expects(:get).never
312
312
  Net::HTTP.any_instance.expects(:start).at_least_once.yields(http)
313
313
 
@@ -104,6 +104,25 @@ module RETS4R
104
104
  assert_equal('20400', transaction.reply_code)
105
105
  assert_equal('Invalid Invalidness.', transaction.reply_text)
106
106
  end
107
+
108
+ def test_parse_compact_line
109
+ results = @parser.parse_compact_line(" 1 2 3 ")
110
+
111
+ assert_equal 3, results.size
112
+ assert_equal '1', results[0]
113
+ assert_equal '2', results[1]
114
+ assert_equal '3', results[2]
115
+ end
116
+
117
+ def test_parse_data_should_ignore_empty_header_fields
118
+ header = ["", "1", "2", "3"]
119
+ data = " 1 2 3 "
120
+
121
+ results = @parser.parse_data(data, header)
122
+
123
+ assert_nil results[""]
124
+ assert_equal 3, results.size
125
+ end
107
126
  end
108
127
  end
109
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rets4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Patterson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-05 00:00:00 -08:00
12
+ date: 2008-11-06 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15