coderwall-ruby-api 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/coderwall-ruby-api/version', __FILE__)
2
+ require File.expand_path('../lib/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Rafael Fidelis"]
@@ -1,9 +1,10 @@
1
- require "coderwall-ruby-api/version"
2
1
  require 'net/http'
3
2
  require 'json'
4
3
 
5
4
  module Coderwall
5
+
6
6
  BASE_URI = "http://coderwall.com/%s.json"
7
+
7
8
  class User
8
9
  def initialize(username, send_request=true)
9
10
  username.empty? ? invalid_username : @username = username.to_s
@@ -18,7 +19,11 @@ module Coderwall
18
19
  return @user_data[args[0].to_s] || super
19
20
  end
20
21
  def make_http_request
21
- @user_data ||= JSON.parse(Net::HTTP.get(URI(BASE_URI % @username))) rescue invalid_username
22
+ begin
23
+ @user_data ||= JSON.parse(Net::HTTP.get(URI(BASE_URI % @username)))
24
+ rescue JSON::ParserError => e
25
+ invalid_username
26
+ end
22
27
  end
23
28
  def invalid_username
24
29
  raise(ArgumentError.new('invalid username'))
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Coderwall
2
+ VERSION = "0.0.2"
3
+ end
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.1
4
+ version: 0.0.2
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-06-24 00:00:00.000000000 Z
12
+ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Simple Coderwall API Interface for Ruby
15
15
  email:
@@ -26,7 +26,7 @@ files:
26
26
  - Rakefile
27
27
  - coderwall-ruby-api.gemspec
28
28
  - lib/coderwall-ruby-api.rb
29
- - lib/coderwall-ruby-api/version.rb
29
+ - lib/version.rb
30
30
  homepage: https://github.com/fidelisrafael/coderwall-ruby-api
31
31
  licenses: []
32
32
  post_install_message:
@@ -1,3 +0,0 @@
1
- module Coderwall
2
- VERSION = "0.0.1"
3
- end