mls 0.14.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Rakefile +6 -6
  4. data/lib/mls.rb +73 -427
  5. data/lib/mls/account.rb +15 -0
  6. data/lib/mls/address.rb +4 -0
  7. data/lib/mls/agency.rb +6 -0
  8. data/lib/mls/brokerage.rb +7 -0
  9. data/lib/mls/coworking_space.rb +5 -0
  10. data/lib/mls/floorplan.rb +11 -0
  11. data/lib/mls/flyer.rb +11 -0
  12. data/lib/mls/lease.rb +2 -0
  13. data/lib/mls/listing.rb +135 -0
  14. data/lib/mls/locality.rb +6 -0
  15. data/lib/mls/photo.rb +18 -0
  16. data/lib/mls/property.rb +24 -0
  17. data/lib/mls/region.rb +13 -0
  18. data/lib/mls/sale.rb +2 -0
  19. data/lib/mls/space.rb +3 -0
  20. data/lib/mls/sublease.rb +2 -0
  21. data/lib/mls/use.rb +25 -0
  22. data/mls.gemspec +11 -15
  23. data/test/mls/attribute_test.rb +55 -0
  24. data/test/mls/resource_test.rb +31 -0
  25. data/test/mls_test.rb +27 -0
  26. data/test/test_helper.rb +26 -27
  27. metadata +43 -75
  28. data/lib/mls/attribute.rb +0 -44
  29. data/lib/mls/attributes/array.rb +0 -11
  30. data/lib/mls/attributes/boolean.rb +0 -9
  31. data/lib/mls/attributes/datetime.rb +0 -25
  32. data/lib/mls/attributes/decimal.rb +0 -21
  33. data/lib/mls/attributes/fixnum.rb +0 -16
  34. data/lib/mls/attributes/hash.rb +0 -15
  35. data/lib/mls/attributes/string.rb +0 -15
  36. data/lib/mls/errors.rb +0 -29
  37. data/lib/mls/factories/account.rb +0 -34
  38. data/lib/mls/factories/address.rb +0 -16
  39. data/lib/mls/factories/listing.rb +0 -29
  40. data/lib/mls/factories_helper.rb +0 -7
  41. data/lib/mls/model.rb +0 -125
  42. data/lib/mls/models/account.rb +0 -174
  43. data/lib/mls/models/address.rb +0 -58
  44. data/lib/mls/models/brokerage.rb +0 -31
  45. data/lib/mls/models/floorplan.rb +0 -45
  46. data/lib/mls/models/flyer.rb +0 -45
  47. data/lib/mls/models/listing.rb +0 -394
  48. data/lib/mls/models/pdf.rb +0 -15
  49. data/lib/mls/models/photo.rb +0 -40
  50. data/lib/mls/models/property.rb +0 -114
  51. data/lib/mls/models/region.rb +0 -56
  52. data/lib/mls/models/tour.rb +0 -54
  53. data/lib/mls/models/video.rb +0 -18
  54. data/lib/mls/parser.rb +0 -74
  55. data/lib/mls/resource.rb +0 -99
  56. data/lib/rdoc/generator/template/42floors/_context.rhtml +0 -209
  57. data/lib/rdoc/generator/template/42floors/_head.rhtml +0 -7
  58. data/lib/rdoc/generator/template/42floors/class.rhtml +0 -39
  59. data/lib/rdoc/generator/template/42floors/file.rhtml +0 -35
  60. data/lib/rdoc/generator/template/42floors/index.rhtml +0 -13
  61. data/lib/rdoc/generator/template/42floors/resources/apple-touch-icon.png +0 -0
  62. data/lib/rdoc/generator/template/42floors/resources/css/github.css +0 -129
  63. data/lib/rdoc/generator/template/42floors/resources/css/main.css +0 -339
  64. data/lib/rdoc/generator/template/42floors/resources/css/panel.css +0 -389
  65. data/lib/rdoc/generator/template/42floors/resources/css/reset.css +0 -48
  66. data/lib/rdoc/generator/template/42floors/resources/favicon.ico +0 -0
  67. data/lib/rdoc/generator/template/42floors/resources/i/arrows.png +0 -0
  68. data/lib/rdoc/generator/template/42floors/resources/i/results_bg.png +0 -0
  69. data/lib/rdoc/generator/template/42floors/resources/i/tree_bg.png +0 -0
  70. data/lib/rdoc/generator/template/42floors/resources/js/highlight.pack.js +0 -1
  71. data/lib/rdoc/generator/template/42floors/resources/js/jquery-1.3.2.min.js +0 -19
  72. data/lib/rdoc/generator/template/42floors/resources/js/jquery-effect.js +0 -593
  73. data/lib/rdoc/generator/template/42floors/resources/js/main.js +0 -20
  74. data/lib/rdoc/generator/template/42floors/resources/js/searchdoc.js +0 -442
  75. data/lib/rdoc/generator/template/42floors/resources/panel/index.html +0 -73
  76. data/lib/rdoc/generator/template/42floors/se_index.rhtml +0 -8
  77. data/test/units/properties/test_boolean.rb +0 -4
  78. data/test/units/test_errors.rb +0 -32
  79. data/test/units/test_mls.rb +0 -294
  80. data/test/units/test_property.rb +0 -35
@@ -1,20 +0,0 @@
1
- function toggleSource(id)
2
- {
3
- var src = $('#' + id).toggle();
4
- var isVisible = src.is(':visible');
5
- $('#l_' + id).html(isVisible ? 'hide' : 'show');
6
- }
7
-
8
- window.highlight = function(url) {
9
- var hash = url.match(/#([^#]+)$/)
10
- if(hash) {
11
- $('a[name=' + hash[1] + ']').parent().effect('highlight', {}, 'slow')
12
- }
13
- }
14
-
15
- $(function() {
16
- highlight('#' + location.hash);
17
- $('.description pre').each(function() {
18
- hljs.highlightBlock(this);
19
- });
20
- });
@@ -1,442 +0,0 @@
1
- Searchdoc = {};
2
-
3
- // navigation.js ------------------------------------------
4
-
5
- Searchdoc.Navigation = new function() {
6
- this.initNavigation = function() {
7
- var _this = this;
8
-
9
- $(document).keydown(function(e) {
10
- _this.onkeydown(e);
11
- }).keyup(function(e) {
12
- _this.onkeyup(e);
13
- });
14
-
15
- this.navigationActive = true;
16
- }
17
-
18
- this.setNavigationActive = function(state) {
19
- this.navigationActive = state;
20
- this.clearMoveTimeout();
21
- }
22
-
23
-
24
- this.onkeyup = function(e) {
25
- if (!this.navigationActive) return;
26
- switch(e.keyCode) {
27
- case 37: //Event.KEY_LEFT:
28
- case 38: //Event.KEY_UP:
29
- case 39: //Event.KEY_RIGHT:
30
- case 40: //Event.KEY_DOWN:
31
- case 73: // i - qwerty
32
- case 74: // j
33
- case 75: // k
34
- case 76: // l
35
- case 67: // c - dvorak
36
- case 72: // h
37
- case 84: // t
38
- case 78: // n
39
- this.clearMoveTimeout();
40
- break;
41
- }
42
- }
43
-
44
- this.onkeydown = function(e) {
45
- if (!this.navigationActive) return;
46
- switch(e.keyCode) {
47
- case 37: //Event.KEY_LEFT:
48
- case 74: // j (qwerty)
49
- case 72: // h (dvorak)
50
- if (this.moveLeft()) e.preventDefault();
51
- break;
52
- case 38: //Event.KEY_UP:
53
- case 73: // i (qwerty)
54
- case 67: // c (dvorak)
55
- if (e.keyCode == 38 || e.ctrlKey) {
56
- if (this.moveUp()) e.preventDefault();
57
- this.startMoveTimeout(false);
58
- }
59
- break;
60
- case 39: //Event.KEY_RIGHT:
61
- case 76: // l (qwerty)
62
- case 78: // n (dvorak)
63
- if (this.moveRight()) e.preventDefault();
64
- break;
65
- case 40: //Event.KEY_DOWN:
66
- case 75: // k (qwerty)
67
- case 84: // t (dvorak)
68
- if (e.keyCode == 40 || e.ctrlKey) {
69
- if (this.moveDown()) e.preventDefault();
70
- this.startMoveTimeout(true);
71
- }
72
- break;
73
- case 9: //Event.KEY_TAB:
74
- case 13: //Event.KEY_RETURN:
75
- if (this.$current) this.select(this.$current);
76
- break;
77
- }
78
- if (e.ctrlKey && e.shiftKey) this.select(this.$current);
79
- }
80
-
81
- this.clearMoveTimeout = function() {
82
- clearTimeout(this.moveTimeout);
83
- this.moveTimeout = null;
84
- }
85
-
86
- this.startMoveTimeout = function(isDown) {
87
- if (!$.browser.mozilla && !$.browser.opera) return;
88
- if (this.moveTimeout) this.clearMoveTimeout();
89
- var _this = this;
90
-
91
- var go = function() {
92
- if (!_this.moveTimeout) return;
93
- _this[isDown ? 'moveDown' : 'moveUp']();
94
- _this.moveTimout = setTimeout(go, 100);
95
- }
96
- this.moveTimeout = setTimeout(go, 200);
97
- }
98
-
99
- this.moveRight = function() {
100
- }
101
-
102
- this.moveLeft = function() {
103
- }
104
-
105
- this.move = function(isDown) {
106
- }
107
-
108
- this.moveUp = function() {
109
- return this.move(false);
110
- }
111
-
112
- this.moveDown = function() {
113
- return this.move(true);
114
- }
115
- }
116
-
117
-
118
- // scrollIntoView.js --------------------------------------
119
-
120
- function scrollIntoView(element, view) {
121
- var offset, viewHeight, viewScroll, height;
122
- offset = element.offsetTop;
123
- height = element.offsetHeight;
124
- viewHeight = view.offsetHeight;
125
- viewScroll = view.scrollTop;
126
- if (offset - viewScroll + height > viewHeight) {
127
- view.scrollTop = offset - viewHeight + height;
128
- }
129
- if (offset < viewScroll) {
130
- view.scrollTop = offset;
131
- }
132
- }
133
-
134
- // panel.js -----------------------------------------------
135
-
136
- Searchdoc.Panel = function(element, data, tree, frame) {
137
- this.$element = $(element);
138
- this.$input = $('input', element).eq(0);
139
- this.$result = $('.result ul', element).eq(0);
140
- this.frame = frame;
141
- this.$current = null;
142
- this.$view = this.$result.parent();
143
- this.data = data;
144
- this.searcher = new Searcher(data.index);
145
-
146
- this.tree = new Searchdoc.Tree($('.tree', element), tree, this);
147
- this.init();
148
- }
149
-
150
- Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() {
151
- var suid = 1;
152
-
153
- this.init = function() {
154
- var _this = this;
155
- var observer = function() {
156
- _this.search(_this.$input[0].value);
157
- };
158
- this.$input.keyup(observer);
159
- this.$input.click(observer); // mac's clear field
160
-
161
- this.searcher.ready(function(results, isLast) {
162
- _this.addResults(results, isLast);
163
- })
164
-
165
- this.$result.click(function(e) {
166
- _this.$current.removeClass('current');
167
- _this.$current = $(e.target).closest('li').addClass('current');
168
- _this.select();
169
- _this.$input.focus();
170
- });
171
-
172
- this.initNavigation();
173
- this.setNavigationActive(false);
174
- }
175
-
176
- this.search = function(value, selectFirstMatch) {
177
- value = jQuery.trim(value).toLowerCase();
178
- this.selectFirstMatch = selectFirstMatch;
179
- if (value) {
180
- this.$element.removeClass('panel_tree').addClass('panel_results');
181
- this.tree.setNavigationActive(false);
182
- this.setNavigationActive(true);
183
- } else {
184
- this.$element.addClass('panel_tree').removeClass('panel_results');
185
- this.tree.setNavigationActive(true);
186
- this.setNavigationActive(false);
187
- }
188
- if (value != this.lastQuery) {
189
- this.lastQuery = value;
190
- this.firstRun = true;
191
- this.searcher.find(value);
192
- }
193
- }
194
-
195
- this.addResults = function(results, isLast) {
196
- var target = this.$result.get(0);
197
- if (this.firstRun && (results.length > 0 || isLast)) {
198
- this.$current = null;
199
- this.$result.empty();
200
- }
201
- for (var i=0, l = results.length; i < l; i++) {
202
- target.appendChild(renderItem.call(this, results[i]));
203
- };
204
- if (this.firstRun && results.length > 0) {
205
- this.firstRun = false;
206
- this.$current = $(target.firstChild);
207
- this.$current.addClass('current');
208
- if (this.selectFirstMatch) this.select();
209
- scrollIntoView(this.$current[0], this.$view[0])
210
- }
211
- if (jQuery.browser.msie) this.$element[0].className += '';
212
- }
213
-
214
- this.open = function(src) {
215
- this.frame.location.href = '../' + src;
216
- if (this.frame.highlight) this.frame.highlight(src);
217
- }
218
-
219
- this.select = function() {
220
- this.open(this.$current.data('path'));
221
- }
222
-
223
- this.move = function(isDown) {
224
- if (!this.$current) return;
225
- var $next = this.$current[isDown ? 'next' : 'prev']();
226
- if ($next.length) {
227
- this.$current.removeClass('current');
228
- $next.addClass('current');
229
- scrollIntoView($next[0], this.$view[0]);
230
- this.$current = $next;
231
- }
232
- return true;
233
- }
234
-
235
- function renderItem(result) {
236
- var li = document.createElement('li'),
237
- html = '', badge = result.badge;
238
- html += '<h1>' + hlt(result.title);
239
- if (result.params) html += '<i>' + result.params + '</i>';
240
- html += '</h1>';
241
- html += '<p>';
242
- if (typeof badge != 'undefined') {
243
- html += '<span class="badge badge_' + (badge % 6 + 1) + '">' + escapeHTML(this.data.badges[badge] || 'unknown') + '</span>';
244
- }
245
- html += hlt(result.namespace) + '</p>';
246
- if (result.snippet) html += '<p class="snippet">' + escapeHTML(result.snippet) + '</p>';
247
- li.innerHTML = html;
248
- jQuery.data(li, 'path', result.path);
249
- return li;
250
- }
251
-
252
- function hlt(html) {
253
- return escapeHTML(html).replace(/\u0001/g, '<b>').replace(/\u0002/g, '</b>')
254
- }
255
-
256
- function escapeHTML(html) {
257
- return html.replace(/[&<>]/g, function(c) {
258
- return '&#' + c.charCodeAt(0) + ';';
259
- });
260
- }
261
-
262
- });
263
-
264
- // tree.js ------------------------------------------------
265
-
266
- Searchdoc.Tree = function(element, tree, panel) {
267
- this.$element = $(element);
268
- this.$list = $('ul', element);
269
- this.tree = tree;
270
- this.panel = panel;
271
- this.init();
272
- }
273
-
274
- Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() {
275
- this.init = function() {
276
- var stopper = document.createElement('li');
277
- stopper.className = 'stopper';
278
- this.$list[0].appendChild(stopper);
279
- for (var i=0, l = this.tree.length; i < l; i++) {
280
- buildAndAppendItem.call(this, this.tree[i], 0, stopper);
281
- };
282
- var _this = this;
283
- this.$list.click(function(e) {
284
- var $target = $(e.target),
285
- $li = $target.closest('li');
286
- if ($target.hasClass('icon')) {
287
- _this.toggle($li);
288
- } else {
289
- _this.select($li);
290
- }
291
- })
292
-
293
- this.initNavigation();
294
- if (jQuery.browser.msie) document.body.className += '';
295
- }
296
-
297
- this.select = function($li) {
298
- this.highlight($li);
299
- var path = $li[0].searchdoc_tree_data.path;
300
- if (path) this.panel.open(path);
301
- }
302
-
303
- this.highlight = function($li) {
304
- if (this.$current) this.$current.removeClass('current');
305
- this.$current = $li.addClass('current');
306
- }
307
-
308
- this.toggle = function($li) {
309
- var closed = !$li.hasClass('closed'),
310
- children = $li[0].searchdoc_tree_data.children;
311
- $li.toggleClass('closed');
312
- for (var i=0, l = children.length; i < l; i++) {
313
- toggleVis.call(this, $(children[i].li), !closed);
314
- };
315
- }
316
-
317
- this.moveRight = function() {
318
- if (!this.$current) {
319
- this.highlight(this.$list.find('li:first'));
320
- return;
321
- }
322
- if (this.$current.hasClass('closed')) {
323
- this.toggle(this.$current);
324
- }
325
- }
326
-
327
- this.moveLeft = function() {
328
- if (!this.$current) {
329
- this.highlight(this.$list.find('li:first'));
330
- return;
331
- }
332
- if (!this.$current.hasClass('closed')) {
333
- this.toggle(this.$current);
334
- } else {
335
- var level = this.$current[0].searchdoc_tree_data.level;
336
- if (level == 0) return;
337
- var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first');
338
- this.$current.removeClass('current');
339
- $next.addClass('current');
340
- scrollIntoView($next[0], this.$element[0]);
341
- this.$current = $next;
342
- }
343
- }
344
-
345
- this.move = function(isDown) {
346
- if (!this.$current) {
347
- this.highlight(this.$list.find('li:first'));
348
- return true;
349
- }
350
- var next = this.$current[0];
351
- if (isDown) {
352
- do {
353
- next = next.nextSibling;
354
- if (next && next.style && next.style.display != 'none') break;
355
- } while(next);
356
- } else {
357
- do {
358
- next = next.previousSibling;
359
- if (next && next.style && next.style.display != 'none') break;
360
- } while(next);
361
- }
362
- if (next && next.className.indexOf('stopper') == -1) {
363
- this.$current.removeClass('current');
364
- $(next).addClass('current');
365
- scrollIntoView(next, this.$element[0]);
366
- this.$current = $(next);
367
- }
368
- return true;
369
- }
370
-
371
- function toggleVis($li, show) {
372
- var closed = $li.hasClass('closed'),
373
- children = $li[0].searchdoc_tree_data.children;
374
- $li.css('display', show ? '' : 'none')
375
- if (!show && this.$current && $li[0] == this.$current[0]) {
376
- this.$current.removeClass('current');
377
- this.$current = null;
378
- }
379
- for (var i=0, l = children.length; i < l; i++) {
380
- toggleVis.call(this, $(children[i].li), show && !closed);
381
- };
382
- }
383
-
384
- function buildAndAppendItem(item, level, before) {
385
- var li = renderItem(item, level),
386
- list = this.$list[0];
387
- item.li = li;
388
- list.insertBefore(li, before);
389
- for (var i=0, l = item[3].length; i < l; i++) {
390
- buildAndAppendItem.call(this, item[3][i], level + 1, before);
391
- };
392
- return li;
393
- }
394
-
395
- function renderItem(item, level) {
396
- var li = document.createElement('li'),
397
- cnt = document.createElement('div'),
398
- h1 = document.createElement('h1'),
399
- p = document.createElement('p'),
400
- icon, i;
401
-
402
- li.appendChild(cnt);
403
- li.style.paddingLeft = getOffset(level);
404
- cnt.className = 'content';
405
- if (!item[1]) li.className = 'empty ';
406
- cnt.appendChild(h1);
407
- // cnt.appendChild(p);
408
- h1.appendChild(document.createTextNode(item[0]));
409
- // p.appendChild(document.createTextNode(item[4]));
410
- if (item[2]) {
411
- i = document.createElement('i');
412
- i.appendChild(document.createTextNode(item[2]));
413
- h1.appendChild(i);
414
- }
415
- if (item[3].length > 0) {
416
- icon = document.createElement('div');
417
- icon.className = 'icon';
418
- cnt.appendChild(icon);
419
- }
420
-
421
- // user direct assignement instead of $()
422
- // it's 8x faster
423
- // $(li).data('path', item[1])
424
- // .data('children', item[3])
425
- // .data('level', level)
426
- // .css('display', level == 0 ? '' : 'none')
427
- // .addClass('level_' + level)
428
- // .addClass('closed');
429
- li.searchdoc_tree_data = {
430
- path: item[1],
431
- children: item[3],
432
- level: level
433
- }
434
- li.style.display = level == 0 ? '' : 'none';
435
- li.className += 'level_' + level + ' closed';
436
- return li;
437
- }
438
-
439
- function getOffset(level) {
440
- return 5 + 18*level + 'px';
441
- }
442
- });