Skip to content
Browse files

Sort contacts A-Z

  • Loading branch information...
1 parent 67b5280 commit cd14bf4a7596d590f8a18d4126c16a30651fa016 Anton Dubina committed with niels Jul 25, 2010
Showing with 13 additions and 6 deletions.
  1. +1 −0 lib/contacts/gmail.rb
  2. +4 −2 lib/contacts/livejournal.rb
  3. +3 −1 lib/contacts/mailru.rb
  4. +2 −2 lib/contacts/vkontakte.rb
  5. +3 −1 lib/contacts/yandex.rb
View
1 lib/contacts/gmail.rb
@@ -7,6 +7,7 @@ class Gmail < Base
CONTACTS_FEED = CONTACTS_SCOPE + 'contacts/default/full/?max-results=1000'
def contacts
+ @contacts.sort! { |a,b| a[:name] <=> b[:name] } if @contacts
return @contacts if @contacts
end
View
6 lib/contacts/livejournal.rb
@@ -28,8 +28,7 @@ def real_connect
@cookies = cookies
end
- def contacts
- return @contacts if @contacts
+ def contacts
@contacts = []
if connected?
url = URI.parse(address_book_url)
@@ -45,6 +44,9 @@ def contacts
end
@contacts
end
+
+ @contacts.sort! { |a,b| a[:name] <=> b[:name] } if @contacts
+ return @contacts if @contacts
end
def send_message(username, subject, text)
View
4 lib/contacts/mailru.rb
@@ -32,7 +32,6 @@ def real_connect
end
def contacts
- return @contacts if @contacts
@contacts = []
if connected?
page = 0
@@ -64,6 +63,9 @@ def contacts
end while data.include?("<a href=\"?page=#{page+1}\">Далее<b>&nbsp;&#8250;</b></a>")
@contacts
end
+
+ @contacts.sort! { |a,b| a[:name] <=> b[:name] } if @contacts
+ return @contacts if @contacts
end
private
View
4 lib/contacts/vkontakte.rb
@@ -19,7 +19,6 @@ def real_connect
end
def contacts
- return @contacts if @contacts
@contacts = []
names = {}
@@ -39,7 +38,8 @@ def contacts
@contacts << {:id => id.to_s, :name => name}
end
- @contacts
+ @contacts.sort! { |a,b| a[:name] <=> b[:name] } if @contacts
+ return @contacts if @contacts
end
def send_message(id, subject, text)
View
4 lib/contacts/yandex.rb
@@ -29,7 +29,6 @@ def real_connect
end
def contacts
- return @contacts if @contacts
@contacts = []
if connected?
data, resp, cookies, forward = post(address_book_url, "tp=4&rus=0", @cookies)
@@ -39,6 +38,9 @@ def contacts
parse data
end
+
+ @contacts.sort! { |a,b| a[:name] <=> b[:name] } if @contacts
+ return @contacts if @contacts
end
private

0 comments on commit cd14bf4

Please sign in to comment.
Something went wrong with that request. Please try again.