codewars_api 0.1.1 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/codewars_api/attempt_solution.rb +2 -8
- data/lib/codewars_api/client.rb +2 -2
- data/lib/codewars_api/common.rb +15 -0
- data/lib/codewars_api/deferred_response.rb +2 -12
- data/lib/codewars_api/finalize_solution.rb +2 -8
- data/lib/codewars_api/kata_info.rb +2 -4
- data/lib/codewars_api/train_next_kata.rb +2 -8
- data/lib/codewars_api/train_specific_kata.rb +2 -8
- data/lib/codewars_api/user.rb +5 -7
- data/lib/codewars_api/version.rb +1 -1
- data/lib/codewars_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d50013fa7b3be16d2e5b8761306ba17566fd27
|
4
|
+
data.tar.gz: ffda58c75b54c0bd3eb783a5fdcc23591347bef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77924b541c9bd1e4bd72778d7a6afd336f4e0c7651f2b1bb987c401de7ed57123dc77483928945613875ffeddf38e3b3b35c6e58c9f41fed4130fb734a4e51a6
|
7
|
+
data.tar.gz: d38ed424d7d2c6310a73ff8b3aeaeb005acc191e1b832a6ecae962f63d5df77b2871bdab07d531e6e4385251bc0df9934fee698acda964f84fa043b98e6538a5
|
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class AttemptSolution
|
3
|
+
include Common
|
4
|
+
|
3
5
|
def initialize(options)
|
4
6
|
api_key = options.delete!(:api_key)
|
5
7
|
project_id = options.delete!(:project_id)
|
@@ -16,16 +18,8 @@ module CodewarsApi
|
|
16
18
|
)
|
17
19
|
end
|
18
20
|
|
19
|
-
def success
|
20
|
-
@response.to_h['success']
|
21
|
-
end
|
22
|
-
|
23
21
|
def dmid
|
24
22
|
@response.to_h['dmid']
|
25
23
|
end
|
26
|
-
|
27
|
-
def to_h
|
28
|
-
@response.to_h
|
29
|
-
end
|
30
24
|
end
|
31
25
|
end
|
data/lib/codewars_api/client.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class DeferredResponse
|
3
|
+
include Common
|
4
|
+
|
3
5
|
def initialize(options)
|
4
6
|
api_key = options.delete!(:api_key)
|
5
7
|
dmid = options.delete!(:dmid)
|
@@ -10,10 +12,6 @@ module CodewarsApi
|
|
10
12
|
@response = RequestHelper.get("#{CodewarsApi::API_URL}/deferred/#{dmid}", request_options)
|
11
13
|
end
|
12
14
|
|
13
|
-
def success
|
14
|
-
@response.to_h['success']
|
15
|
-
end
|
16
|
-
|
17
15
|
def dmid
|
18
16
|
@response.to_h['dmid']
|
19
17
|
end
|
@@ -58,10 +56,6 @@ module CodewarsApi
|
|
58
56
|
@response.to_h['summary'].andand['errors']
|
59
57
|
end
|
60
58
|
|
61
|
-
def reason
|
62
|
-
@response.to_h['reason']
|
63
|
-
end
|
64
|
-
|
65
59
|
def output
|
66
60
|
@response.to_h['output']
|
67
61
|
end
|
@@ -73,9 +67,5 @@ module CodewarsApi
|
|
73
67
|
def status_code
|
74
68
|
@response.to_h['status_code']
|
75
69
|
end
|
76
|
-
|
77
|
-
def to_h
|
78
|
-
@response.to_h
|
79
|
-
end
|
80
70
|
end
|
81
71
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class FinalizeSolution
|
3
|
+
include Common
|
4
|
+
|
3
5
|
def initialize(options)
|
4
6
|
api_key = options.delete!(:api_key)
|
5
7
|
project_id = options.delete!(:project_id)
|
@@ -14,13 +16,5 @@ module CodewarsApi
|
|
14
16
|
request_options
|
15
17
|
)
|
16
18
|
end
|
17
|
-
|
18
|
-
def success
|
19
|
-
@response.to_h['success']
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_h
|
23
|
-
@response.to_h
|
24
|
-
end
|
25
19
|
end
|
26
20
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class KataInfo
|
3
|
+
include Common
|
4
|
+
|
3
5
|
def initialize(id)
|
4
6
|
@response = RequestHelper.get("#{CodewarsApi::API_URL}/code-challenges/#{id}")
|
5
7
|
end
|
@@ -95,9 +97,5 @@ module CodewarsApi
|
|
95
97
|
def unresolved_suggestions
|
96
98
|
@response.to_h['unresolved'].andand['suggestions']
|
97
99
|
end
|
98
|
-
|
99
|
-
def to_h
|
100
|
-
@response.to_h
|
101
|
-
end
|
102
100
|
end
|
103
101
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class TrainNextKata
|
3
|
+
include Common
|
4
|
+
|
3
5
|
def initialize(options)
|
4
6
|
api_key = options.delete!(:api_key)
|
5
7
|
language = options.delete!(:language)
|
@@ -14,10 +16,6 @@ module CodewarsApi
|
|
14
16
|
)
|
15
17
|
end
|
16
18
|
|
17
|
-
def success
|
18
|
-
@response.to_h['success']
|
19
|
-
end
|
20
|
-
|
21
19
|
def name
|
22
20
|
@response.to_h['name']
|
23
21
|
end
|
@@ -69,9 +67,5 @@ module CodewarsApi
|
|
69
67
|
def code
|
70
68
|
@response.to_h['session'].andand['code']
|
71
69
|
end
|
72
|
-
|
73
|
-
def to_h
|
74
|
-
@response.to_h
|
75
|
-
end
|
76
70
|
end
|
77
71
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class TrainSpecificKata
|
3
|
+
include Common
|
4
|
+
|
3
5
|
def initialize(options)
|
4
6
|
api_key = options.delete!(:api_key)
|
5
7
|
language = options.delete!(:language)
|
@@ -14,10 +16,6 @@ module CodewarsApi
|
|
14
16
|
)
|
15
17
|
end
|
16
18
|
|
17
|
-
def success
|
18
|
-
@response.to_h['success']
|
19
|
-
end
|
20
|
-
|
21
19
|
def name
|
22
20
|
@response.to_h['name']
|
23
21
|
end
|
@@ -69,9 +67,5 @@ module CodewarsApi
|
|
69
67
|
def recently_attempted
|
70
68
|
@response.to_h['session'].andand['recentlyAttempted']
|
71
69
|
end
|
72
|
-
|
73
|
-
def to_h
|
74
|
-
@response.to_h
|
75
|
-
end
|
76
70
|
end
|
77
71
|
end
|
data/lib/codewars_api/user.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module CodewarsApi
|
2
2
|
class User
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
include Common
|
4
|
+
|
5
|
+
def initialize(id_or_username)
|
6
|
+
fail 'Username or id is not set' unless id_or_username
|
7
|
+
@response = RequestHelper.get("#{CodewarsApi::API_URL}/users/#{id_or_username}")
|
6
8
|
end
|
7
9
|
|
8
10
|
def username
|
@@ -44,9 +46,5 @@ module CodewarsApi
|
|
44
46
|
def katas_completed
|
45
47
|
@response.to_h['codeChallenges'].andand['totalCompleted']
|
46
48
|
end
|
47
|
-
|
48
|
-
def to_h
|
49
|
-
@response.to_h
|
50
|
-
end
|
51
49
|
end
|
52
50
|
end
|
data/lib/codewars_api/version.rb
CHANGED
data/lib/codewars_api.rb
CHANGED
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
|
+
version: 0.2.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: 2015-11-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/codewars_api.rb
|
199
199
|
- lib/codewars_api/attempt_solution.rb
|
200
200
|
- lib/codewars_api/client.rb
|
201
|
+
- lib/codewars_api/common.rb
|
201
202
|
- lib/codewars_api/deferred_response.rb
|
202
203
|
- lib/codewars_api/finalize_solution.rb
|
203
204
|
- lib/codewars_api/kata_info.rb
|