mls 0.11.3 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mls.rb +46 -46
  3. data/lib/mls/{property.rb → attribute.rb} +2 -2
  4. data/lib/mls/{properties → attributes}/array.rb +1 -1
  5. data/lib/mls/{properties → attributes}/boolean.rb +1 -1
  6. data/lib/mls/{properties → attributes}/datetime.rb +1 -1
  7. data/lib/mls/{properties → attributes}/decimal.rb +1 -1
  8. data/lib/mls/{properties → attributes}/fixnum.rb +1 -1
  9. data/lib/mls/{properties → attributes}/hash.rb +1 -1
  10. data/lib/mls/{properties → attributes}/string.rb +1 -1
  11. data/lib/mls/factories/listing.rb +3 -3
  12. data/lib/mls/model.rb +33 -33
  13. data/lib/mls/models/account.rb +55 -46
  14. data/lib/mls/models/address.rb +18 -117
  15. data/lib/mls/models/brokerage.rb +6 -6
  16. data/lib/mls/models/floorplan.rb +5 -5
  17. data/lib/mls/models/flyer.rb +5 -5
  18. data/lib/mls/models/listing.rb +80 -76
  19. data/lib/mls/models/pdf.rb +4 -4
  20. data/lib/mls/models/photo.rb +10 -10
  21. data/lib/mls/models/property.rb +113 -0
  22. data/lib/mls/models/region.rb +14 -14
  23. data/lib/mls/models/tour.rb +10 -10
  24. data/lib/mls/models/video.rb +7 -7
  25. data/lib/mls/parser.rb +1 -1
  26. data/lib/mls/resource.rb +15 -15
  27. data/lib/rdoc/generator/template/42floors/resources/css/github.css +1 -1
  28. data/lib/rdoc/generator/template/42floors/resources/js/highlight.pack.js +1 -1
  29. data/lib/rdoc/generator/template/42floors/resources/js/jquery-1.3.2.min.js +1 -1
  30. data/lib/rdoc/generator/template/42floors/resources/js/jquery-effect.js +6 -6
  31. data/mls.gemspec +1 -1
  32. data/test/test_helper.rb +1 -1
  33. data/test/units/models/test_address.rb +4 -4
  34. data/test/units/models/test_contact.rb +1 -1
  35. data/test/units/models/test_listing.rb +4 -4
  36. data/test/units/test_mls.rb +60 -60
  37. data/test/units/test_model.rb +3 -3
  38. data/test/units/test_property.rb +18 -18
  39. data/test/units/test_resource.rb +1 -1
  40. metadata +12 -11
@@ -12,10 +12,10 @@ class TestMLS < ::Test::Unit::TestCase
12
12
  assert mls.respond_to?(:url)
13
13
  assert mls.respond_to?(:url=)
14
14
  assert mls.respond_to?(:api_key)
15
- assert mls.respond_to?(:auth_key)
15
+ assert mls.respond_to?(:auth_cookie)
16
16
  assert mls.respond_to?(:logger)
17
17
  assert mls.respond_to?(:connection)
18
- assert mls.respond_to?(:add_headers)
18
+ assert mls.respond_to?(:prepare_request)
19
19
 
20
20
  assert mls.respond_to?(:put)
21
21
  assert mls.respond_to?(:post)
@@ -27,28 +27,28 @@ class TestMLS < ::Test::Unit::TestCase
27
27
  assert mls.respond_to?(:auth_ping)
28
28
  assert mls.respond_to?(:default_logger)
29
29
  end
30
-
30
+
31
31
  # MLS.get =================================================================
32
-
32
+
33
33
  test '#get' do
34
34
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get')
35
35
  response = MLS.get('/test')
36
36
  assert_equal 'get', response.body
37
37
  end
38
-
38
+
39
39
  test '#get with params' do
40
40
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test?key=value", :body => 'get')
41
41
  response = MLS.get('/test', :key => 'value')
42
-
42
+
43
43
  assert_equal '/api/test?key=value', FakeWeb.last_request.path
44
44
  end
45
-
45
+
46
46
  test '#get to 404 raises MLS::Exception::NotFound' do
47
47
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get', :status => ['404', ''])
48
-
48
+
49
49
  assert_raises(MLS::Exception::NotFound) { MLS.get('/test') }
50
50
  end
51
-
51
+
52
52
  test '#get to 404 doesnt raise NotFound if in valid_response_codes' do
53
53
  assert_nothing_raised {
54
54
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get', :status => ['404', ''])
@@ -56,18 +56,18 @@ class TestMLS < ::Test::Unit::TestCase
56
56
 
57
57
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get', :status => ['404', ''])
58
58
  MLS.get('/test', nil, 400..499)
59
-
59
+
60
60
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get', :status => ['404', ''])
61
61
  MLS.get('/test', nil, 300..399, 404)
62
-
62
+
63
63
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get', :status => ['404', ''])
64
64
  MLS.get('/test', nil, 404, 300..399)
65
-
65
+
66
66
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get', :status => ['404', ''])
67
67
  MLS.get('/test', nil, [300..399, 404])
68
68
  }
69
69
  end
70
-
70
+
71
71
  test '#get with block' do
72
72
  FakeWeb.register_uri(:get, "#{MLS_HOST}/test", :body => 'get')
73
73
  MLS.get('/test') do |response|
@@ -81,29 +81,29 @@ class TestMLS < ::Test::Unit::TestCase
81
81
  raise MLS::Exception, 'Should not get here'
82
82
  end
83
83
  }
84
- end
85
-
84
+ end
85
+
86
86
  # MLS.put =================================================================
87
-
87
+
88
88
  test '#put' do
89
89
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put')
90
90
  response = MLS.put('/test')
91
91
  assert_equal 'put', response.body
92
92
  end
93
-
93
+
94
94
  test '#put with a body' do
95
95
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put')
96
96
  response = MLS.put('/test', :key => 'value')
97
-
98
- assert_equal '{"key":"value"}', FakeWeb.last_request.body
97
+
98
+ assert_equal '{"key":"value"}', FakeWeb.last_request.body
99
99
  end
100
-
100
+
101
101
  test '#put to 404 raises MLS::Exception::NotFound' do
102
102
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put', :status => ['404', ''])
103
-
103
+
104
104
  assert_raises(MLS::Exception::NotFound) { MLS.put('/test') }
105
105
  end
106
-
106
+
107
107
  test '#put to 404 doesnt raise NotFound if in valid_response_codes' do
108
108
  assert_nothing_raised {
109
109
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put', :status => ['404', ''])
@@ -111,18 +111,18 @@ class TestMLS < ::Test::Unit::TestCase
111
111
 
112
112
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put', :status => ['404', ''])
113
113
  MLS.put('/test', nil, 400..499)
114
-
114
+
115
115
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put', :status => ['404', ''])
116
116
  MLS.put('/test', nil, 300..399, 404)
117
-
117
+
118
118
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put', :status => ['404', ''])
119
119
  MLS.put('/test', nil, 404, 300..399)
120
-
120
+
121
121
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put', :status => ['404', ''])
122
122
  MLS.put('/test', nil, [300..399, 404])
123
123
  }
124
124
  end
125
-
125
+
126
126
  test '#put with block' do
127
127
  FakeWeb.register_uri(:put, "#{MLS_HOST}/test", :body => 'put')
128
128
  MLS.put('/test') do |response|
@@ -137,28 +137,28 @@ class TestMLS < ::Test::Unit::TestCase
137
137
  end
138
138
  }
139
139
  end
140
-
140
+
141
141
  # MLS.post =================================================================
142
-
142
+
143
143
  test '#post' do
144
144
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post')
145
145
  response = MLS.post('/test')
146
146
  assert_equal 'post', response.body
147
147
  end
148
-
148
+
149
149
  test '#post with a body' do
150
150
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post')
151
151
  response = MLS.post('/test', :key => 'value')
152
-
153
- assert_equal '{"key":"value"}', FakeWeb.last_request.body
152
+
153
+ assert_equal '{"key":"value"}', FakeWeb.last_request.body
154
154
  end
155
-
155
+
156
156
  test '#post to 404 raises MLS::Exception::NotFound' do
157
157
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post', :status => ['404', ''])
158
-
158
+
159
159
  assert_raises(MLS::Exception::NotFound) { MLS.post('/test') }
160
160
  end
161
-
161
+
162
162
  test '#post to 404 doesnt raise NotFound if in valid_response_codes' do
163
163
  assert_nothing_raised {
164
164
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post', :status => ['404', ''])
@@ -166,18 +166,18 @@ class TestMLS < ::Test::Unit::TestCase
166
166
 
167
167
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post', :status => ['404', ''])
168
168
  MLS.post('/test', nil, 400..499)
169
-
169
+
170
170
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post', :status => ['404', ''])
171
171
  MLS.post('/test', nil, 300..399, 404)
172
-
172
+
173
173
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post', :status => ['404', ''])
174
174
  MLS.post('/test', nil, 404, 300..399)
175
-
175
+
176
176
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post', :status => ['404', ''])
177
177
  MLS.post('/test', nil, [300..399, 404])
178
178
  }
179
179
  end
180
-
180
+
181
181
  test '#post with block' do
182
182
  FakeWeb.register_uri(:post, "#{MLS_HOST}/test", :body => 'post')
183
183
  MLS.post('/test') do |response|
@@ -192,28 +192,28 @@ class TestMLS < ::Test::Unit::TestCase
192
192
  end
193
193
  }
194
194
  end
195
-
195
+
196
196
  # MLS.delete ================================================================
197
-
197
+
198
198
  test '#delete' do
199
199
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete')
200
200
  response = MLS.delete('/test')
201
201
  assert_equal 'delete', response.body
202
202
  end
203
-
203
+
204
204
  test '#delete with a body' do
205
205
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete')
206
206
  response = MLS.delete('/test', :key => 'value')
207
-
208
- assert_equal '{"key":"value"}', FakeWeb.last_request.body
207
+
208
+ assert_equal '{"key":"value"}', FakeWeb.last_request.body
209
209
  end
210
-
210
+
211
211
  test '#delete to 404 raises MLS::Exception::NotFound' do
212
212
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete', :status => ['404', ''])
213
-
213
+
214
214
  assert_raises(MLS::Exception::NotFound) { MLS.delete('/test') }
215
215
  end
216
-
216
+
217
217
  test '#delete to 404 doesnt raise NotFound if in valid_response_codes' do
218
218
  assert_nothing_raised {
219
219
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete', :status => ['404', ''])
@@ -221,18 +221,18 @@ class TestMLS < ::Test::Unit::TestCase
221
221
 
222
222
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete', :status => ['404', ''])
223
223
  MLS.delete('/test', nil, 400..499)
224
-
224
+
225
225
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete', :status => ['404', ''])
226
226
  MLS.delete('/test', nil, 300..399, 404)
227
-
227
+
228
228
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete', :status => ['404', ''])
229
229
  MLS.delete('/test', nil, 404, 300..399)
230
-
230
+
231
231
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete', :status => ['404', ''])
232
232
  MLS.delete('/test', nil, [300..399, 404])
233
233
  }
234
234
  end
235
-
235
+
236
236
  test '#delete with block' do
237
237
  FakeWeb.register_uri(:delete, "#{MLS_HOST}/test", :body => 'delete')
238
238
  MLS.delete('/test') do |response|
@@ -247,19 +247,19 @@ class TestMLS < ::Test::Unit::TestCase
247
247
  end
248
248
  }
249
249
  end
250
-
250
+
251
251
  # MLS.handle_response ======================================================
252
-
252
+
253
253
  test 'handle_response raises BadRequest on 400' do
254
254
  response = mock_response(:get, 400)
255
255
  assert_raises(MLS::Exception::BadRequest) { MLS.handle_response(response) }
256
256
  end
257
-
257
+
258
258
  test 'handle_response raises Unauthorized on 401' do
259
259
  response = mock_response(:get, 401)
260
260
  assert_raises(MLS::Exception::Unauthorized) { MLS.handle_response(response) }
261
261
  end
262
-
262
+
263
263
  test 'handle_response raises NotFound on 404' do
264
264
  response = mock_response(:get, 404)
265
265
  assert_raises(MLS::Exception::NotFound) { MLS.handle_response(response) }
@@ -274,21 +274,21 @@ class TestMLS < ::Test::Unit::TestCase
274
274
  response = mock_response(:get, 422)
275
275
  assert_raises(MLS::Exception::ApiVersionUnsupported) { MLS.handle_response(response) }
276
276
  end
277
-
277
+
278
278
  test 'handle_response raises ServiceUnavailable on 503' do
279
279
  response = mock_response(:get, 503)
280
280
  assert_raises(MLS::Exception::ServiceUnavailable) { MLS.handle_response(response) }
281
281
  end
282
-
282
+
283
283
  test 'handle_response raises Exception on 350, 450, & 550' do
284
284
  response = mock_response(:get, 350)
285
285
  assert_raises(MLS::Exception) { MLS.handle_response(response) }
286
-
286
+
287
287
  response = mock_response(:get, 450)
288
288
  assert_raises(MLS::Exception) { MLS.handle_response(response) }
289
-
289
+
290
290
  response = mock_response(:get, 550)
291
291
  assert_raises(MLS::Exception) { MLS.handle_response(response) }
292
292
  end
293
-
294
- end
293
+
294
+ end
@@ -10,9 +10,9 @@ class TestModel < ::Test::Unit::TestCase
10
10
  def test_instance_methods
11
11
  model = MyModel.new
12
12
 
13
- assert model.respond_to?(:property)
14
- assert model.respond_to?(:properties)
15
- assert model.respond_to?(:property_module)
13
+ assert model.respond_to?(:attribute)
14
+ assert model.respond_to?(:attributes)
15
+ assert model.respond_to?(:attribute_module)
16
16
  assert model.respond_to?(:create_reader_for)
17
17
  assert model.respond_to?(:create_writer_for)
18
18
  assert model.respond_to?(:model_name)
@@ -1,35 +1,35 @@
1
1
  require 'test_helper'
2
2
 
3
- class TestProperty < ::Test::Unit::TestCase
3
+ class TestAttribute < ::Test::Unit::TestCase
4
4
 
5
5
  def test_DEFAULT_OPTIONS
6
- assert_equal :always, MLS::Property::DEFAULT_OPTIONS[:serialize]
6
+ assert_equal :always, MLS::Attribute::DEFAULT_OPTIONS[:serialize]
7
7
  end
8
8
 
9
9
  def test_attr_readers
10
- property = MLS::Property.new(:name => "blah")
11
-
12
- assert property.respond_to?(:model)
13
- assert property.respond_to?(:name)
14
- assert property.respond_to?(:instance_variable_name)
15
- assert property.respond_to?(:options)
16
- assert property.respond_to?(:default)
17
- assert property.respond_to?(:reader_visibility)
18
- assert property.respond_to?(:writer_visibility)
10
+ attribute = MLS::Attribute.new(:name => "blah")
11
+
12
+ assert attribute.respond_to?(:model)
13
+ assert attribute.respond_to?(:name)
14
+ assert attribute.respond_to?(:instance_variable_name)
15
+ assert attribute.respond_to?(:options)
16
+ assert attribute.respond_to?(:default)
17
+ assert attribute.respond_to?(:reader_visibility)
18
+ assert attribute.respond_to?(:writer_visibility)
19
19
  end
20
20
 
21
21
  def test_instance_methods
22
- property = MLS::Property.new(:name => "blah")
22
+ attribute = MLS::Attribute.new(:name => "blah")
23
23
 
24
- assert property.respond_to?(:set_default_value)
25
- assert property.respond_to?(:determine_visibility)
24
+ assert attribute.respond_to?(:set_default_value)
25
+ assert attribute.respond_to?(:determine_visibility)
26
26
  end
27
27
 
28
28
  def test_class_methods
29
- assert MLS::Property.respond_to?(:determine_class)
30
- assert MLS::Property.respond_to?(:inherited)
31
- assert MLS::Property.respond_to?(:demodulized_names)
32
- assert MLS::Property.respond_to?(:find_class)
29
+ assert MLS::Attribute.respond_to?(:determine_class)
30
+ assert MLS::Attribute.respond_to?(:inherited)
31
+ assert MLS::Attribute.respond_to?(:demodulized_names)
32
+ assert MLS::Attribute.respond_to?(:find_class)
33
33
  end
34
34
 
35
35
  end
@@ -18,7 +18,7 @@ class TestResource < ::Test::Unit::TestCase
18
18
  assert resource.respond_to?(:persisted?)
19
19
  assert resource.respond_to?(:save)
20
20
 
21
- assert resource.respond_to?(:properties)
21
+ assert resource.respond_to?(:attributes)
22
22
  assert resource.respond_to?(:set_default_values)
23
23
  assert resource.respond_to?(:update_attributes)
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James R. Bracy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-11 00:00:00.000000000 Z
12
+ date: 2014-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -205,6 +205,14 @@ files:
205
205
  - README.rdoc
206
206
  - Rakefile
207
207
  - lib/mls.rb
208
+ - lib/mls/attribute.rb
209
+ - lib/mls/attributes/array.rb
210
+ - lib/mls/attributes/boolean.rb
211
+ - lib/mls/attributes/datetime.rb
212
+ - lib/mls/attributes/decimal.rb
213
+ - lib/mls/attributes/fixnum.rb
214
+ - lib/mls/attributes/hash.rb
215
+ - lib/mls/attributes/string.rb
208
216
  - lib/mls/errors.rb
209
217
  - lib/mls/factories/account.rb
210
218
  - lib/mls/factories/address.rb
@@ -219,18 +227,11 @@ files:
219
227
  - lib/mls/models/listing.rb
220
228
  - lib/mls/models/pdf.rb
221
229
  - lib/mls/models/photo.rb
230
+ - lib/mls/models/property.rb
222
231
  - lib/mls/models/region.rb
223
232
  - lib/mls/models/tour.rb
224
233
  - lib/mls/models/video.rb
225
234
  - lib/mls/parser.rb
226
- - lib/mls/properties/array.rb
227
- - lib/mls/properties/boolean.rb
228
- - lib/mls/properties/datetime.rb
229
- - lib/mls/properties/decimal.rb
230
- - lib/mls/properties/fixnum.rb
231
- - lib/mls/properties/hash.rb
232
- - lib/mls/properties/string.rb
233
- - lib/mls/property.rb
234
235
  - lib/mls/resource.rb
235
236
  - lib/rdoc/generator/template/42floors/_context.rhtml
236
237
  - lib/rdoc/generator/template/42floors/_head.rhtml
@@ -288,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
289
  version: '0'
289
290
  requirements: []
290
291
  rubyforge_project: mls
291
- rubygems_version: 2.0.3
292
+ rubygems_version: 2.1.11
292
293
  signing_key:
293
294
  specification_version: 4
294
295
  summary: 42Floors MLS Client