pokedex 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ module Pokedex
2
+ class Region
3
+ require 'pokedex/modules_helper/name'
4
+ include Pokedex::ModulesHelper::Name
5
+
6
+ attr_accessor :id, :names, :generation, :version_groups_urls
7
+
8
+ def initialize(args={})
9
+ @id = args['id']
10
+ @generation = Generation.find_by_url args['main_generation']['url']
11
+ @version_groups_urls = args['version_groups'].map{ |version_group| version_group['url'] }
12
+ extract_names args
13
+ end
14
+
15
+ def self.find id
16
+ new Pokedex.get "api/v2/region/#{id}"
17
+ end
18
+
19
+ def self.find_by_url url
20
+ new Pokedex.get URI.parse(url).path
21
+ end
22
+
23
+ def version_groups
24
+ version_groups_urls.map{ |version_group_url| VersionGroup.find_by_url version_group_url }
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ module Pokedex
2
+ VERSION = "0.0.1"
3
+ API_BASE_URL = 'http://pokeapi.co'
4
+ DEFAULT_TIMEOUT = 30 # seconds
5
+ TOTAL_POKEMON_COUNT = 721
6
+ end
@@ -0,0 +1,19 @@
1
+ module Pokedex
2
+ class VersionGroup
3
+ attr_accessor :id, :name, :generation
4
+
5
+ def initialize(args={})
6
+ @id = args['id']
7
+ @name = args['name']
8
+ @generation = Generation.find_by_url args['generation']['url']
9
+ end
10
+
11
+ def self.find id
12
+ self.new Pokedex.get "api/v2/version-group/#{id}"
13
+ end
14
+
15
+ def self.find_by_url url
16
+ self.new Pokedex.get URI.parse(url).path
17
+ end
18
+ end
19
+ end
@@ -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 'pokedex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pokedex"
8
+ spec.version = Pokedex::VERSION
9
+ spec.authors = ["Daniel Romero Esteban"]
10
+ spec.email = ["daniel.romero.esteban@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby wrapper for http://pokeapi.co Pokemon API.}
13
+ spec.homepage = "https://github.com/danielRomero/pokedex"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'unirest'
22
+ spec.add_development_dependency 'codeclimate-test-reporter'
23
+ spec.add_development_dependency 'pry'
24
+ spec.add_development_dependency 'awesome_print'
25
+ spec.add_development_dependency 'vcr'
26
+ spec.add_development_dependency 'webmock'
27
+ spec.add_development_dependency "bundler", "~> 1.11"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pokedex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Romero Esteban
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unirest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codeclimate-test-reporter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
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: awesome_print
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: vcr
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: webmock
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: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.11'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.11'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.0'
139
+ description:
140
+ email:
141
+ - daniel.romero.esteban@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".codeclimate.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - ".travis.yml"
151
+ - CODE_OF_CONDUCT.md
152
+ - Gemfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - lib/pokedex.rb
157
+ - lib/pokedex/area.rb
158
+ - lib/pokedex/egg_group.rb
159
+ - lib/pokedex/evolution_chain.rb
160
+ - lib/pokedex/generation.rb
161
+ - lib/pokedex/location.rb
162
+ - lib/pokedex/modules_helper/description.rb
163
+ - lib/pokedex/modules_helper/locale.rb
164
+ - lib/pokedex/modules_helper/name.rb
165
+ - lib/pokedex/pokemon.rb
166
+ - lib/pokedex/region.rb
167
+ - lib/pokedex/version.rb
168
+ - lib/pokedex/version_group.rb
169
+ - pokedex.gemspec
170
+ homepage: https://github.com/danielRomero/pokedex
171
+ licenses:
172
+ - MIT
173
+ metadata: {}
174
+ post_install_message:
175
+ rdoc_options: []
176
+ require_paths:
177
+ - lib
178
+ required_ruby_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ requirements: []
189
+ rubyforge_project:
190
+ rubygems_version: 2.6.0
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: Ruby wrapper for http://pokeapi.co Pokemon API.
194
+ test_files: []