poke-api-v2 0.1.0 → 0.1.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
- SHA1:
3
- metadata.gz: 55982a103820663bbb2d0652e8a8e9da58636822
4
- data.tar.gz: cf6ee064ea3d3805a35f7ad20610a3664aa5bb48
2
+ SHA256:
3
+ metadata.gz: 32eb66cbf128d30fe3c198c47433bcdd374504ad4255896570465a51e5be6f30
4
+ data.tar.gz: f54706d6914fcf814a1b75c2ff82d3c7775819749310aa1ab3ed614152b35c8d
5
5
  SHA512:
6
- metadata.gz: 5b1eba96ccc46ed87a8ffda8642b85397b7826ff2ebe3bd53e122d7f57ee6314e4d1dc6a199eed014822f75e43ecb1363236db16e8f93790b7be37e9e91efad7
7
- data.tar.gz: de867553cc0bda3b6d61661862d875a2f284c37a58e7491d8052be62fecfd026834dd063885f38835d0591800a513f3d327ef5ba0373457b03474ec2fd64051c
6
+ metadata.gz: d5aa6be36c56d673a3d16a0b64b40c85f113f9268ca27c413a09f9ecfaba61725a3c535612f381438afff9a991be1085697e1a3548c532c8099ecd021e5c3a77
7
+ data.tar.gz: bde6b63c375efc7da980c665122091f573b4ab89df007171015c598479a737104d58177e0a7773787fa32f5a0281eb3fbc562b61ad2fc14de6f8309c7e0d18cc
@@ -0,0 +1,65 @@
1
+ # Contributing
2
+
3
+ Thank you for your interest in contributing! We welcome developers of all skill levels to contribute to Poke-Api-V2 and will provide issues for those new to open-source and veterans alike. All tasks that we are looking to complete can be found in the [Issues](https://github.com/rdavid1099/poke-api-v2/issues) section. If you find a bug or would like to implement new functionality, please feel free to open an issue or contact the owner directly at [rdavid1099@gmail.com](mailto:rdavid1099@gmail.com).
4
+
5
+ ## Installation
6
+
7
+ - Fork and clone Poke-Api-V2 to your local machine, use [this guide](https://help.github.com/articles/fork-a-repo/) if you don't know how to do that.
8
+ - Set the upstream remote so you can keep your copy of Poke-Api-V2 synced with the original. To do that go to your terminal and `cd` into your cloned `poke-api-v2` directory. Then user one of the following commands:
9
+
10
+ If you have ssh set up with Git
11
+ ```
12
+ $ git remote add upstream git@github.com:rdavid1099/poke-api-v2.git
13
+ ```
14
+ Otherwise
15
+ ```
16
+ $ git remote add upstream https://github.com/rdavid1099/poke-api-v2.git
17
+ ```
18
+
19
+ - From the root directory run `bundle install` to install all gem dependencies.
20
+ - Run `rake` to run all tests.
21
+
22
+ ## Code Style
23
+
24
+ While we encourage creativity and clever, performant code, your implementation must follow basic Ruby standards and practices. This project is wired with CodeClimate, Rubocop and Reek. All PRs must pass these checks to be merged into production. As a rule of thumb, all contributors are encouraged to:
25
+
26
+ - Write readable and succinct code, and use standard functions in Ruby to the best of your knowledge.
27
+ - Blank lines should contain no spaces, and there should be no additional white space following the end of a line of code.
28
+ - Follow the [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principle.
29
+ - Run `reek` and `rubocop` before committing any work.
30
+ - Have fun!
31
+
32
+ If you are familiar with and use git hooks, we strongly encourage you to add the following block of code to your project's `pre-commit` hook. You can learn more about git hooks [here](https://githooks.com/).
33
+
34
+ ```
35
+ EXIT=0
36
+
37
+ FILES=$(git diff --name-only HEAD)
38
+
39
+ rubocop $(echo $FILES) --force-exclusion
40
+ EXIT1=$?
41
+ reek $(echo $FILES)
42
+ EXIT2=$?
43
+
44
+ [ $EXIT1 -gt 0 -o $EXIT2 -gt 0 ] && EXIT=1
45
+
46
+ [ $EXIT -eq 1 ] && echo 'Unable to commit. Fix issues above.'
47
+
48
+ exit $EXIT
49
+ ```
50
+
51
+ ## Testing
52
+
53
+ Tests are imperative to creating a functional and successful application. We strive to have 100% test coverage across the codebase. Our test suite uses [RSpec](http://rspec.info/documentation/) and should follow basic RSpec formatting and style. All features/ bugs must include coinciding tests to confirm their functionality.
54
+
55
+ ### Running Tests
56
+
57
+ Run `rake` or `rspec` to run all tests in test suite.
58
+
59
+ ## Documentation
60
+
61
+ We are in the process of adding documentation using `YARD`. Please stay tuned for updates when that is ready.
62
+
63
+ ## Pull Requests
64
+
65
+ All branches should be based off the `dev` branch and written using the following format, `<labe>/<issue number>-<summary of issue>` (ex: `chore/142-add-yard-for-documentation`). Before submitting a pull request, run `rake` in the top-level directory to verify that all tests are passing. Make your pull request to `dev` unless stated otherwise in the issue tracker. We will check for new pull requests at the end of every day and review/ comment on them as necessary.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- poke-api-v2 (0.1.0)
4
+ poke-api-v2 (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -28,7 +28,7 @@ GEM
28
28
  hashdiff (0.3.8)
29
29
  ice_nine (0.11.2)
30
30
  jaro_winkler (1.5.2)
31
- json (2.2.0)
31
+ json (2.3.1)
32
32
  kwalify (0.7.2)
33
33
  method_source (0.9.2)
34
34
  parallel (1.17.0)
@@ -41,7 +41,7 @@ GEM
41
41
  psych (3.1.0)
42
42
  public_suffix (3.0.3)
43
43
  rainbow (3.0.0)
44
- rake (10.5.0)
44
+ rake (13.0.1)
45
45
  rb-readline (0.5.5)
46
46
  reek (5.0.2)
47
47
  codeclimate-engine-rb (~> 0.4.0)
@@ -97,7 +97,7 @@ DEPENDENCIES
97
97
  bundler (~> 2.0)
98
98
  poke-api-v2!
99
99
  pry
100
- rake (~> 10.0)
100
+ rake (~> 13.0)
101
101
  rb-readline
102
102
  reek (= 5.0.2)
103
103
  rspec (~> 3.0)
@@ -107,4 +107,4 @@ DEPENDENCIES
107
107
  webmock
108
108
 
109
109
  BUNDLED WITH
110
- 2.0.1
110
+ 2.1.4
data/README.md CHANGED
@@ -1,9 +1,139 @@
1
- # Poke::Api::V2
1
+ # Poke-Api-V2
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/poke-api-v2.svg)](https://badge.fury.io/rb/poke-api-v2)
3
4
  [![Build Status](https://semaphoreci.com/api/v1/rworkman1099/poke-api-v2/branches/master/badge.svg)](https://semaphoreci.com/rworkman1099/poke-api-v2)
4
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/1f0142f320ea41ce5fed/maintainability)](https://codeclimate.com/github/rdavid1099/poke-api-v2/maintainability)
5
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/1f0142f320ea41ce5fed/test_coverage)](https://codeclimate.com/github/rdavid1099/poke-api-v2/test_coverage)
6
7
 
7
- ## Ruby gem wrapping `https://pokeapi.co/api/v2/`.
8
+ A simplified interface for interacting with the [PokéAPI](https://pokeapi.co/docs/v2.html) version 2 - `https://pokeapi.co/api/v2/`
8
9
 
9
- :construction_worker: Under construction...
10
+ ## Requirements
11
+ * Ruby >= 2.0.0
12
+
13
+ Poke-Api-V2 depends on these other gems for usage at runtime:
14
+ * [net/http] consumes the [PokéAPI](https://pokeapi.co/docs/v2.html)
15
+ * [json] parses the [PokéAPI](https://pokeapi.co/docs/v2.html) response
16
+
17
+ ## Installation
18
+ Add the following line to a Gemfile:
19
+
20
+ gem 'poke-api-v2'
21
+
22
+ and run `bundle install` from your shell.
23
+
24
+ If you use Rubygems, run this command manually from your shell to install the latest poke-api-v2 version:
25
+
26
+ gem install poke-api-v2
27
+
28
+
29
+ ## Usage
30
+ Once the gem is installed simply require it and call any of the 48 endpoints using `PokeApi#get`.
31
+ ```ruby
32
+ require 'poke-api-v2'
33
+
34
+ PokeApi.get(pokemon: 'bulbasaur') # Fetches data from https://pokeapi.co/api/v2/pokemon/bulbasaur/
35
+ # => #<PokeApi::Pokemon:0x007fe36c2cfc70
36
+ # @abilities=
37
+ # [#<PokeApi::Pokemon::PokemonAbility:0x007fe36c2cfba8 @ability=#<PokeApi::Ability:0x007fe36c2cfb80 @name="chlorophyll", @url="https://pokeapi.co/api/v2/ability/34/">, @is_hidden=true, @slot=3>,
38
+ # #<PokeApi::Pokemon::PokemonAbility:0x007fe36c2cf630 @ability=#<PokeApi::Ability:0x007fe36c2cf590 @name="overgrow", @url="https://pokeapi.co/api/v2/ability/65/">, @is_hidden=false, @slot=1>],
39
+ # @base_experience=64,
40
+ # @forms=[#<PokeApi::PokemonForm:0x007fe36c2cee10 @name="bulbasaur", @url="https://pokeapi.co/api/v2/pokemon-form/1/">],
41
+ # @game_indices=
42
+ # [...
43
+
44
+ PokeApi.get(super_contest_effect: 1) # Fetches data from https://pokeapi.co/api/v2/super-contest-effect/1/
45
+ # => #<PokeApi::SuperContestEffect:0x007fe36b1976d8
46
+ # @appeal=2,
47
+ # @flavor_text_entries=
48
+ # [#<PokeApi::Common::FlavorText:0x007fe36b197430
49
+ # @flavor_text="Enables the user to perform first in the next turn.",
50
+ # @language=#<PokeApi::Utility::Language:0x007fe36b197408 @name="en", @url="https://pokeapi.co/api/v2/language/9/">,
51
+ # @version=nil>],
52
+ # @id=1,
53
+ # @moves=
54
+ # [#<PokeApi::Move:0x007fe36b196f30 @name="agility", @url="https://pokeapi.co/api/v2/move/97/">,
55
+ ```
56
+
57
+ Almost all endpoints can be queried by either the name or id in accordance with the [PokéAPI Docs](https://pokeapi.co/docs/v2.html).
58
+
59
+ You can also chain fetches together allowing Poke-Api-V2 to make multiple API calls with one command.
60
+
61
+ ```ruby
62
+ # Call https://pokeapi.co/api/v2/pokedex/2/ -> https://pokeapi.co/api/v2/pokemon-species/1/ -> https://pokeapi.co/api/v2/evolution-chain/1/
63
+ evolution_chain = PokeApi.get(pokedex: 2).pokemon_entries.first.pokemon_species.get.evolution_chain.get
64
+ # => [#<PokeApi::EvolutionChain::ChainLink:0x007fe36c31d718
65
+ # @evolution_details=...
66
+
67
+ evolution_chain.chain.evolves_to.first.species.name
68
+ # => "ivysaur"
69
+ ```
70
+
71
+ The [PokéAPI](https://pokeapi.co/docs/v2.html) also allows you to create lists of paginated endpoints for any resource. This can be achieved in a couple different ways using Poke-Api-V2.
72
+
73
+ First, you can call any endpoint without passing an id or name. This will generate a list of the 20 first resources allowing pagination per 20.
74
+
75
+ ```ruby
76
+ PokeApi.get(:ability)
77
+ # => #<PokeApi::ApiResourceList:0x007fe36c31ce80
78
+ # @count=293,
79
+ # @next_url="https://pokeapi.co/api/v2/ability/?offset=20&limit=20",
80
+ # @previous_url=nil,
81
+ # @results=
82
+ # [#<PokeApi::Ability:0x007fe36c31cd40 @name="stench", @url="https://pokeapi.co/api/v2/ability/1/">,
83
+ # #<PokeApi::Ability:0x007fe36c31c610 @name="drizzle", @url="https://pokeapi.co/api/v2/ability/2/">,
84
+ # #<PokeApi::Ability:0x007fe36c31c250 @name="speed-boost", @url="https://pokeapi.co/api/v2/ability/3/">,
85
+ # #<PokeApi::Ability:0x007fe36b2b7e50 @name="battle-armor", @url="https://pokeapi.co/api/v2/ability/4/">,
86
+ # #<PokeApi::Ability:0x007fe36b2b79c8 @name="sturdy", @url="https://pokeapi.co/api/v2/ability/5/">,
87
+ # #<PokeApi::Ability:0x007fe36b2b75b8 @name="damp", @url="https://pokeapi.co/api/v2/ability/6/">,
88
+ # #<PokeApi::Ability:0x007fe36b2b71f8 @name="limber", @url="https://pokeapi.co/api/v2/ability/7/">,
89
+ # #<PokeApi::Ability:0x007fe36b2b6e38 @name="sand-veil", @url="https://pokeapi.co/api/v2/ability/8/">,
90
+ # #<PokeApi::Ability:0x007fe36b2b6a50 @name="static", @url="https://pokeapi.co/api/v2/ability/9/">,
91
+ # #<PokeApi::Ability:0x007fe36b2b6690 @name="volt-absorb", @url="https://pokeapi.co/api/v2/ability/10/">,
92
+ # #<PokeApi::Ability:0x007fe36b2b6230 @name="water-absorb", @url="https://pokeapi.co/api/v2/ability/11/">,
93
+ # #<PokeApi::Ability:0x007fe36b2b5ee8 @name="oblivious", @url="https://pokeapi.co/api/v2/ability/12/">,
94
+ # #<PokeApi::Ability:0x007fe36b2b5880 @name="cloud-nine", @url="https://pokeapi.co/api/v2/ability/13/">,
95
+ # #<PokeApi::Ability:0x007fe36b2b5538 @name="compound-eyes", @url="https://pokeapi.co/api/v2/ability/14/">,
96
+ # #<PokeApi::Ability:0x007fe36b2b4520 @name="insomnia", @url="https://pokeapi.co/api/v2/ability/15/">,
97
+ # #<PokeApi::Ability:0x007fe36b2b4020 @name="color-change", @url="https://pokeapi.co/api/v2/ability/16/">,
98
+ # ...
99
+
100
+ PokeApi.get(:ability).results[4].get # Fetches data from https://pokeapi.co/api/v2/ability/5/
101
+ ```
102
+
103
+ Second, you can specify the limit and pagination values by passing through the parameters.
104
+
105
+ ```ruby
106
+ PokeApi.get(pokemon_shape: {limit: 5, offset: 5})
107
+ # => #<PokeApi::ApiResourceList:0x007fe36c1ad158
108
+ # @count=14,
109
+ # @next_url="https://pokeapi.co/api/v2/pokemon-shape/?offset=10&limit=4",
110
+ # @previous_url="https://pokeapi.co/api/v2/pokemon-shape/?offset=0&limit=5",
111
+ # @results=
112
+ # [#<PokeApi::PokemonShape:0x007fe36c1ad0b8 @name="upright", @url="https://pokeapi.co/api/v2/pokemon-shape/6/">,
113
+ # #<PokeApi::PokemonShape:0x007fe36c1acc30 @name="legs", @url="https://pokeapi.co/api/v2/pokemon-shape/7/">,
114
+ # #<PokeApi::PokemonShape:0x007fe36c1ac7f8 @name="quadruped", @url="https://pokeapi.co/api/v2/pokemon-shape/8/">,
115
+ # #<PokeApi::PokemonShape:0x007fe36c1ac460 @name="wings", @url="https://pokeapi.co/api/v2/pokemon-shape/9/">,
116
+ # #<PokeApi::PokemonShape:0x007fe36b277da0 @name="tentacles", @url="https://pokeapi.co/api/v2/pokemon-shape/10/">]>
117
+
118
+ PokeApi.get(pokemon_shape: {limit: 5, page: 2})
119
+ # => #<PokeApi::ApiResourceList:0x007fe36c1bc928
120
+ # @count=14,
121
+ # @next_url="https://pokeapi.co/api/v2/pokemon-shape/?offset=10&limit=4",
122
+ # @previous_url="https://pokeapi.co/api/v2/pokemon-shape/?offset=0&limit=5",
123
+ # @results=
124
+ # [#<PokeApi::PokemonShape:0x007fe36c1bc658 @name="upright", @url="https://pokeapi.co/api/v2/pokemon-shape/6/">,
125
+ # #<PokeApi::PokemonShape:0x007fe36c1b6730 @name="legs", @url="https://pokeapi.co/api/v2/pokemon-shape/7/">,
126
+ # #<PokeApi::PokemonShape:0x007fe36c1b4660 @name="quadruped", @url="https://pokeapi.co/api/v2/pokemon-shape/8/">,
127
+ # #<PokeApi::PokemonShape:0x007fe36c19de60 @name="wings", @url="https://pokeapi.co/api/v2/pokemon-shape/9/">,
128
+ # #<PokeApi::PokemonShape:0x007fe36c18f9f0 @name="tentacles", @url="https://pokeapi.co/api/v2/pokemon-shape/10/">]>
129
+ ```
130
+
131
+ All of the data presented follows the identical patterns described by the API. For a complete list of endpoints and keys, please check out the [PokéAPI Docs](https://pokeapi.co/docs/v2.html).
132
+
133
+ ## Contributing
134
+
135
+ Contributions are welcome! Be sure to read our [contributing guide](https://github.com/rdavid1099/poke-api-v2/blob/master/CONTRIBUTING.md) before working on an issue. Bug reports and pull requests are welcome on GitHub at https://github.com/rdavid1099/poke-api-v2.
136
+
137
+ ## License
138
+
139
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module PokeApi
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ['lib']
31
31
 
32
32
  spec.add_development_dependency 'bundler', '~> 2.0'
33
- spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
34
  spec.add_development_dependency 'rspec', '~> 3.0'
35
35
  spec.add_development_dependency 'vcr', '~> 4.0.0'
36
36
  spec.add_development_dependency 'rubocop', '~> 0.65.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poke-api-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Workman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-04 00:00:00.000000000 Z
11
+ date: 2020-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,7 @@ files:
164
164
  - ".rspec"
165
165
  - ".rubocop.yml"
166
166
  - CODE_OF_CONDUCT.md
167
+ - CONTRIBUTING.md
167
168
  - Gemfile
168
169
  - Gemfile.lock
169
170
  - LICENSE.txt
@@ -292,7 +293,7 @@ licenses:
292
293
  - MIT
293
294
  metadata:
294
295
  allowed_push_host: https://rubygems.org/
295
- post_install_message:
296
+ post_install_message:
296
297
  rdoc_options: []
297
298
  require_paths:
298
299
  - lib
@@ -307,9 +308,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
308
  - !ruby/object:Gem::Version
308
309
  version: '0'
309
310
  requirements: []
310
- rubyforge_project:
311
- rubygems_version: 2.6.14
312
- signing_key:
311
+ rubygems_version: 3.1.4
312
+ signing_key:
313
313
  specification_version: 4
314
314
  summary: Ruby gem wrapper for https://pokeapi.co/api/v2/
315
315
  test_files: []