rets4r 0.8.5 → 1.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.document +5 -0
  2. data/{test/client/data/1.5/metadata.xml → .gemtest} +0 -0
  3. data/CHANGELOG +611 -66
  4. data/CONTRIBUTORS +6 -2
  5. data/Gemfile +1 -0
  6. data/LICENSE +22 -0
  7. data/MANIFEST +63 -0
  8. data/NEWS +203 -0
  9. data/{README → README.rdoc} +11 -4
  10. data/RUBYS +7 -7
  11. data/Rakefile +48 -0
  12. data/TODO +5 -1
  13. data/examples/client_get_object.rb +31 -42
  14. data/examples/client_login.rb +20 -18
  15. data/examples/client_mapper.rb +17 -0
  16. data/examples/client_metadata.rb +28 -28
  17. data/examples/client_parser.rb +9 -0
  18. data/examples/client_search.rb +25 -27
  19. data/examples/settings.yml +114 -0
  20. data/lib/rets4r.rb +14 -1
  21. data/lib/rets4r/auth.rb +70 -66
  22. data/lib/rets4r/client.rb +470 -650
  23. data/lib/rets4r/client/data.rb +13 -13
  24. data/lib/rets4r/client/dataobject.rb +27 -19
  25. data/lib/rets4r/client/exceptions.rb +116 -0
  26. data/lib/rets4r/client/links.rb +32 -0
  27. data/lib/rets4r/client/metadata.rb +12 -12
  28. data/lib/rets4r/client/parsers/compact.rb +42 -0
  29. data/lib/rets4r/client/parsers/compact_nokogiri.rb +91 -0
  30. data/lib/rets4r/client/parsers/metadata.rb +92 -0
  31. data/lib/rets4r/client/parsers/response_parser.rb +100 -0
  32. data/lib/rets4r/client/requester.rb +143 -0
  33. data/lib/rets4r/client/transaction.rb +30 -33
  34. data/lib/rets4r/core_ext/array/extract_options.rb +15 -0
  35. data/lib/rets4r/core_ext/class/attribute_accessors.rb +58 -0
  36. data/lib/rets4r/core_ext/hash/keys.rb +46 -0
  37. data/lib/rets4r/core_ext/hash/slice.rb +39 -0
  38. data/lib/rets4r/listing_mapper.rb +17 -0
  39. data/lib/rets4r/listing_service.rb +35 -0
  40. data/lib/rets4r/loader.rb +8 -0
  41. data/lib/tasks/annotations.rake +121 -0
  42. data/lib/tasks/coverage.rake +13 -0
  43. data/rets4r.gemspec +24 -0
  44. data/spec/rets4r_compact_data_parser_spec.rb +7 -0
  45. data/test/data/1.5/bad_compact.xml +7 -0
  46. data/test/data/1.5/count_only_compact.xml +3 -0
  47. data/test/{client/data → data}/1.5/error.xml +0 -0
  48. data/test/{client/data → data}/1.5/invalid_compact.xml +0 -0
  49. data/test/{client/data → data}/1.5/login.xml +0 -0
  50. data/test/data/1.5/metadata.xml +0 -0
  51. data/test/{client/data → data}/1.5/search_compact.xml +0 -0
  52. data/test/data/1.5/search_compact_big.xml +136 -0
  53. data/test/{client/data → data}/1.5/search_unescaped_compact.xml +0 -0
  54. data/test/data/listing_service.yml +36 -0
  55. data/test/test_auth.rb +68 -0
  56. data/test/test_client.rb +342 -0
  57. data/test/test_client_links.rb +39 -0
  58. data/test/test_compact_nokogiri.rb +64 -0
  59. data/test/test_helper.rb +12 -0
  60. data/test/test_listing_mapper.rb +112 -0
  61. data/test/test_loader.rb +24 -0
  62. data/test/test_parser.rb +96 -0
  63. data/test/test_quality.rb +57 -0
  64. metadata +168 -53
  65. data/GPL +0 -340
  66. data/examples/metadata.xml +0 -42
  67. data/lib/rets4r/client/metadataindex.rb +0 -82
  68. data/lib/rets4r/client/parser.rb +0 -141
  69. data/lib/rets4r/client/parser/rexml.rb +0 -75
  70. data/lib/rets4r/client/parser/xmlparser.rb +0 -95
  71. data/test/client/parser/tc_rexml.rb +0 -17
  72. data/test/client/parser/tc_xmlparser.rb +0 -21
  73. data/test/client/tc_auth.rb +0 -68
  74. data/test/client/tc_client.rb +0 -320
  75. data/test/client/tc_metadataindex.rb +0 -36
  76. data/test/client/test_parser.rb +0 -128
  77. data/test/client/ts_all.rb +0 -8
  78. data/test/ts_all.rb +0 -1
  79. data/test/ts_client.rb +0 -1
@@ -1,36 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), "../..", "lib")
2
-
3
- require 'rets4r/client/metadataindex'
4
- require 'rets4r/client/transaction'
5
- require 'rets4r/client/metadata'
6
- require 'test/unit'
7
-
8
- module RETS4R
9
- class TestMetadataIndex < Test::Unit::TestCase
10
-
11
- def test_truth
12
- end
13
-
14
- =begin
15
- def setup
16
- File.open('tests/rets/data/metadata.marshal') do |file|
17
- @trans = Marshal.load(file)
18
- end
19
-
20
- @index = MetadataIndex.new(@trans.data)
21
- end
22
-
23
- # Ensure that our lookup and search functions, although different, will return the same data
24
- # for the same criteria.
25
- def test_lookup_search
26
- assert_equal("Club House", @index.lookup('METADATA-LOOKUP_TYPE', 'Property', 'HOAMENITIS_Lkp_2')[0]['LongValue'])
27
-
28
- puts @index.search('METADATA-LOOKUP_TYPE', {'Resource' => 'Property', 'Lookup' => 'HOAMENITIS_Lkp_2'}).inspect
29
- assert_equal( \
30
- @index.lookup('METADATA-LOOKUP_TYPE', 'Property', 'HOAMENITIS_Lkp_2'), \
31
- @index.search('METADATA-LOOKUP_TYPE', {'Resource' => 'Property', 'Lookup' => 'HOAMENITIS_Lkp_2'}).inspect \
32
- )
33
- end
34
- =end
35
- end
36
- end
@@ -1,128 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), "../..", "lib")
2
-
3
- module RETS4R
4
- class Client
5
-
6
- =begin
7
-
8
- Provides a set of parser tests that can be extend for each specific parser type.
9
-
10
- Usage:
11
-
12
- module TestMyParser < Test::Unit::TestCase
13
- include TestParser
14
-
15
- def setup
16
- @parser = MyParser.new
17
- end
18
- end
19
-
20
- =end
21
-
22
- module TestParser
23
- DATA_DIR = 'test/client/data/1.5/'
24
-
25
- def setup
26
- # To be overridden. Must set @parser with a valid parser object
27
- end
28
-
29
- def load_xml_from_file(file_name)
30
- xml = ''
31
-
32
- File.open(file_name) do |file|
33
- file.each do |line|
34
- xml << line
35
- end
36
- end
37
-
38
- xml
39
- end
40
-
41
- def parse_to_transaction(xml_file_name)
42
- @parser.parse(load_xml_from_file(xml_file_name))
43
- end
44
-
45
- # Test Cases
46
-
47
- def test_search_compact
48
- transaction = parse_to_transaction("#{DATA_DIR}search_compact.xml")
49
-
50
- assert_equal(true, transaction.success?)
51
- assert_equal(nil, transaction.response)
52
- assert_equal(false, transaction.header.empty?)
53
- assert_equal(2, transaction.data.length)
54
- assert_equal(transaction.header.length, transaction.data[0].length)
55
- assert_equal(4, transaction.count)
56
- assert_equal(9, transaction.delimiter)
57
- assert_equal("\t", transaction.ascii_delimiter)
58
- end
59
-
60
- def test_unescaped_search_compact
61
- transaction = parse_to_transaction("#{DATA_DIR}search_unescaped_compact.xml")
62
-
63
- # (We should be able to recover automatically from this)
64
- assert_equal(true, transaction.success?)
65
- assert_equal(nil, transaction.response)
66
- assert_equal(false, transaction.header.empty?)
67
- assert_equal(2, transaction.data.length)
68
- assert_equal(transaction.header.length, transaction.data[0].length)
69
- assert_equal(4, transaction.count)
70
- end
71
-
72
- def test_invalid_search_compact
73
- assert_raise(ParserException) do
74
- parse_to_transaction("#{DATA_DIR}invalid_compact.xml")
75
- end
76
- end
77
-
78
- def test_login_results
79
- transaction = parse_to_transaction("#{DATA_DIR}login.xml")
80
-
81
- assert_equal(true, transaction.success?)
82
- assert_equal('srealtor,1,11,11111', transaction.response['User'])
83
- assert_equal('/rets/Login', transaction.response['Login'])
84
- end
85
-
86
- =begin These were salvaged from the old parser test case.
87
-
88
- def test_metadata_results
89
- trans = parse_to_transaction("test/client/data/metadata-full.xml")
90
-
91
- assert_equal(true, trans.success?)
92
- assert_equal(605, trans.data.length)
93
-
94
- #assert_equal('METADATA-SYSTEM', trans.data[0].type)
95
- end
96
- =end
97
-
98
- def test_error_results
99
- xml = load_xml_from_file("#{DATA_DIR}error.xml")
100
-
101
- transaction = @parser.parse(xml)
102
-
103
- assert_equal(false, transaction.success?)
104
- assert_equal('20400', transaction.reply_code)
105
- assert_equal('Invalid Invalidness.', transaction.reply_text)
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
126
- end
127
- end
128
- end
@@ -1,8 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__))
2
-
3
- require 'test/unit'
4
- require 'tc_auth.rb'
5
- require 'tc_client.rb'
6
- require 'tc_metadataindex.rb'
7
- require 'parser/tc_rexml.rb'
8
- require 'parser/tc_xmlparser.rb'
@@ -1 +0,0 @@
1
- require 'test/ts_client'
@@ -1 +0,0 @@
1
- require 'test/client/ts_all'