you_got_listed 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,7 +50,7 @@ module YouGotListed
50
50
  end
51
51
 
52
52
  def pictures
53
- self.photos.photo unless self.photos.blank? || self.photos.photo.blank?
53
+ (self.photos.photo.is_a?(Array) ? self.photos.photo : [self.photos.photo]) unless self.photos.blank? || self.photos.photo.blank?
54
54
  end
55
55
 
56
56
  def main_picture
@@ -52,10 +52,10 @@ module YouGotListed
52
52
  if listing_ids.any?{|list_id| list_id !=~ /[A-Z]{3}-[0-9]{3}-[0-9]{3}/}
53
53
  search_params[:include_mls] = 1
54
54
  end
55
- listing_ids.in_groups_of(500, false).each_with_index do |group, index|
55
+ # YGL no longer allows you to pass more than 10 ids at a time
56
+ listing_ids.in_groups_of(10, false).each_with_index do |group, index|
56
57
  group.delete_if{|x| x.nil?}
57
58
  search_params[:listing_ids] = group.join(',')
58
- search_params[:page_count] = 500
59
59
  search_params[:page_index] = index + 1
60
60
  all_listings << find_all(search_params)
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module YouGotListed
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -4,6 +4,7 @@ require 'hashie'
4
4
  require 'rash'
5
5
  require 'will_paginate/collection'
6
6
  require 'active_support/core_ext/array/grouping'
7
+ require 'active_support/core_ext/object/blank'
7
8
 
8
9
  require 'you_got_listed/client'
9
10
  require 'you_got_listed/resource'
@@ -81,6 +81,14 @@ describe YouGotListed::Listing do
81
81
  @listing.stub!(:pictures).and_return(nil)
82
82
  @listing.main_picture.should be_nil
83
83
  end
84
+
85
+ it "should return an array if the property has only one photo" do
86
+ rash = valid_listing_rash
87
+ rash[:photos].merge!(:photo => 'http://ygl-photos.s3.amazonaws.com/1236380.jpg')
88
+ @listing = YouGotListed::Listing.new(rash, @ygl)
89
+ @listing.pictures.is_a?(Array).should be_true
90
+ @listing.main_picture.should == 'http://ygl-photos.s3.amazonaws.com/1236380.jpg'
91
+ end
84
92
  end
85
93
 
86
94
  context "latitude" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: you_got_listed
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Cocca