metacritic 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 +12 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +108 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/environment.rb +2 -0
- data/lib/metacritic.rb +67 -0
- data/lib/metacritic/Game.rb +47 -0
- data/lib/metacritic/movie.rb +55 -0
- data/lib/metacritic/review.rb +25 -0
- data/lib/metacritic/version.rb +3 -0
- data/metacritic.gemspec +26 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a9a753ee7aecb4e65e1274313e3c9a4b87deec5c
|
4
|
+
data.tar.gz: 0f8b061f74779d217f53407f5cd795d38da71f61
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0af86f1402b3e76778b79cef6bd239d67cdc494671f5d27a672ba00d4fda916e19dc3c42a220fa50499ec3636bf6f8de97df3bb757780d8047839c8e45b23a71
|
7
|
+
data.tar.gz: 322607d0063594d4cffdc1abf73e1e800c03f1fc84ac21eda6c3251b9ce0f86d3272d6a1170313306d8d67b556ed498779801c90b65c0923acd5d808f49ae70a
|
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, 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 jeremysklarsky
|
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,108 @@
|
|
1
|
+
# Metacritic
|
2
|
+
|
3
|
+
This is a ruby gem wrapper for Mashape's Metacritic API. As of this version (0.1.0), the gem supports:
|
4
|
+
|
5
|
+
1. Getting Metacritic details for a movie or a game
|
6
|
+
2. Getting a list of critic reviews for a movie or game
|
7
|
+
|
8
|
+
TODO: Delete this and the text above, and describe your gem
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'metacritic'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install metacritic
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Using this gem requires an API key. These can be obtained from [Mashape](https://www.mashape.com/byroredux/metacritic). Currently, the free key allows for 1,000 requests per day.
|
29
|
+
|
30
|
+
As this gem requires use of a private API key, it is strongly suggested you use Figaro to manage your keys. `metacritic` is configured to access Install `figaro` (see [Figaro](https://github.com/laserlemon/figaro) for instructions) in your application, and place the following in your `application.yml` file:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
metacritic_api_key: <your key here>
|
34
|
+
```
|
35
|
+
|
36
|
+
##Using the gem
|
37
|
+
|
38
|
+
###Searching for a movie
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Metacritic.movie(title)
|
42
|
+
```
|
43
|
+
will return a movie object that has the following attributes:
|
44
|
+
`name`, `score`, `rlsdate`, `genres`, `rating`, `thumbnail`, `user_score`, `summary`, `director`, `cast`
|
45
|
+
|
46
|
+
Example usage:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
@movie = Metacritic.movie("The Big Lebowski")
|
50
|
+
@movie.name = "The Big Lebowski"
|
51
|
+
@movie.score = 69
|
52
|
+
```
|
53
|
+
Special cases:<br>
|
54
|
+
`@movie.cast` returns an array of the listed actors' names.<br>
|
55
|
+
`@movie.genres` returns an array of the listed genres.
|
56
|
+
|
57
|
+
###Searching for a game
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Metacritic.game(title)
|
61
|
+
```
|
62
|
+
will return a game object that has the following attributes:
|
63
|
+
`name`,`score`,`rlsdate`,`genre`,`rating`,`platform`,`publisher`,`developer`,`url`
|
64
|
+
|
65
|
+
Example usage:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
@game = Metacritic.game("The Elder Scrolls V: Skyrim")
|
69
|
+
@game.name = "The Elder Scrolls V: Skyrim"
|
70
|
+
@game.score = 92
|
71
|
+
```
|
72
|
+
|
73
|
+
###Getting a list of a movie or game's reviews
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
Metacritic.reviews(metacritic_url)
|
77
|
+
```
|
78
|
+
will return an array of reviews.
|
79
|
+
|
80
|
+
Example usage:
|
81
|
+
```ruby
|
82
|
+
Metacritic.reviews("http://www.metacritic.com/game/pc/portal-2")
|
83
|
+
```
|
84
|
+
will return:
|
85
|
+
```ruby
|
86
|
+
[{
|
87
|
+
"critic": "DarkStation",
|
88
|
+
"score": "100",
|
89
|
+
"excerpt": "Wolfenstein 3D changed how we looked at first person games in 1992 and The New Order, while not as big of a step, may be just as important of one for the future of the genre.",
|
90
|
+
"date": "2014-05-28",
|
91
|
+
"link": "http://www.darkstation.com/reviews/wolfenstein-the-new-order/"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"critic": "Softpedia",
|
95
|
+
"score": "90",
|
96
|
+
"excerpt": "A great reimagining of the series, delivering a fun experience to shooter fans, while bringing a good story and some solid mechanics that feel fresh but still know the roots of the franchise.",
|
97
|
+
"date": "2014-08-06",
|
98
|
+
"link": "http://www.softpedia.com/reviews/games/pc/Wolfenstein-The-New-Order-Review-447123.shtml"
|
99
|
+
}]
|
100
|
+
```
|
101
|
+
|
102
|
+
## Contributing
|
103
|
+
|
104
|
+
1. Fork it ( https://github.com/[my-github-username]/metacritic/fork )
|
105
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
106
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
107
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
108
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "metacritic"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
|
11
|
+
Pry.start
|
12
|
+
|
13
|
+
# require "irb"
|
14
|
+
# IRB.start
|
data/bin/setup
ADDED
data/lib/metacritic.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require "metacritic/version"
|
2
|
+
require "metacritic/movie"
|
3
|
+
require "metacritic/search"
|
4
|
+
require "metacritic/game"
|
5
|
+
require 'unirest'
|
6
|
+
require 'figaro'
|
7
|
+
module Metacritic
|
8
|
+
# Your code goes here...
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :response, :api_key
|
12
|
+
|
13
|
+
def api_key
|
14
|
+
self.api_key = ENV['metacritic_api_key']
|
15
|
+
end
|
16
|
+
|
17
|
+
def movie(title)
|
18
|
+
@response = Unirest.post "https://byroredux-metacritic.p.mashape.com/find/movie",
|
19
|
+
headers:{
|
20
|
+
"X-Mashape-Key" => api_key,
|
21
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
22
|
+
"Accept" => "application/json"
|
23
|
+
},
|
24
|
+
parameters:{
|
25
|
+
"retry" => 4,
|
26
|
+
"title" => title
|
27
|
+
}
|
28
|
+
|
29
|
+
Movie.new(@response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def movie(title)
|
33
|
+
@movie = Unirest.post "https://byroredux-metacritic.p.mashape.com/find/movie",
|
34
|
+
headers:{
|
35
|
+
"X-Mashape-Key" => api_key,
|
36
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
37
|
+
"Accept" => "application/json"
|
38
|
+
},
|
39
|
+
parameters:{
|
40
|
+
"retry" => 4,
|
41
|
+
"title" => title
|
42
|
+
}
|
43
|
+
Movie.new(@movie)
|
44
|
+
end
|
45
|
+
|
46
|
+
def reviews(url)
|
47
|
+
Reviews.new(url)
|
48
|
+
end
|
49
|
+
|
50
|
+
def game(title)
|
51
|
+
@game = Unirest.post "https://byroredux-metacritic.p.mashape.com/find/game",
|
52
|
+
headers:{
|
53
|
+
"X-Mashape-Key" => api_key,
|
54
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
55
|
+
"Accept" => "application/json"
|
56
|
+
},
|
57
|
+
parameters:{
|
58
|
+
"platform" => 1,
|
59
|
+
"retry" => 4,
|
60
|
+
"title" => title
|
61
|
+
}
|
62
|
+
Game.new(@game)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Metacritic
|
2
|
+
|
3
|
+
class Game
|
4
|
+
|
5
|
+
attr_accessor :response
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response.body["result"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
@response["name"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def score
|
16
|
+
@response["score"].to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
def rlsdate
|
20
|
+
@response["rlsdate"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def genre
|
24
|
+
@response["genre"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def rating
|
28
|
+
@response["rating"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def platform
|
32
|
+
@response["platform"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def publisher
|
36
|
+
@response["publisher"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def developer
|
40
|
+
@response["developer"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def url
|
44
|
+
@response["url"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Metacritic
|
2
|
+
|
3
|
+
class Movie
|
4
|
+
|
5
|
+
attr_accessor :response
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response.body["result"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
@response["name"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def score
|
16
|
+
@response["score"].to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
def rlsdate
|
20
|
+
@response["rlsdate"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def genres
|
24
|
+
@response["genre"].split("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def rating
|
28
|
+
@response["rating"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def thumbnail
|
32
|
+
@response["thumbnail"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def user_score
|
36
|
+
@response["userscore"].to_f
|
37
|
+
end
|
38
|
+
|
39
|
+
def summary
|
40
|
+
@response["summary"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def director
|
44
|
+
@response["director"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def cast
|
48
|
+
@response["cast"].split(", ")
|
49
|
+
end
|
50
|
+
|
51
|
+
def url
|
52
|
+
@response["url"]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Metacritic
|
2
|
+
|
3
|
+
class Reviews
|
4
|
+
|
5
|
+
attr_accessor :url, :response
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@url = url.gsub("/", "%2F").gsub(":", "%3A")
|
9
|
+
call
|
10
|
+
@response["result"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
|
15
|
+
@response = Unirest.get "https://byroredux-metacritic.p.mashape.com/reviews?url=#{@url}",
|
16
|
+
headers:{
|
17
|
+
"X-Mashape-Key" => api_key,
|
18
|
+
"Accept" => "application/json"
|
19
|
+
}
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/metacritic.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'metacritic/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "metacritic"
|
8
|
+
spec.version = Metacritic::VERSION
|
9
|
+
spec.authors = ["Jeremy Sklarsky"]
|
10
|
+
spec.email = ["jeremy.sklarsky@gmail.com"]
|
11
|
+
spec.summary = %q{Wrapper for Mashape's Metacritic gem.}
|
12
|
+
spec.description = %q{Wrapper for Mashape's Metacritic gem.}
|
13
|
+
spec.homepage = "https://github.com/jeremysklarsky/metacritic.git"
|
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_development_dependency "bundler", "~> 1.8"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_dependency "unirest"
|
24
|
+
spec.add_dependency "figaro"
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metacritic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Sklarsky
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-19 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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
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: unirest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: figaro
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Wrapper for Mashape's Metacritic gem.
|
70
|
+
email:
|
71
|
+
- jeremy.sklarsky@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- config/environment.rb
|
87
|
+
- lib/metacritic.rb
|
88
|
+
- lib/metacritic/Game.rb
|
89
|
+
- lib/metacritic/movie.rb
|
90
|
+
- lib/metacritic/review.rb
|
91
|
+
- lib/metacritic/version.rb
|
92
|
+
- metacritic.gemspec
|
93
|
+
homepage: https://github.com/jeremysklarsky/metacritic.git
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.4.6
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Wrapper for Mashape's Metacritic gem.
|
117
|
+
test_files: []
|