igdb 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dbdf71e2606337fa85b81e3cce2a8bb95a9fd96
4
- data.tar.gz: 6da334c7d830fbbc1c001761d0ff2ceb335c65d0
3
+ metadata.gz: 04df047690556a37cc11f802c70aa5cdb447d441
4
+ data.tar.gz: 322573ae0e0d83a2b0d21f3679b8e15a62f10541
5
5
  SHA512:
6
- metadata.gz: 65003d8a0152038839b67c15f15bc46fa61b6e024455b12394a378200932145d38731fbd045c6e15b1bd2dd120bd5debb1f830f43d0fb2d0b15e6c9546b2ea2b
7
- data.tar.gz: 765b0ada099dfbac0f7c12dcd05f7695cf1d807e671ee65b71ca4cf5d7020117a9fbfcc2001104b41d394087405261b854dcb29a1205b7dbbeb78d50039fa776
6
+ metadata.gz: 6a4aceca38ce1d45d825ea6e3a6195d2a3f5a06b6f433d128420ea5ed610c757381dcc2e753ad9d20ad03a327a1a4c34dbe46c1e1405ceb1900c8f3bad827c8b
7
+ data.tar.gz: 8f072d0e3db19d5bc478a9205e3a0c9c62b2d3f960fb7ae746bdc451e4dcc68d7d22db04ae08bccb16cbfd8c80e2b13572aa232a8cb2545036dc9474709ba979
data/README.md CHANGED
@@ -6,63 +6,70 @@
6
6
  [![Gem Version](https://badge.fury.io/rb/igdb.svg)](http://badge.fury.io/rb/igdb)
7
7
  [![Dependency Status](https://gemnasium.com/ahmetabdi/igdb.svg)](https://gemnasium.com/ahmetabdi/igdb)
8
8
 
9
- ## Installation
10
- $ gem install igdb
9
+ <img src="banner.png">
11
10
 
11
+ ## Installation
12
+ ```ruby
13
+ $ gem install igdb
14
+ ```
12
15
  ## Usage
13
16
 
14
17
  ##### Connect
15
-
16
- $ Igdb.connect('api_key')
17
-
18
+ ```ruby
19
+ $ Igdb.connect('api_key')
20
+ ```
18
21
  ##### Game
19
22
  Find game by ID
20
-
21
- $ Igdb::Game.find(1971)
22
-
23
+ ```ruby
24
+ $ Igdb::Game.find(1971)
25
+ ```
23
26
  Search for a game
24
-
25
- $ Igdb::Game.search(query: 'batman')
26
-
27
+ ```ruby
28
+ $ Igdb::Game.search(query: 'batman')
29
+ ```
27
30
  Return the number of games in the database
28
-
29
- $ Igdb::Game.meta
30
-
31
+ ```ruby
32
+ $ Igdb::Game.meta
33
+ ```
31
34
  Return a list of all games with an offset and/or limit
32
-
33
- $ Igdb::Game.all
34
- $ Igdb::Game.all(limit: 10) # Limit to 10 results - Default 100
35
- $ Igdb::Game.all(offset: 5) # Offset result starting at 5th - Default 0
36
-
35
+ ```ruby
36
+ $ Igdb::Game.all
37
+ $ Igdb::Game.all(limit: 10) # Limit to 10 results - Default 100
38
+ $ Igdb::Game.all(offset: 5) # Offset result starting at 5th - Default 0
39
+ ```
37
40
  ##### Person
38
41
  Find person by ID or name
39
-
40
- $ Igdb::Person.find(4)
41
- $ Igdb::Person.find('derek-watts')
42
-
42
+ ```ruby
43
+ $ Igdb::Person.find(4)
44
+ $ Igdb::Person.find('derek-watts')
45
+ ```
43
46
  Return the number of people in the database
44
-
45
- $ Igdb::Person.meta
46
-
47
+ ```ruby
48
+ $ Igdb::Person.meta
49
+ ```
47
50
  Return a list of all games with an offset and/or limit
48
-
49
- $ Igdb::Person.all
50
- $ Igdb::Person.all(limit: 10) # Limit to 10 results - Default 100
51
- $ Igdb::Person.all(offset: 5) # Offset result starting at 5th - Default 0
52
-
51
+ ```ruby
52
+ $ Igdb::Person.all
53
+ $ Igdb::Person.all(limit: 10) # Limit to 10 results - Default 100
54
+ $ Igdb::Person.all(offset: 5) # Offset result starting at 5th - Default 0
55
+ ```
53
56
  ##### Company
54
57
  Find company by ID or name
55
-
56
- $ Igdb::Company.find(70)
57
- $ Igdb::Company.find('nintendo')
58
-
58
+ ```ruby
59
+ $ Igdb::Company.find(70)
60
+ $ Igdb::Company.find('nintendo')
61
+ ```
59
62
  Return the number of companies in the database.
60
-
61
- $ Igdb::Company.meta
62
-
63
+ ```ruby
64
+ $ Igdb::Company.meta
65
+ ```
66
+ Return the games for a company
67
+ ```ruby
68
+ $ Igdb::Company.find('2000').games
69
+ ```
63
70
  ## Contributing
64
71
 
65
- 1. Fork it ( https://github.com/[my-github-username]/igdb/fork )
72
+ 1. Fork it ( https://github.com/ahmetabdi/igdb/fork )
66
73
  2. Create your feature branch (`git checkout -b my-new-feature`)
67
74
  3. Commit your changes (`git commit -am 'Add some feature'`)
68
75
  4. Push to the branch (`git push origin my-new-feature`)
@@ -9,12 +9,12 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Ahmet Abdi']
10
10
  spec.email = ['ahmetabdi@gmail.com']
11
11
 
12
- spec.summary = ''
12
+ spec.summary = 'A Ruby wrapper for the Internet Game Database API.'
13
13
  spec.description = ''
14
14
  spec.homepage = ''
15
15
  spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.files = Dir['README.md', 'igdb.gemspec', 'lib/**/*']
18
18
  spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
@@ -29,5 +29,4 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'representable'
30
30
  spec.add_runtime_dependency 'multi_json'
31
31
  spec.add_runtime_dependency 'rest-client'
32
- spec.add_runtime_dependency 'require_all'
33
32
  end
@@ -1,7 +1,33 @@
1
- require 'require_all'
2
- require_all 'lib'
3
-
4
1
  module Igdb
2
+ #Utilities
3
+ autoload :Configuration, 'igdb/configuration/api'
4
+ autoload :Requester, 'igdb/requester'
5
+ autoload :Exception, 'igdb/exceptions'
6
+
7
+ #Models
8
+ autoload :ApiResource, 'igdb/models/api_resource'
9
+ autoload :Company, 'igdb/models/company'
10
+ autoload :Game, 'igdb/models/game'
11
+ autoload :GameCompany, 'igdb/models/game_company'
12
+ autoload :GameGenre, 'igdb/models/game_genre'
13
+ autoload :GameReleaseDate, 'igdb/models/game_release_date'
14
+ autoload :GameScreenshot, 'igdb/models/game_screenshot'
15
+ autoload :GameTheme, 'igdb/models/game_theme'
16
+ autoload :GameVideo, 'igdb/models/game_video'
17
+ autoload :Person, 'igdb/models/person'
18
+ autoload :Shop, 'igdb/models/shop'
19
+
20
+ #Presenters
21
+ autoload :CompanyRepresenter, 'igdb/representers/company_representer'
22
+ autoload :GameCompanyRespresenter, 'igdb/representers/game_company_representer'
23
+ autoload :GameGenreRepresenter, 'igdb/representers/game_genre_representer'
24
+ autoload :GameReleaseDateRespresenter, 'igdb/representers/game_release_date_representer'
25
+ autoload :GameRepresenter, 'igdb/representers/game_representer'
26
+ autoload :GameScreenshotRepresenter, 'igdb/representers/game_screenshot_representer'
27
+ autoload :GameThemeRepresenter, 'igdb/representers/game_theme_representer'
28
+ autoload :GameVideoRepresenter, 'igdb/representers/game_video_representer'
29
+ autoload :PersonRepresenter, 'igdb/representers/person_representer'
30
+
5
31
  def self.connect(api_key)
6
32
  Igdb::Configuration::Api.instance.tap do |api|
7
33
  api.connect(api_key)
@@ -12,4 +12,8 @@ class Igdb::ApiResource < OpenStruct
12
12
  resources << self.new.extend(representer).from_hash(response)
13
13
  end
14
14
  end
15
+
16
+ def build_for_collection(response, representer)
17
+ [].extend(representer.for_collection).from_hash(response)
18
+ end
15
19
  end
@@ -1,11 +1,20 @@
1
1
  class Igdb::Company < Igdb::ApiResource
2
2
 
3
3
  def self.meta
4
- build_single_resource(Igdb::Requester.get("companies/meta"), CompanyRepresenter).size
4
+ build_single_resource(Igdb::Requester.get("companies/meta"), Igdb::CompanyRepresenter).size
5
5
  end
6
6
 
7
7
  def self.find(id)
8
- build_single_resource(Igdb::Requester.get("companies/#{id}")['company'], CompanyRepresenter)
8
+ build_single_resource(Igdb::Requester.get("companies/#{id}")['company'], Igdb::CompanyRepresenter)
9
+ end
10
+
11
+ # Show games of a specific company
12
+ def games(opts={})
13
+ params = Hash.new.tap do |hash|
14
+ hash['offset'] = opts[:offset] || 0
15
+ hash['limit'] = opts[:limit] || 100
16
+ end
17
+ build_for_collection(Igdb::Requester.get("companies/#{id}/games", params)['games'], Igdb::CompanyRepresenter)
9
18
  end
10
19
 
11
20
  end
@@ -1,11 +1,11 @@
1
1
  class Igdb::Game < Igdb::ApiResource
2
2
 
3
3
  def self.meta
4
- build_single_resource(Igdb::Requester.get("games/meta"), GameRepresenter).size
4
+ build_single_resource(Igdb::Requester.get("games/meta"), Igdb::GameRepresenter).size
5
5
  end
6
6
 
7
7
  def self.find(id)
8
- build_single_resource(Igdb::Requester.get("games/#{id}")['game'], GameRepresenter)
8
+ build_single_resource(Igdb::Requester.get("games/#{id}")['game'], Igdb::GameRepresenter)
9
9
  end
10
10
 
11
11
  def self.search(opts={})
@@ -13,7 +13,7 @@ class Igdb::Game < Igdb::ApiResource
13
13
  hash['q'] = opts[:query] if opts[:query]
14
14
  hash['filters'] = opts[:filters] if opts[:filters]
15
15
  end
16
- build_collection(Igdb::Requester.get("games/search", params)['games'], GameRepresenter)
16
+ build_collection(Igdb::Requester.get("games/search", params)['games'], Igdb::GameRepresenter)
17
17
  end
18
18
 
19
19
  def self.all(opts={})
@@ -21,7 +21,7 @@ class Igdb::Game < Igdb::ApiResource
21
21
  hash['offset'] = opts[:offset] || 0
22
22
  hash['limit'] = opts[:limit] || 100
23
23
  end
24
- build_collection(Igdb::Requester.get("games", params)['games'], GameRepresenter)
24
+ build_collection(Igdb::Requester.get("games", params)['games'], Igdb::GameRepresenter)
25
25
  end
26
26
 
27
27
  end
@@ -1,11 +1,11 @@
1
1
  class Igdb::Person < Igdb::ApiResource
2
2
 
3
3
  def self.meta
4
- build_single_resource(Igdb::Requester.get('people/meta'), PersonRepresenter).size
4
+ build_single_resource(Igdb::Requester.get('people/meta'), Igdb::PersonRepresenter).size
5
5
  end
6
6
 
7
7
  def self.find(id)
8
- build_single_resource(Igdb::Requester.get("people/#{id}")['person'], PersonRepresenter)
8
+ build_single_resource(Igdb::Requester.get("people/#{id}")['person'], Igdb::PersonRepresenter)
9
9
  end
10
10
 
11
11
  def self.all(opts={})
@@ -13,7 +13,7 @@ class Igdb::Person < Igdb::ApiResource
13
13
  hash['offset'] = opts[:offset] || 0
14
14
  hash['limit'] = opts[:limit] || 100
15
15
  end
16
- build_collection(Igdb::Requester.get("people", params)['people'], PersonRepresenter)
16
+ build_collection(Igdb::Requester.get("people", params)['people'], Igdb::PersonRepresenter)
17
17
  end
18
18
 
19
19
  end
@@ -1,4 +1,4 @@
1
- module CompanyRepresenter
1
+ module Igdb::CompanyRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :id # The id of the game.
@@ -6,4 +6,6 @@ module CompanyRepresenter
6
6
  property :average_rating # The average rating of all the games the company that has developed or published.
7
7
  property :parent # The id of the parent company.
8
8
  property :size # The number of companies in the database.
9
+
10
+ collection_representer class: Igdb::Game
9
11
  end
@@ -1,6 +1,8 @@
1
- module GameCompanyRespresenter
1
+ module Igdb::GameCompanyRespresenter
2
2
  include Representable::JSON
3
3
 
4
+ property :id
5
+ property :parent
4
6
  property :name
5
7
  property :developer
6
8
  property :publisher
@@ -1,4 +1,4 @@
1
- module GameGenreRepresenter
1
+ module Igdb::GameGenreRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :name
@@ -1,4 +1,4 @@
1
- module GameReleaseDateRespresenter
1
+ module Igdb::GameReleaseDateRespresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :platform_name
@@ -1,4 +1,4 @@
1
- module GameRepresenter
1
+ module Igdb::GameRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :id # The id of the game.
@@ -17,10 +17,10 @@ module GameRepresenter
17
17
  property :src # The source of the image in the thumbnail format.
18
18
  property :size # The number of games in the database.
19
19
 
20
- collection :release_dates, extend: GameReleaseDateRespresenter, class: Igdb::GameReleaseDate # The release dates of the game.
21
- collection :screenshots, extend: GameScreenshotRepresenter, class: Igdb::GameScreenshot # The list of screenshots of the game.
22
- collection :videos, extend: GameVideoRepresenter, class: Igdb::GameVideo # Not documented in v1 API
23
- collection :genres, extend: GameGenreRepresenter, class: Igdb::GameGenre # Not documented in v1 API
24
- collection :themes, extend: GameThemeRepresenter, class: Igdb::GameTheme # Not documented in v1 API
25
- collection :companies, extend: GameCompanyRespresenter, class: Igdb::GameCompany # List of companies that developed and published.
20
+ collection :release_dates, extend: Igdb::GameReleaseDateRespresenter, class: Igdb::GameReleaseDate # The release dates of the game.
21
+ collection :screenshots, extend: Igdb::GameScreenshotRepresenter, class: Igdb::GameScreenshot # The list of screenshots of the game.
22
+ collection :videos, extend: Igdb::GameVideoRepresenter, class: Igdb::GameVideo # Not documented in v1 API
23
+ collection :genres, extend: Igdb::GameGenreRepresenter, class: Igdb::GameGenre # Not documented in v1 API
24
+ collection :themes, extend: Igdb::GameThemeRepresenter, class: Igdb::GameTheme # Not documented in v1 API
25
+ collection :companies, extend: Igdb::GameCompanyRespresenter, class: Igdb::GameCompany # List of companies that developed and published.
26
26
  end
@@ -1,6 +1,9 @@
1
- module GameScreenshotRepresenter
1
+ module Igdb::GameScreenshotRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :title
5
- property :thumb
5
+ property :url
6
+ property :width
7
+ property :height
8
+ property :id
6
9
  end
@@ -1,4 +1,4 @@
1
- module GameThemeRepresenter
1
+ module Igdb::GameThemeRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :name
@@ -1,4 +1,4 @@
1
- module GameVideoRepresenter
1
+ module Igdb::GameVideoRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :title
@@ -1,4 +1,4 @@
1
- module PersonRepresenter
1
+ module Igdb::PersonRepresenter
2
2
  include Representable::JSON
3
3
 
4
4
  property :id # The id of the person.
@@ -1,3 +1,3 @@
1
1
  module Igdb
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: igdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmet Abdi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: require_all
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
139
  description: ''
154
140
  email:
155
141
  - ahmetabdi@gmail.com
@@ -157,16 +143,7 @@ executables: []
157
143
  extensions: []
158
144
  extra_rdoc_files: []
159
145
  files:
160
- - ".circle.yml"
161
- - ".gitignore"
162
- - ".rspec"
163
- - ".travis.yml"
164
- - Gemfile
165
- - LICENSE.txt
166
146
  - README.md
167
- - Rakefile
168
- - bin/console
169
- - bin/setup
170
147
  - igdb.gemspec
171
148
  - lib/igdb.rb
172
149
  - lib/igdb/configuration/api.rb
@@ -213,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
190
  version: '0'
214
191
  requirements: []
215
192
  rubyforge_project:
216
- rubygems_version: 2.4.8
193
+ rubygems_version: 2.5.1
217
194
  signing_key:
218
195
  specification_version: 4
219
- summary: ''
196
+ summary: A Ruby wrapper for the Internet Game Database API.
220
197
  test_files: []
@@ -1,3 +0,0 @@
1
- machine:
2
- ruby:
3
- version: rbx-2.2.2
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- .idea
11
- .env
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.2
4
- env:
5
- - CODECLIMATE_REPO_TOKEN=8ffbec2a216b73652275893dbfb29f9b73035ba8e7d00f4743ec4824f8eacfdd
6
- script: bundle exec rspec spec
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in igdb.gemspec
4
- gemspec
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Ahmet Abdi
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/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "igdb"
5
- require 'byebug'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here