getafreelancer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ code.rb
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mark Turner
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.
@@ -0,0 +1,30 @@
1
+ = getafreelancer
2
+
3
+ API Wrapper for http://getafreelancer.com
4
+
5
+ == Example
6
+
7
+ require 'getafreelancer'
8
+ client = GetAFreelancer::Client.new
9
+ user = client.user('amerine')
10
+
11
+ puts user.id
12
+ => "123435"
13
+ puts user.url
14
+ => "http://amerine.net"
15
+ puts user.hourly_rate
16
+ => "250"
17
+
18
+ == Note on Patches/Pull Requests
19
+
20
+ * Fork the project.
21
+ * Make your feature addition or bug fix.
22
+ * Add tests for it. This is important so I don't break it in a
23
+ future version unintentionally.
24
+ * Commit, do not mess with rakefile, version, or history.
25
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
26
+ * Send me a pull request. Bonus points for topic branches.
27
+
28
+ == Copyright
29
+
30
+ Copyright (c) 2009 Mark Turner. See LICENSE for details.
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "getafreelancer"
8
+ gem.summary = "API Wrapper for http://getafreelancer.com"
9
+ gem.description = "API Wrapper for http://getafreelancer.com"
10
+ gem.email = "mark@amerine.net"
11
+ gem.homepage = "http://github.com/amerine/getafreelancer"
12
+ gem.authors = ["Mark Turner"]
13
+ gem.add_dependency 'httparty', '>= 0.4.5'
14
+ gem.add_development_dependency "thoughtbot-shoulda"
15
+ gem.add_development_dependency "fakeweb"
16
+ gem.add_development_dependency "mhennemeyer-matchy"
17
+
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/*_test.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/*_test.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+ task :test => :check_dependencies
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ if File.exist?('VERSION')
52
+ version = File.read('VERSION')
53
+ else
54
+ version = ""
55
+ end
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "getafreelancer #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ gem 'httparty', '>= 0.4.5'
3
+ require 'httparty'
4
+ %w(user).each { |x| require File.dirname(__FILE__) + "/getafreelancer/#{x}.rb" }
5
+
6
+
7
+ module GetAFreelancer
8
+ class Client
9
+ include HTTParty
10
+ base_uri "http://api.getafreelancer.com"
11
+
12
+ def initialize(api_key='')
13
+ self.class.default_params :apikey => api_key unless api_key.blank?
14
+ end
15
+
16
+ def get(path, options={})
17
+ self.class.get("#{path}", options)
18
+ end
19
+
20
+ def user(user_id_or_slug="")
21
+ raise ArgumentError, 'You must specify a User id or slug' if user_id_or_slug.blank?
22
+ User.new(self, user_id_or_slug)
23
+ end
24
+ end
25
+
26
+
27
+ end
@@ -0,0 +1,86 @@
1
+ module GetAFreelancer
2
+ class User
3
+ attr_reader :ident, :client
4
+
5
+ def initialize(client, ident)
6
+ @client, @ident = client, ident
7
+ @user = client.get("/User/Properties.json?id=#{ident}")['profile']
8
+ end
9
+
10
+ def info
11
+ @user
12
+ end
13
+
14
+ def url
15
+ @user['url']
16
+ end
17
+
18
+ def id
19
+ @user['id']
20
+ end
21
+
22
+ def username
23
+ @user['username']
24
+ end
25
+
26
+ def logo_url
27
+ @user['logo_url']
28
+ end
29
+
30
+ def reg_unixtime
31
+ @user['reg_unixtime']
32
+ end
33
+
34
+ def reg_date
35
+ @user['reg_date']
36
+ end
37
+
38
+ def company
39
+ @user['company']
40
+ end
41
+
42
+ def gold
43
+ @user['gold']
44
+ end
45
+
46
+ def country
47
+ @user['address']['country']
48
+ end
49
+
50
+ def city
51
+ @user['address']['city']
52
+ end
53
+
54
+ def hourly_rate
55
+ @user['hourlyrate']
56
+ end
57
+
58
+ def rating_average
59
+ @user['rating']['avg']
60
+ end
61
+
62
+ def rating_count
63
+ @user['rating']['count']
64
+ end
65
+
66
+ def provider_rating_average
67
+ @user['provider_rating']['avg']
68
+ end
69
+
70
+ def provider_rating_count
71
+ @user['provider_rating']['count']
72
+ end
73
+
74
+ def buyer_rating_average
75
+ @user['buyer_rating']['avg']
76
+ end
77
+
78
+ def buyer_rating_count
79
+ @user['buyer_rating']['count']
80
+ end
81
+
82
+ def jobs
83
+ @user['jobs']
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Sat, 17 Oct 2009 09:19:48 GMT
4
+ Content-Type: text/javascript; UTF-8
5
+ Transfer-Encoding: chunked
6
+ Connection: keep-alive
7
+
8
+ {"profile":{"url":"http:\/\/www.getafreelancer.com\/users\/1246655.html","id":1246655,"username":"amerine","logo_url":false,"reg_unixtime":1255764110,"reg_date":"Sat, 17 Oct 2009 03:21:50 -0400","company":"nVariable Inc.","gold":0,"address":{"country":"United States","city":"Bend"},"hourlyrate":false,"rating":{"avg":null,"count":0},"provider_rating":{"avg":null,"count":0},"buyer_rating":{"avg":null,"count":0},"jobs":["Linux","MacOS","Ruby\/Ruby on Rails"]}}
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ class GetafreelancerTest < Test::Unit::TestCase
4
+ context "Fetching User Data" do
5
+ setup do
6
+ FakeWeb.register_uri(:get, "http://api.getafreelancer.com/User/Properties.json?id=amerine", :body => File.read("test/fixtures/user.json"))
7
+ @client = GetAFreelancer::Client.new
8
+ @user = @client.user('amerine')
9
+ end
10
+
11
+ should "have an id" do
12
+ @user.id.should == 1246655
13
+ end
14
+
15
+ should "have a url" do
16
+ @user.url.should == "http://www.getafreelancer.com/users/1246655.html"
17
+ end
18
+
19
+ should "have a username" do
20
+ @user.username.should == 'amerine'
21
+ end
22
+
23
+ should "have a company" do
24
+ @user.company.should == 'nVariable Inc.'
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'matchy'
5
+ require 'fakeweb'
6
+
7
+ FakeWeb.allow_net_connect = false
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
+ require 'getafreelancer'
12
+
13
+ class Test::Unit::TestCase
14
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: getafreelancer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Turner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-17 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.5
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: thoughtbot-shoulda
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: fakeweb
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: mhennemeyer-matchy
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: API Wrapper for http://getafreelancer.com
56
+ email: mark@amerine.net
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.rdoc
64
+ files:
65
+ - .document
66
+ - .gitignore
67
+ - LICENSE
68
+ - README.rdoc
69
+ - Rakefile
70
+ - VERSION
71
+ - lib/getafreelancer.rb
72
+ - lib/getafreelancer/user.rb
73
+ - test/fixtures/user.json
74
+ - test/getafreelancer_test.rb
75
+ - test/test_helper.rb
76
+ has_rdoc: true
77
+ homepage: http://github.com/amerine/getafreelancer
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --charset=UTF-8
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.3.5
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: API Wrapper for http://getafreelancer.com
104
+ test_files:
105
+ - test/getafreelancer_test.rb
106
+ - test/test_helper.rb