codewars_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +252 -0
- data/Rakefile +6 -0
- data/bin/console +19 -0
- data/bin/setup +7 -0
- data/codewars_client.gemspec +30 -0
- data/config/secrets.example.yml +1 -0
- data/lib/codewars_client.rb +59 -0
- data/lib/codewars_client/attempt_solution.rb +11 -0
- data/lib/codewars_client/client.rb +35 -0
- data/lib/codewars_client/configuration.rb +16 -0
- data/lib/codewars_client/deferred_response.rb +12 -0
- data/lib/codewars_client/finalize.rb +11 -0
- data/lib/codewars_client/next_kata.rb +12 -0
- data/lib/codewars_client/object_builder.rb +39 -0
- data/lib/codewars_client/user.rb +12 -0
- data/lib/codewars_client/version.rb +3 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ff9541500bfc61638385d9e2010d8fb36849ecfe
|
4
|
+
data.tar.gz: de43d5cb962ab2a6eb8413e8364fb11e1f7a46db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a985134a455432475598a36659db4eb8f54e1f5d1dbbabb43de1a5538ec8b4d603ef24c47a3a53815192b12e7809be14623258bf81a3b25defd64d08279f15e1
|
7
|
+
data.tar.gz: ece055184af36e895fd0ccbf1a781515845fa32e7b742c5d321d42333cff26dce2622b112fa80ba19c6414e9fecb179de82af9f6142568230c11de785fe37a27
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 GustavoCaso
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
# CodewarsClient
|
2
|
+
|
3
|
+
Simple Wrapper for the [Codewars](http://www.codewars.com/) site, where you can improve your coding skills by completing Katas.
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'codewars_client'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install codewars_client
|
19
|
+
|
20
|
+
## Configuration
|
21
|
+
To use this gem you have to have an account with [Codewars](http://www.codewars.com/).
|
22
|
+
|
23
|
+
Then get the Api key from the profile settings and added to the gem.
|
24
|
+
|
25
|
+
There are to ways of configuration.
|
26
|
+
|
27
|
+
1- Block
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
CodewarsClient.configure do |config|
|
31
|
+
config.api_key = API_KEY
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
2- Inline
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
CodewarsClient.api_key = API_KEY
|
39
|
+
```
|
40
|
+
|
41
|
+
## Endpoints
|
42
|
+
|
43
|
+
### User
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
CodewarsClient.user(username_or_id: USERNAME_OR_ID)
|
47
|
+
```
|
48
|
+
|
49
|
+
It will return a `CodewarsClient::User` object with all the information of the user.
|
50
|
+
|
51
|
+
```json
|
52
|
+
{
|
53
|
+
"username": "some_user",
|
54
|
+
"name": "Some Person",
|
55
|
+
"honor": 544,
|
56
|
+
"clan": "some clan",
|
57
|
+
"leaderboardPosition": 134,
|
58
|
+
"skills": [
|
59
|
+
"ruby",
|
60
|
+
"c#",
|
61
|
+
".net",
|
62
|
+
"javascript",
|
63
|
+
"coffeescript",
|
64
|
+
"nodejs",
|
65
|
+
"rails"
|
66
|
+
],
|
67
|
+
"ranks": {
|
68
|
+
"overall": {
|
69
|
+
"rank": -3,
|
70
|
+
"name": "3 kyu",
|
71
|
+
"color": "blue",
|
72
|
+
"score": 2116
|
73
|
+
},
|
74
|
+
"languages": {
|
75
|
+
"javascript": {
|
76
|
+
"rank": -3,
|
77
|
+
"name": "3 kyu",
|
78
|
+
"color": "blue",
|
79
|
+
"score": 1819
|
80
|
+
},
|
81
|
+
"ruby": {
|
82
|
+
"rank": -4,
|
83
|
+
"name": "4 kyu",
|
84
|
+
"color": "blue",
|
85
|
+
"score": 1005
|
86
|
+
},
|
87
|
+
"coffeescript": {
|
88
|
+
"rank": -4,
|
89
|
+
"name": "4 kyu",
|
90
|
+
"color": "blue",
|
91
|
+
"score": 870
|
92
|
+
}
|
93
|
+
}
|
94
|
+
},
|
95
|
+
"codeChallenges": {
|
96
|
+
"totalAuthored": 3,
|
97
|
+
"totalCompleted": 230
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
### Next Kata
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
CodewarsClient.next_kata(language: LANGUAGE)
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Valid languages
|
110
|
+
|
111
|
+
```
|
112
|
+
clojure
|
113
|
+
coffescript
|
114
|
+
c
|
115
|
+
haskell
|
116
|
+
java
|
117
|
+
javascript
|
118
|
+
python
|
119
|
+
ruby
|
120
|
+
```
|
121
|
+
|
122
|
+
It accept language as `symbol` and `string`
|
123
|
+
|
124
|
+
It will return a `CodewarsClient::NextKata` object with all the information of the kata and start a new training session.
|
125
|
+
|
126
|
+
```json
|
127
|
+
{
|
128
|
+
"success":true,
|
129
|
+
"name":"Anything to integer",
|
130
|
+
"slug":"anything-to-integer",
|
131
|
+
"description":"Your task is to program a function which converts any input to an integer.\n\nDo not perform rounding, the fractional part should simply be discarded.\n\nIf converting the input to an integer does not make sense (with an object, for instance), the function should return 0 (zero).\n\nAlso, Math.floor(), parseInt() and parseFloat() are disabled for your unconvenience.\n\nOnegaishimasu!",
|
132
|
+
"author":"Jake Hoffner",
|
133
|
+
"rank":-6,
|
134
|
+
"averageCompletion":125.4,
|
135
|
+
"tags":[
|
136
|
+
"Fundamentals",
|
137
|
+
"Integers",
|
138
|
+
"Data Types",
|
139
|
+
"Numbers"
|
140
|
+
],
|
141
|
+
"session":{
|
142
|
+
"projectId":"523f66fba0de5d94410001cb",
|
143
|
+
"solutionId":"53bc968d35fd2feefd000013",
|
144
|
+
"setup":"function toInteger(n) {\n \n}",
|
145
|
+
"exampleFixture":"Test.expect(toInteger(\"4.55\") === 4)",
|
146
|
+
"code":null
|
147
|
+
}
|
148
|
+
}
|
149
|
+
```
|
150
|
+
|
151
|
+
### Attemp Solution
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
CodewarsClient.attempt_solution(kata: NEXT_KATA_OBJECT , code: YOUR_CODE)
|
155
|
+
```
|
156
|
+
|
157
|
+
The `NEXT_KATA_OBJECT` could be any kind of object at least it has te respond to `solution_id` and `project_id` and return valid data related with the kata.
|
158
|
+
|
159
|
+
Will submit a solution to be validated, this will return a deferred message id (dmid) which will be use to poll for the response.
|
160
|
+
|
161
|
+
```json
|
162
|
+
{
|
163
|
+
"success":true,
|
164
|
+
"dmid":"4rsdaDf8d"
|
165
|
+
}
|
166
|
+
```
|
167
|
+
|
168
|
+
### Deferred Response
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
CodewarsClient.deferred_response(dmid: DMID)
|
172
|
+
```
|
173
|
+
|
174
|
+
This is use for polling the response from the server. It will return a `CodewarsClient::DeferredResponse` object with al the information.
|
175
|
+
|
176
|
+
```json
|
177
|
+
{
|
178
|
+
"success":true,
|
179
|
+
"dmid":"4rsdaDf8d",
|
180
|
+
"valid": false,
|
181
|
+
"reason":"-e: Value is not what was expected (Test::Error)\n",
|
182
|
+
"output":[
|
183
|
+
"<div class='console-failed'>Value is not what was expected</div>"
|
184
|
+
],
|
185
|
+
"wall_time":45
|
186
|
+
}
|
187
|
+
```
|
188
|
+
|
189
|
+
### Finalize Solution
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
CodewarsClient.finalize(kata: NEXT_KATA_OBJECT)
|
193
|
+
```
|
194
|
+
|
195
|
+
The `NEXT_KATA_OBJECT` could be any kind of object at least it has te respond to `solution_id` and `project_id` and return valid data related with the kata.
|
196
|
+
|
197
|
+
This endpoint is used to finalize the previously submitted solution. This endpoint will only return a success message if there has been a previously successful solution.
|
198
|
+
|
199
|
+
```json
|
200
|
+
{
|
201
|
+
"success":true
|
202
|
+
}
|
203
|
+
```
|
204
|
+
|
205
|
+
## Practical Example
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
CodewarsClient.api_key = 'fake_api_key'
|
209
|
+
|
210
|
+
def client
|
211
|
+
CodewarsClient
|
212
|
+
end
|
213
|
+
|
214
|
+
kata = client.next_kata(language: :ruby)
|
215
|
+
|
216
|
+
# Read the kata information and complete it with some code !!!
|
217
|
+
|
218
|
+
code = File.read('./solution.rb')
|
219
|
+
|
220
|
+
attempt_solution = client.attempt_solution(kata: kata, code: code)
|
221
|
+
|
222
|
+
10.times do
|
223
|
+
deferred_response = client.deferred_response(dmid: attempt_solution.dmid)
|
224
|
+
break if deferred_response.success
|
225
|
+
end
|
226
|
+
|
227
|
+
if deferred_response.valid
|
228
|
+
client.finalize_solution(kata: kata)
|
229
|
+
else
|
230
|
+
warn deferred_response.reason
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
## Development
|
235
|
+
|
236
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
237
|
+
|
238
|
+
To been able to run the test or to use the api with the interactive prompt you will have to create a `secrest.yml` file inside the `config` folder and store a valid api_key. `api_key: VALID_API_KEY`
|
239
|
+
|
240
|
+
Then, run `rake spec` to run the tests. Run `bin/console` for an interactive prompt that will allow you to experiment.
|
241
|
+
|
242
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
243
|
+
|
244
|
+
## Contributing
|
245
|
+
|
246
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/GustavoCaso/codewars_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
247
|
+
|
248
|
+
|
249
|
+
## License
|
250
|
+
|
251
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
252
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'yaml'
|
3
|
+
require "bundler/setup"
|
4
|
+
require "codewars_client"
|
5
|
+
|
6
|
+
config_file = YAML.load(File.read(File.expand_path('../../config/secrets.yml', __FILE__)))
|
7
|
+
CodewarsClient.configure do |config|
|
8
|
+
config.api_key = config_file['api_key']
|
9
|
+
end
|
10
|
+
|
11
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
12
|
+
# with your gem easier. You can also use a different console, if you like.
|
13
|
+
|
14
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
15
|
+
require "pry"
|
16
|
+
Pry.start
|
17
|
+
|
18
|
+
# require "irb"
|
19
|
+
# IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'codewars_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "codewars_client"
|
8
|
+
spec.version = CodewarsClient::VERSION
|
9
|
+
spec.authors = ["GustavoCaso"]
|
10
|
+
spec.email = ["gustavocaso@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Codewars API Wrapper made with ruby}
|
13
|
+
spec.description = %q{Codewars API Wrapper made with ruby}
|
14
|
+
spec.homepage = "https://github.com/GustavoCaso/codewars_client"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "webmock"
|
27
|
+
spec.add_development_dependency "vcr"
|
28
|
+
|
29
|
+
spec.add_runtime_dependency "faraday"
|
30
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
api_key:
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "codewars_client/finalize"
|
2
|
+
require "codewars_client/deferred_response"
|
3
|
+
require "codewars_client/attempt_solution"
|
4
|
+
require "codewars_client/next_kata"
|
5
|
+
require "codewars_client/user"
|
6
|
+
require "codewars_client/client"
|
7
|
+
require "codewars_client/configuration"
|
8
|
+
require "codewars_client/version"
|
9
|
+
require 'json'
|
10
|
+
|
11
|
+
module CodewarsClient
|
12
|
+
class InvalidLanguageSelection < StandardError; end
|
13
|
+
extend Configuration
|
14
|
+
extend Client
|
15
|
+
|
16
|
+
VALID_LANGUAGES = [
|
17
|
+
:clojure, :coffescript, :c, :haskell, :java, :javascript, :python, :ruby
|
18
|
+
]
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def user(username_or_id:)
|
22
|
+
status, response = get(path: User::PATH, params: username_or_id)
|
23
|
+
User.new(data: _parse_response(status, response))
|
24
|
+
end
|
25
|
+
|
26
|
+
def next_kata(language:)
|
27
|
+
fail InvalidLanguageSelection unless VALID_LANGUAGES.include?(language.to_sym)
|
28
|
+
status, response = post(path: NextKata::PATH, params: [language.to_s, 'train'])
|
29
|
+
NextKata.new(data: _parse_response(status, response))
|
30
|
+
end
|
31
|
+
|
32
|
+
def attemp_solution(kata:, code:)
|
33
|
+
status, response = post(path: NextKata::PATH,
|
34
|
+
params: ['projects', kata.project_id, 'solutions', kata.solution_id, 'attempt'],
|
35
|
+
body: code
|
36
|
+
)
|
37
|
+
AttemptSolution.new(data: _parse_response(status, response))
|
38
|
+
end
|
39
|
+
|
40
|
+
def deferred_response(dmid:)
|
41
|
+
status, response = get(path: DeferredResponse::PATH, params: dmid)
|
42
|
+
DeferredResponse.new(data: _parse_response(status, response))
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def finalize(kata:)
|
47
|
+
status, response = post(path: NextKata::PATH,
|
48
|
+
params: ['projects', kata.project_id, 'solutions', kata.solution_id, 'finalize']
|
49
|
+
)
|
50
|
+
Finalize.new(data: _parse_response(status, response))
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def _parse_response(status, response)
|
56
|
+
JSON.parse(response).merge({'status' => status})
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
module CodewarsClient
|
3
|
+
module Client
|
4
|
+
PUBLIC_METHODS = [:get, :post]
|
5
|
+
class ApiKeyMissingError < StandardError; end
|
6
|
+
|
7
|
+
PUBLIC_METHODS.each do |method|
|
8
|
+
define_method(method) do |path:, params:, body: nil|
|
9
|
+
fail ApiKeyMissingError.new(api_key_message) if CodewarsClient.api_key.nil?
|
10
|
+
response = request method: method, path: path, params: params, body: body
|
11
|
+
[response.status, response.body]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def conn
|
17
|
+
Faraday.new(url: CodewarsClient::Configuration::DEFAULT_ENDPOINT) do |c|
|
18
|
+
c.request :url_encoded
|
19
|
+
c.adapter Faraday.default_adapter
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def request(method:, path:, params:, body:)
|
24
|
+
conn.send(method) do |req|
|
25
|
+
req.url File.join(path, params)
|
26
|
+
req.headers['Authorization'] = CodewarsClient.api_key
|
27
|
+
req.body = { code: body } unless body.nil?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def api_key_message
|
32
|
+
'Please set up your api key'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module CodewarsClient
|
2
|
+
module Configuration
|
3
|
+
PUBLIC_METHODS = [:api_key]
|
4
|
+
|
5
|
+
API_VERSION = 'v1'
|
6
|
+
DEFAULT_ENDPOINT = "https://www.codewars.com/api/#{API_VERSION}"
|
7
|
+
|
8
|
+
API_KEY_DEFAULT = nil
|
9
|
+
|
10
|
+
attr_accessor *PUBLIC_METHODS
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module CodewarsClient
|
2
|
+
module ObjectBuilder
|
3
|
+
def _build_object(data)
|
4
|
+
data.each do |key, value|
|
5
|
+
if value.is_a? Hash
|
6
|
+
_build_methods(value)
|
7
|
+
else
|
8
|
+
_mount_values_and_methods(key, value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def _build_methods(values)
|
14
|
+
values.each do |key, value|
|
15
|
+
_mount_values_and_methods(key, value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def _mount_values_and_methods(key, value)
|
20
|
+
new_key = _underscore_key(key)
|
21
|
+
_build_attr_reader(new_key)
|
22
|
+
_set_attr_value(new_key, value)
|
23
|
+
end
|
24
|
+
|
25
|
+
def _build_attr_reader(key)
|
26
|
+
self.class.instance_eval("attr_reader :#{key}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def _set_attr_value(key, value)
|
30
|
+
instance_variable_set("@#{key}", value)
|
31
|
+
end
|
32
|
+
|
33
|
+
def _underscore_key(key)
|
34
|
+
match = key.match(/^([a-z]*)([A-Z].*)/)
|
35
|
+
return key unless match
|
36
|
+
"#{match[1]}_#{match[2].downcase}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codewars_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- GustavoCaso
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Codewars API Wrapper made with ruby
|
112
|
+
email:
|
113
|
+
- gustavocaso@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- codewars_client.gemspec
|
129
|
+
- config/secrets.example.yml
|
130
|
+
- lib/codewars_client.rb
|
131
|
+
- lib/codewars_client/attempt_solution.rb
|
132
|
+
- lib/codewars_client/client.rb
|
133
|
+
- lib/codewars_client/configuration.rb
|
134
|
+
- lib/codewars_client/deferred_response.rb
|
135
|
+
- lib/codewars_client/finalize.rb
|
136
|
+
- lib/codewars_client/next_kata.rb
|
137
|
+
- lib/codewars_client/object_builder.rb
|
138
|
+
- lib/codewars_client/user.rb
|
139
|
+
- lib/codewars_client/version.rb
|
140
|
+
homepage: https://github.com/GustavoCaso/codewars_client
|
141
|
+
licenses:
|
142
|
+
- MIT
|
143
|
+
metadata: {}
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 2.4.6
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: Codewars API Wrapper made with ruby
|
164
|
+
test_files: []
|