contactlist-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Richard Huang (flyerhzm@gmail.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,35 @@
1
+ h1. contactlist-client
2
+
3
+ The contactlist-client gem is a ruby client to "contactlist":http://github.com/flyerhzm/contactlist service which retrieves contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah and 189) and im(msn)
4
+
5
+ **********************************************************
6
+
7
+ h2. install
8
+
9
+ <pre><code>
10
+ gem sources -a http://gemcutter.org
11
+ gem install contactlist-client
12
+ </code></pre>
13
+
14
+ **********************************************************
15
+
16
+ h2. Usage
17
+
18
+ <pre><code>
19
+ require 'contactlist-client'
20
+
21
+ contacts = ContactList::Client.fetch(account, password, type)
22
+
23
+ contacts.each do |contact|
24
+ puts "username: #{contact.username}, email: #{contact.email}"
25
+ end
26
+ </code></pre>
27
+
28
+ * <code>account</code>, string of your email or im account
29
+ * <code>password</code>, string of your password
30
+ * <code>type</code>, string of your email type of im, now support gmail, hotmail, yahoo, sohu, sina, tom, yeah, 163, 126, 189, 139 and msn
31
+
32
+ **********************************************************
33
+
34
+
35
+ Copyright (c) 2009 Richard Huang (flyerhzm@gmail.com). See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "contactlist-client"
8
+ gem.summary = %Q{The contactlist-client gem is a ruby client to contactlist service which retrieves contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah and 189) and im(msn)}
9
+ gem.description = %Q{The contactlist-client gem is a ruby client to contactlist service which retrieves contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah and 189) and im(msn)}
10
+ gem.email = "flyerhzm@gmail.com"
11
+ gem.homepage = "http://github.com/flyerhzm/contactlist-client"
12
+ gem.authors = ["Richard Huang"]
13
+ gem.files.exclude '.gitignore'
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION')
47
+ version = File.read('VERSION')
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "contactlist-client #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,41 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ require 'rubygems'
5
+ require 'json'
6
+
7
+ module ContactList
8
+ class Client
9
+
10
+ REQUEST_URI = 'http://contacts.huangzhimin.com/'
11
+ #REQUEST_URI = 'http://localhost:8080/ContactListService/contacts'
12
+
13
+ Contact = Struct.new(:username, :email)
14
+
15
+ def self.fetch(account, password, type)
16
+ response = get_response(REQUEST_URI, {'account' => account, 'password' => password, 'type' => type})
17
+ contacts = []
18
+ data = JSON.parse(response.body)
19
+
20
+ raise ContactListException.new(data['error']) if data['error']
21
+
22
+ data['contacts'].each do |contact|
23
+ contacts << Contact.new(contact['username'], contact['email'])
24
+ end
25
+ contacts
26
+ end
27
+
28
+ private
29
+ def self.get_response(url, post_data)
30
+ response = Net::HTTP.post_form URI.parse(url), post_data
31
+ if Net::HTTPRedirection === response
32
+ response = get_response(response['location'], post_data)
33
+ end
34
+ response
35
+ end
36
+ end
37
+
38
+ class ContactListException < Exception
39
+ end
40
+ end
41
+
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), 'contactlist', 'client')
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class ContactlistClientTest < Test::Unit::TestCase
4
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ require 'contactlist-client'
7
+
8
+ class Test::Unit::TestCase
9
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contactlist-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Richard Huang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-30 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: The contactlist-client gem is a ruby client to contactlist service which retrieves contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah and 189) and im(msn)
17
+ email: flyerhzm@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.textile
25
+ files:
26
+ - .document
27
+ - LICENSE
28
+ - README.textile
29
+ - Rakefile
30
+ - VERSION
31
+ - lib/contactlist-client.rb
32
+ - lib/contactlist/client.rb
33
+ - test/contactlist-client_test.rb
34
+ - test/test_helper.rb
35
+ has_rdoc: true
36
+ homepage: http://github.com/flyerhzm/contactlist-client
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.3.5
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: The contactlist-client gem is a ruby client to contactlist service which retrieves contact list of email(hotmail, gmail, yahoo, sohu, sina, 163, 126, tom, yeah and 189) and im(msn)
63
+ test_files:
64
+ - test/contactlist-client_test.rb
65
+ - test/test_helper.rb