zombie_battleground-api 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 +62 -0
- data/.rspec +3 -0
- data/.rubocop.yml +21 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +33 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +85 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +16 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +4 -0
- data/lib/zombie_battleground/api/client.rb +114 -0
- data/lib/zombie_battleground/api/errors.rb +24 -0
- data/lib/zombie_battleground/api/models/card.rb +46 -0
- data/lib/zombie_battleground/api/models/deck.rb +65 -0
- data/lib/zombie_battleground/api/models/match.rb +47 -0
- data/lib/zombie_battleground/api/models/simple_card.rb +27 -0
- data/lib/zombie_battleground/api/requests/get_card_request.rb +27 -0
- data/lib/zombie_battleground/api/requests/get_cards_request.rb +40 -0
- data/lib/zombie_battleground/api/requests/get_deck_request.rb +30 -0
- data/lib/zombie_battleground/api/requests/get_decks_request.rb +36 -0
- data/lib/zombie_battleground/api/requests/get_match_request.rb +30 -0
- data/lib/zombie_battleground/api/requests/get_matches_request.rb +34 -0
- data/lib/zombie_battleground/api/requests/request_helper.rb +20 -0
- data/lib/zombie_battleground/api/responses/get_card_response.rb +38 -0
- data/lib/zombie_battleground/api/responses/get_cards_response.rb +54 -0
- data/lib/zombie_battleground/api/responses/get_deck_response.rb +38 -0
- data/lib/zombie_battleground/api/responses/get_decks_response.rb +54 -0
- data/lib/zombie_battleground/api/responses/get_match_response.rb +38 -0
- data/lib/zombie_battleground/api/responses/get_matches_response.rb +54 -0
- data/lib/zombie_battleground/api/responses/response_helper.rb +28 -0
- data/lib/zombie_battleground/api/validation_helper.rb +347 -0
- data/lib/zombie_battleground/api/version.rb +7 -0
- data/lib/zombie_battleground/api.rb +40 -0
- data/zombie_battleground-api.gemspec +40 -0
- metadata +196 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b70c3c3d5dbcf87bd3104d85db5a99cdaefa0224cb6e3441a956cd7ade8290a
|
4
|
+
data.tar.gz: 214cbe7b928a264a1c55e80f99f6ad9096058a88addc89a28dfbe209007850be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c4f80e80f1c4f463185f9d189ede2914bb41175fd9343e5d9ee82992c318c679c76fd1b8ac06887eeafc8df8159638b3ca431fd4687a0b2a42409591872fd8f
|
7
|
+
data.tar.gz: c49ecc117373b8f15b526242c12201a0fb48f0032815105dd6504ea00453948380e20209907302869dd287c3ac513dab6d422e7c0be75709e28ad775fce5e482
|
data/.gitignore
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
=======
|
52
|
+
/.bundle/
|
53
|
+
/.yardoc
|
54
|
+
/_yardoc/
|
55
|
+
/coverage/
|
56
|
+
/doc/
|
57
|
+
/pkg/
|
58
|
+
/spec/reports/
|
59
|
+
/tmp/
|
60
|
+
|
61
|
+
# rspec failure tracking
|
62
|
+
.rspec_status
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.3
|
5
|
+
|
6
|
+
Metrics/LineLength:
|
7
|
+
Max: 120
|
8
|
+
|
9
|
+
Metrics/BlockLength:
|
10
|
+
Exclude:
|
11
|
+
- '*.gemspec'
|
12
|
+
- '**/*_spec.rb'
|
13
|
+
|
14
|
+
Metrics/ModuleLength:
|
15
|
+
Max: 300
|
16
|
+
|
17
|
+
Metrics/AbcSize:
|
18
|
+
Max: 20
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Max: 20
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at watmin@watministrator.net. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
FROM ruby:2.5.1-stretch
|
2
|
+
|
3
|
+
# setup packages
|
4
|
+
ENV DEBIAN_FRONTEND noninteractive
|
5
|
+
RUN apt-get -y update && \
|
6
|
+
apt-get -y install \
|
7
|
+
bash \
|
8
|
+
locales \
|
9
|
+
tmux \
|
10
|
+
vim \
|
11
|
+
jq
|
12
|
+
|
13
|
+
# setup locales
|
14
|
+
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
|
15
|
+
RUN locale-gen en_US.UTF-8
|
16
|
+
ENV LANG en_US.UTF-8
|
17
|
+
ENV LANGUAGE en_US:en
|
18
|
+
ENV LC_ALL en_US.UTF-8
|
19
|
+
|
20
|
+
# setup bundler
|
21
|
+
ENV RUBYLIB /app/lib:$RUBYLIB
|
22
|
+
ENV PATH /app/bin:$PATH
|
23
|
+
WORKDIR /app
|
24
|
+
COPY Gemfile* *.gemspec /app/
|
25
|
+
COPY lib/zombie_battleground/api/version.rb /app/lib/zombie_battleground/api/version.rb
|
26
|
+
COPY bin/setup /app/bin/setup
|
27
|
+
RUN setup
|
28
|
+
|
29
|
+
# setup api
|
30
|
+
COPY . /app/
|
31
|
+
|
32
|
+
# entry point
|
33
|
+
CMD ["console"]
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
zombie_battleground-api (0.1.0)
|
5
|
+
activerecord
|
6
|
+
faraday
|
7
|
+
json
|
8
|
+
pry
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activemodel (5.2.1)
|
14
|
+
activesupport (= 5.2.1)
|
15
|
+
activerecord (5.2.1)
|
16
|
+
activemodel (= 5.2.1)
|
17
|
+
activesupport (= 5.2.1)
|
18
|
+
arel (>= 9.0)
|
19
|
+
activesupport (5.2.1)
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
+
i18n (>= 0.7, < 2)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
arel (9.0.0)
|
25
|
+
ast (2.4.0)
|
26
|
+
coderay (1.1.2)
|
27
|
+
concurrent-ruby (1.0.5)
|
28
|
+
diff-lcs (1.3)
|
29
|
+
faraday (0.15.4)
|
30
|
+
multipart-post (>= 1.2, < 3)
|
31
|
+
i18n (1.1.1)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
jaro_winkler (1.5.1)
|
34
|
+
json (2.1.0)
|
35
|
+
method_source (0.9.0)
|
36
|
+
minitest (5.11.3)
|
37
|
+
multipart-post (2.0.0)
|
38
|
+
parallel (1.12.1)
|
39
|
+
parser (2.5.1.0)
|
40
|
+
ast (~> 2.4.0)
|
41
|
+
powerpack (0.1.2)
|
42
|
+
pry (0.12.0)
|
43
|
+
coderay (~> 1.1.0)
|
44
|
+
method_source (~> 0.9.0)
|
45
|
+
rainbow (3.0.0)
|
46
|
+
rake (10.5.0)
|
47
|
+
rspec (3.8.0)
|
48
|
+
rspec-core (~> 3.8.0)
|
49
|
+
rspec-expectations (~> 3.8.0)
|
50
|
+
rspec-mocks (~> 3.8.0)
|
51
|
+
rspec-core (3.8.0)
|
52
|
+
rspec-support (~> 3.8.0)
|
53
|
+
rspec-expectations (3.8.2)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.8.0)
|
56
|
+
rspec-mocks (3.8.0)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.8.0)
|
59
|
+
rspec-support (3.8.0)
|
60
|
+
rubocop (0.57.2)
|
61
|
+
jaro_winkler (~> 1.5.1)
|
62
|
+
parallel (~> 1.10)
|
63
|
+
parser (>= 2.5)
|
64
|
+
powerpack (~> 0.1)
|
65
|
+
rainbow (>= 2.2.2, < 4.0)
|
66
|
+
ruby-progressbar (~> 1.7)
|
67
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
68
|
+
ruby-progressbar (1.9.0)
|
69
|
+
thread_safe (0.3.6)
|
70
|
+
tzinfo (1.2.5)
|
71
|
+
thread_safe (~> 0.1)
|
72
|
+
unicode-display_width (1.4.0)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
bundler (~> 1.16)
|
79
|
+
rake (~> 10.0)
|
80
|
+
rspec (~> 3.0)
|
81
|
+
rubocop
|
82
|
+
zombie_battleground-api!
|
83
|
+
|
84
|
+
BUNDLED WITH
|
85
|
+
1.16.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 John Shields
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 John Shields
|
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,57 @@
|
|
1
|
+
# ZombieBattleground::Api
|
2
|
+
|
3
|
+
Ruby implementation of the Public API for Zombie Battleground
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'zombie_battleground-api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install zombie_battleground-api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Use the singleton class `ZombieBattleground::Api`
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ZombieBattleground::Api.decks(limit: 1)
|
27
|
+
# => ZombieBattleground::Api::GetDecksResponse
|
28
|
+
```
|
29
|
+
|
30
|
+
Use the API client directly
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
client = ZombieBattleground::Api::Client.new
|
34
|
+
client.decks(limit: 1) # => ZombieBattleground::Api::GetDecksResponse
|
35
|
+
```
|
36
|
+
|
37
|
+
Every API call returns a response object that contains a complete modeled Ruby object of the response. See the API documentation (once I write it) on rubygems.org
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
You can also execute `docker-compose build && docker-compose run zombie_battleground-api` to run within a Docker container that drops into a Pry session to experiment with (this is how I have developed this gem).
|
44
|
+
|
45
|
+
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).
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/watmin/zombie_battleground-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
54
|
+
|
55
|
+
## Code of Conduct
|
56
|
+
|
57
|
+
Everyone interacting in the ZombieBattleground::Api project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/watmin/zombie_battleground-api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
task default: :spec
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
11
|
+
task.options = ['--display-cop-names']
|
12
|
+
end
|
13
|
+
|
14
|
+
task default: :rubocop
|
15
|
+
|
16
|
+
task build: %i[spec rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'zombie_battleground/api'
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
require 'pry'
|
12
|
+
Pry.start
|