codewars_api 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e358b5d3492ac331673e4e194549c75751262f6
4
- data.tar.gz: 1802474bae44ea03f2cd68e50d5beb19ff9b862b
3
+ metadata.gz: 95b67630306cd7baae05bb70c5158e3a6a2d1e83
4
+ data.tar.gz: 8bf2bcc0aa0c7e1687efb8fd4478b1d357b877c4
5
5
  SHA512:
6
- metadata.gz: d8657851f10677e18ce4c9fcff03ee05735e55674cbbc11b0fe014103b985d889d1fd81aca7c5d5de10eff93b5a61a8b8534af20e18e9990080a3141f39bf101
7
- data.tar.gz: 33f017f8937798e332a969b6ae8507532b496282954738bb6369a599de5a34406bb6f66219862d35d79809875dd5f1f27173e86194fc65e35a43717a4e17c64d
6
+ metadata.gz: 5dfd98777bde1240bcd7fa134e5ca996a4162d23281c34a5ae1d746e5dfd0a2b7a2d14c94791a835dbcd517e5da16ff67581d5de5e39576f352adb26f09c471c
7
+ data.tar.gz: 8f0b0a7928750f46a0b570d69db4185475532dfbef220420becaa7542044021a3dc4f1ad434876c587773ddcefab651ba1e945ae881188cb9b46a1c12e2356fd
data/codewars_api.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/evmorov/codewars_api_client'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
- .reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.bindir = 'exe'
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
data/lib/codewars_api.rb CHANGED
@@ -5,8 +5,8 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  module CodewarsApi
8
- BASE_URL = 'https://www.codewars.com'
9
- API_URL = '/api/v1'
8
+ BASE_URL = 'https://www.codewars.com'.freeze
9
+ API_URL = '/api/v1'.freeze
10
10
  end
11
11
 
12
12
  class Hash
@@ -65,6 +65,10 @@ module CodewarsApi
65
65
  @response.to_h['wall_time']
66
66
  end
67
67
 
68
+ def type
69
+ @response.to_h['type']
70
+ end
71
+
68
72
  def status_code
69
73
  @response.to_h['status_code']
70
74
  end
@@ -32,8 +32,6 @@ module CodewarsApi
32
32
  https(uri).request_get uri, headers
33
33
  end
34
34
 
35
- private
36
-
37
35
  def self.https(uri)
38
36
  https = Net::HTTP.new(uri.host, uri.port)
39
37
  https.use_ssl = true
@@ -1,7 +1,7 @@
1
1
  module CodewarsApi
2
2
  class ResponseChecker
3
3
  def self.check_errors(response)
4
- fail response.message if response.code == 500
4
+ raise response.message unless response.code == 200
5
5
  end
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@ module CodewarsApi
3
3
  include Common
4
4
 
5
5
  def initialize(id_or_username)
6
- fail 'Username or id is not set' unless id_or_username
6
+ raise 'Username or id is not set' unless id_or_username
7
7
  @response = RequestHelper.get("#{CodewarsApi::API_URL}/users/#{id_or_username}")
8
8
  ResponseChecker.check_errors(@response)
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module CodewarsApi
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codewars_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Morozov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler