coderwall-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +58 -0
- data/Rakefile +2 -0
- data/lib/coderwall-api.rb +23 -0
- data/lib/coderwall-api/client.rb +8 -0
- data/lib/coderwall-api/client/profile.rb +29 -0
- data/lib/coderwall-api/hash.rb +19 -0
- data/lib/coderwall-api/version.rb +3 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Will
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# coderwall-api
|
2
|
+
|
3
|
+
A simple gem that allows you to access User Profiles on [Coderwall](http://coderwall.com)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
First install the gem:
|
8
|
+
|
9
|
+
gem install coderwall-api
|
10
|
+
|
11
|
+
or add to your bundler
|
12
|
+
|
13
|
+
gem 'coderwall-api'
|
14
|
+
|
15
|
+
then you're ready to roll.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
First step is to fire up a new client to use. At this point the only available action is to check someones profile. But this will be the core for any future needs.
|
20
|
+
|
21
|
+
cw = Coderwall::Client.new
|
22
|
+
|
23
|
+
Now you can access a profile.
|
24
|
+
|
25
|
+
profile = cw.profile('willrax')
|
26
|
+
|
27
|
+
This will return to you a Hash with method style access to keys.
|
28
|
+
|
29
|
+
profile.location => "Sydney"
|
30
|
+
profile.accounts => {:github=>"willrax"}
|
31
|
+
profile.accounts.github => "willrax"
|
32
|
+
|
33
|
+
You can do things like:
|
34
|
+
|
35
|
+
profile.accounts.each do |k,v|
|
36
|
+
puts "#{profile.username} is a member of #{k}"
|
37
|
+
end
|
38
|
+
|
39
|
+
=> willrax is a member of github
|
40
|
+
|
41
|
+
|
42
|
+
## Contributing to coderwall-api
|
43
|
+
|
44
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
45
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
46
|
+
* Fork the project.
|
47
|
+
* Start a feature/bugfix branch.
|
48
|
+
* Commit and push until you are happy with your contribution.
|
49
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
50
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
51
|
+
|
52
|
+
## Copyright
|
53
|
+
|
54
|
+
Copyright (c) 2012 Will. See LICENSE.txt for
|
55
|
+
further details.
|
56
|
+
|
57
|
+
[![endorse](http://api.coderwall.com/willrax/endorse.png)](http://coderwall.com/willrax)
|
58
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "coderwall-api/client"
|
2
|
+
require "coderwall-api/hash"
|
3
|
+
require "coderwall-api/version"
|
4
|
+
|
5
|
+
module Coderwall
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def new
|
10
|
+
Coderwall::Client.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(method, *args, &block)
|
14
|
+
return super unless new.respond_to?(method)
|
15
|
+
new.send(method, *args, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def respond_to?(method, include_private=false)
|
19
|
+
new.respond_to?(method, include_private) || super(method, include_private)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Coderwall
|
5
|
+
|
6
|
+
# define profile methods
|
7
|
+
class Client
|
8
|
+
|
9
|
+
@@base_url = "http://coderwall.com/"
|
10
|
+
|
11
|
+
def profile(username)
|
12
|
+
begin
|
13
|
+
hash = JSON.load(open(url_to_get(username)))
|
14
|
+
Coderwall::Hash.new(hash)
|
15
|
+
rescue OpenURI::HTTPError
|
16
|
+
console.log "Invalid username: #{username}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def url_to_get(username)
|
23
|
+
url = URI.escape("#{@@base_url}#{username}.json")
|
24
|
+
return url
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Coderwall::Hash < ::Hash
|
2
|
+
|
3
|
+
def initialize(hash = {})
|
4
|
+
hash.keys.each do |key|
|
5
|
+
value = hash[key]
|
6
|
+
value = Coderwall::Hash.new(value) if value.is_a?(::Hash)
|
7
|
+
self[key.to_sym] = value
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(method_name, *args)
|
12
|
+
if key?(method_name.to_sym)
|
13
|
+
self[method_name.to_sym]
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coderwall-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Will
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-30 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: A gem to access the Coderwall api
|
22
|
+
email:
|
23
|
+
- me@willrax.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- lib/coderwall-api.rb
|
37
|
+
- lib/coderwall-api/client.rb
|
38
|
+
- lib/coderwall-api/client/profile.rb
|
39
|
+
- lib/coderwall-api/hash.rb
|
40
|
+
- lib/coderwall-api/version.rb
|
41
|
+
homepage: http://github.com/willrax/coderwall-api
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.13
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: This gem will allow access to the Coderwall api and can be easily updated as the api grows
|
74
|
+
test_files: []
|
75
|
+
|
76
|
+
has_rdoc:
|