rentjuicer 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rentjuicer/listing.rb +12 -10
- data/lib/rentjuicer/listings.rb +24 -25
- data/rentjuicer.gemspec +2 -2
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/lib/rentjuicer/listing.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Rentjuicer
|
2
2
|
class Listing
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(listing)
|
5
|
-
listing.
|
6
|
-
self.instance_variable_set(
|
7
|
-
self.class.send(:
|
5
|
+
listing.each do |key, value|
|
6
|
+
self.instance_variable_set("@#{key}", value)
|
7
|
+
self.class.send(:attr_reader, key)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -43,7 +43,7 @@ module Rentjuicer
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def main_pic
|
46
|
-
sorted_photos.detect(lambda {return sorted_photos.first}) { |photo| photo[:main_photo] } if sorted_photos
|
46
|
+
@main_picture ||= sorted_photos.detect(lambda {return sorted_photos.first}) { |photo| photo[:main_photo] } if sorted_photos
|
47
47
|
end
|
48
48
|
|
49
49
|
def sorted_photos
|
@@ -51,11 +51,13 @@ module Rentjuicer
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def neighborhood_name
|
54
|
-
|
55
|
-
|
56
|
-
self.neighborhoods.first
|
57
|
-
|
58
|
-
self.neighborhoods.first
|
54
|
+
@neigh_name ||= begin
|
55
|
+
unless neighborhoods.blank?
|
56
|
+
if self.neighborhoods.first.is_a?(String)
|
57
|
+
self.neighborhoods.first
|
58
|
+
elsif self.neighborhoods.first.is_a?(Array)
|
59
|
+
self.neighborhoods.first[1]
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
data/lib/rentjuicer/listings.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
1
|
module Rentjuicer
|
2
2
|
class Listings
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :client, :resource
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(client)
|
7
7
|
self.client = client
|
8
8
|
self.resource = "/listings.json"
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def search(params = {})
|
12
12
|
limit = params[:limit] || 20
|
13
13
|
params[:order_by] ||= "rent"
|
14
14
|
params[:order_direction] ||= "asc"
|
15
15
|
SearchResponse.new(self.client.process_get(resource, params), limit)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def featured(params = {})
|
19
19
|
params.merge!(:featured => 1)
|
20
20
|
search(params)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def find_by_id(listing_id, params = {})
|
24
24
|
response = SearchResponse.new(self.client.process_get(resource, params.merge(:rentjuice_id => listing_id)))
|
25
25
|
(response.success? && response.properties.size > 0) ? response.properties.first : nil
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def find_all(params = {})
|
29
29
|
per_page = params[:limit] || 20
|
30
30
|
all_listings = []
|
31
|
-
|
32
31
|
response = search(params)
|
33
32
|
if response.success?
|
34
33
|
all_listings << response.properties
|
@@ -44,7 +43,7 @@ module Rentjuicer
|
|
44
43
|
end
|
45
44
|
all_listings.flatten
|
46
45
|
end
|
47
|
-
|
46
|
+
|
48
47
|
def find_all_by_ids(listing_ids, params = {})
|
49
48
|
listing_ids = listing_ids.split(',') if listing_ids.is_a?(String)
|
50
49
|
all_listings = []
|
@@ -54,49 +53,49 @@ module Rentjuicer
|
|
54
53
|
end
|
55
54
|
all_listings.flatten
|
56
55
|
end
|
57
|
-
|
56
|
+
|
58
57
|
class SearchResponse < Rentjuicer::Response
|
59
|
-
|
60
|
-
attr_accessor :limit
|
61
|
-
|
58
|
+
|
59
|
+
attr_accessor :limit
|
60
|
+
|
62
61
|
def initialize(response, limit = 20)
|
63
62
|
super(response)
|
64
63
|
@limit = limit
|
65
64
|
end
|
66
|
-
|
65
|
+
|
67
66
|
def properties
|
68
|
-
return [] if !self.success? || self.body.listings.blank?
|
69
67
|
@cached_properties ||= begin
|
70
68
|
props = []
|
71
|
-
self.body.listings.
|
72
|
-
|
69
|
+
if self.success? && !self.body.listings.blank?
|
70
|
+
self.body.listings.each do |listing|
|
71
|
+
props << Rentjuicer::Listing.new(listing)
|
72
|
+
end
|
73
73
|
end
|
74
74
|
props
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def total_results
|
79
79
|
self.body.total_count ? self.body.total_count : properties.size
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def mls_results?
|
83
83
|
@has_mls_properties ||= properties.any?{|property| property.mls_listing?}
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
def mls_disclaimers
|
87
87
|
@disclaimers ||= properties.collect{|property| property.mls_disclaimer}.compact.uniq
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
def paginator
|
91
|
-
paginator_cache
|
92
|
-
|
93
|
-
|
94
|
-
@limit,
|
91
|
+
@paginator_cache ||= WillPaginate::Collection.create(
|
92
|
+
self.body.page ||= 1,
|
93
|
+
@limit,
|
95
94
|
self.total_results) do |pager|
|
96
95
|
pager.replace properties
|
97
96
|
end
|
98
97
|
end
|
99
98
|
end
|
100
|
-
|
99
|
+
|
101
100
|
end
|
102
101
|
end
|
data/rentjuicer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rentjuicer}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.8.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["tcocca"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-05-03}
|
13
13
|
s.description = %q{Ruby API wrapper for rentjuice.com built with httparty}
|
14
14
|
s.email = %q{tom.cocca@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rentjuicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- tcocca
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|