coderwall-ruby-api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/coderwall-ruby-api.rb +12 -2
- data/lib/version.rb +2 -1
- metadata +3 -2
data/lib/coderwall-ruby-api.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
require 'version'
|
1
3
|
require 'net/http'
|
2
4
|
require 'json'
|
3
5
|
|
4
6
|
module Coderwall
|
5
7
|
|
6
|
-
BASE_URI = "
|
8
|
+
BASE_URI = "https://coderwall.com/%s.json"
|
7
9
|
|
8
10
|
class User
|
9
11
|
def initialize(username, send_request=true)
|
@@ -20,11 +22,19 @@ module Coderwall
|
|
20
22
|
end
|
21
23
|
def make_http_request
|
22
24
|
begin
|
23
|
-
@user_data ||= JSON.parse(
|
25
|
+
@user_data ||= JSON.parse(send_http_request)
|
24
26
|
rescue JSON::ParserError => e
|
25
27
|
invalid_username
|
26
28
|
end
|
27
29
|
end
|
30
|
+
def send_http_request
|
31
|
+
uri = URI.parse(BASE_URI % @username)
|
32
|
+
response = Net::HTTP.start(uri.host, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
33
|
+
http.get uri.request_uri
|
34
|
+
end
|
35
|
+
return response.body
|
36
|
+
end
|
37
|
+
|
28
38
|
def invalid_username
|
29
39
|
raise(ArgumentError.new('invalid username'))
|
30
40
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coderwall-ruby-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Simple Coderwall API Interface for Ruby
|
15
15
|
email:
|
@@ -52,3 +52,4 @@ signing_key:
|
|
52
52
|
specification_version: 3
|
53
53
|
summary: Simple Coderwall API Interface for Ruby
|
54
54
|
test_files: []
|
55
|
+
has_rdoc:
|