badfruit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/Manifest +3 -0
- data/README.md +28 -5
- data/Rakefile +1 -1
- data/badfruit.gemspec +3 -3
- data/lib/badfruit/Movies/movie.rb +28 -30
- data/lib/badfruit/Posters/posters.rb +11 -0
- data/lib/badfruit/Scores/scores.rb +11 -0
- data/lib/badfruit/base.rb +9 -0
- data/lib/badfruit.rb +3 -1
- metadata +7 -1
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Brian Michel (brian.michel@gmail.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/Manifest
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
LICENSE
|
1
2
|
Manifest
|
2
3
|
README.md
|
3
4
|
Rakefile
|
@@ -6,5 +7,7 @@ lib/badfruit/Actors/actor.rb
|
|
6
7
|
lib/badfruit/Lists/lists.rb
|
7
8
|
lib/badfruit/Movies/movie.rb
|
8
9
|
lib/badfruit/Movies/movies.rb
|
10
|
+
lib/badfruit/Posters/posters.rb
|
9
11
|
lib/badfruit/Reviews/review.rb
|
12
|
+
lib/badfruit/Scores/scores.rb
|
10
13
|
lib/badfruit/base.rb
|
data/README.md
CHANGED
@@ -3,13 +3,36 @@ BadFruit Client For Rotten Tomatoes
|
|
3
3
|
|
4
4
|
This is a rough gem to interface with the Rotten Tomatoes API.
|
5
5
|
|
6
|
+
Prerequisites
|
7
|
+
-------------
|
8
|
+
|
9
|
+
>gem install badfruit
|
10
|
+
|
11
|
+
YOU ARE NOW READY TO GET SOME SWEET MOVIE DATA!
|
12
|
+
|
6
13
|
Usage
|
7
14
|
-----
|
8
15
|
|
16
|
+
So there are two main parts of the api, movies and lists. Each of these parts return movie objects, but they are in different contexts. For example. (bf is a BadFruit client instance).
|
17
|
+
|
18
|
+
>bf.lists.newDVDReleases
|
19
|
+
|
20
|
+
Will return you an array of movie objects that represent that latest dvd releases. From this array you can execute actions on the individual movies themselves like...
|
21
|
+
|
22
|
+
>movies = bf.lists.newDVDReleases
|
23
|
+
movies[0].fullCast
|
24
|
+
movies[0].reviews
|
25
|
+
|
26
|
+
Very similar to the actual movie section of the api which I've included an example below...
|
27
|
+
|
9
28
|
>require 'badfruit'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
29
|
+
bf = BadFruit.new("YOUR_API_KEY_HERE")
|
30
|
+
movies = bf.movies.search_by_name("Hackers")
|
31
|
+
cast = movies[0].fullCast
|
32
|
+
reviews = movies[0].reviews
|
33
|
+
|
34
|
+
This should get you started, I should also mention that there are probably more tweaks needed to the list part of the api, but it should work for most people. Feel free to contact me or open an issue if need be.
|
14
35
|
|
15
|
-
|
36
|
+
Version
|
37
|
+
--------
|
38
|
+
The current version of the gem is 0.0.4, I could probably bump it to a 1.0 but..umm, well...who cares.
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('badfruit', '0.0.
|
5
|
+
Echoe.new('badfruit', '0.0.4') do |p|
|
6
6
|
p.description = "Interface with the Rotten Tomatoes API"
|
7
7
|
p.url = "http://www.github.com/brianmichel/badfruit"
|
8
8
|
p.author = "Brian Michel"
|
data/badfruit.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{badfruit}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Brian Michel"]
|
9
9
|
s.date = %q{2011-04-17}
|
10
10
|
s.description = %q{Interface with the Rotten Tomatoes API}
|
11
11
|
s.email = %q{brian.michel@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["README.md", "lib/badfruit.rb", "lib/badfruit/Actors/actor.rb", "lib/badfruit/Lists/lists.rb", "lib/badfruit/Movies/movie.rb", "lib/badfruit/Movies/movies.rb", "lib/badfruit/Reviews/review.rb", "lib/badfruit/base.rb"]
|
13
|
-
s.files = ["Manifest", "README.md", "Rakefile", "lib/badfruit.rb", "lib/badfruit/Actors/actor.rb", "lib/badfruit/Lists/lists.rb", "lib/badfruit/Movies/movie.rb", "lib/badfruit/Movies/movies.rb", "lib/badfruit/Reviews/review.rb", "lib/badfruit/base.rb", "badfruit.gemspec"]
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "README.md", "lib/badfruit.rb", "lib/badfruit/Actors/actor.rb", "lib/badfruit/Lists/lists.rb", "lib/badfruit/Movies/movie.rb", "lib/badfruit/Movies/movies.rb", "lib/badfruit/Posters/posters.rb", "lib/badfruit/Reviews/review.rb", "lib/badfruit/Scores/scores.rb", "lib/badfruit/base.rb"]
|
13
|
+
s.files = ["LICENSE", "Manifest", "README.md", "Rakefile", "lib/badfruit.rb", "lib/badfruit/Actors/actor.rb", "lib/badfruit/Lists/lists.rb", "lib/badfruit/Movies/movie.rb", "lib/badfruit/Movies/movies.rb", "lib/badfruit/Posters/posters.rb", "lib/badfruit/Reviews/review.rb", "lib/badfruit/Scores/scores.rb", "lib/badfruit/base.rb", "badfruit.gemspec"]
|
14
14
|
s.homepage = %q{http://www.github.com/brianmichel/badfruit}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Badfruit", "--main", "README.md"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -1,39 +1,37 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module BadFruit
|
2
|
+
class Movie
|
3
|
+
attr_accessor :id, :name, :cast, :scores, :posters
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
def initialize(movieHash, badfruit)
|
6
|
+
@id = movieHash["id"]
|
7
|
+
@name = movieHash["title"]
|
8
|
+
@cast = movieHash["abridged_cast"]
|
9
|
+
@scores = Scores.new(movieHash["ratings"])
|
10
|
+
@posters = Posters.new(movieHash["posters"])
|
11
|
+
@badfruit = badfruit
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
def averageScores
|
15
|
+
puts "average!"
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
actors = Array.new
|
21
|
-
data["cast"].each do |actor|
|
22
|
-
actors.push(Actor.new(actor))
|
18
|
+
# for the three following methods, pass in your BadFruit client instance to retreive the info
|
19
|
+
# this will be fixed when all results are parsed into movie assets for the user
|
20
|
+
def fullCast
|
21
|
+
return @badfruit.parseActorsArray(JSON.parse(@badfruit.get_movie_info(@id, "cast")))
|
23
22
|
end
|
24
|
-
return actors
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
def reviews
|
25
|
+
data = JSON.parse(@badfruit.get_movie_info(@id, "reviews"))
|
26
|
+
reviews = Array.new
|
27
|
+
data["reviews"].each do |review|
|
28
|
+
reviews.push(Review.new(review))
|
29
|
+
end
|
30
|
+
return reviews
|
32
31
|
end
|
33
|
-
return reviews
|
34
|
-
end
|
35
32
|
|
36
|
-
|
37
|
-
|
33
|
+
def info
|
34
|
+
return JSON.parse(@badfruit.get_movie_info(@id, "details"))
|
35
|
+
end
|
38
36
|
end
|
39
37
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module BadFruit
|
2
|
+
class Posters
|
3
|
+
attr_reader :thumbnail, :profile, :detailed, :original
|
4
|
+
def initialize(posterHash)
|
5
|
+
@thumbnail = posterHash["thumbnail"]
|
6
|
+
@profile = posterHash["profile"]
|
7
|
+
@detailed = posterHash["detailed"]
|
8
|
+
@original = posterHash["original"]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Scores
|
2
|
+
attr_reader :critics_score, :audience_score
|
3
|
+
def initialize(scoreHash)
|
4
|
+
@critics_score = scoreHash["critics_score"]
|
5
|
+
@audience_score = scoreHash["audience_score"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def average
|
9
|
+
return ((@critics_score + @audience_score) / 2)
|
10
|
+
end
|
11
|
+
end
|
data/lib/badfruit/base.rb
CHANGED
@@ -65,6 +65,7 @@ module BadFruit
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
#Utility Methods For Parsing
|
68
69
|
def parseMoviesArray(hash)
|
69
70
|
moviesArray = Array.new
|
70
71
|
hash["movies"].each do |movie|
|
@@ -72,5 +73,13 @@ module BadFruit
|
|
72
73
|
end
|
73
74
|
return moviesArray
|
74
75
|
end
|
76
|
+
|
77
|
+
def parseActorsArray(hash)
|
78
|
+
actorsArray = Array.new
|
79
|
+
hash["cast"].each do |actor|
|
80
|
+
actorsArray.push(Actor.new(actor))
|
81
|
+
end
|
82
|
+
return actorsArray
|
83
|
+
end
|
75
84
|
end
|
76
85
|
end
|
data/lib/badfruit.rb
CHANGED
@@ -3,11 +3,13 @@ require 'JSON'
|
|
3
3
|
require 'cgi'
|
4
4
|
|
5
5
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'base')
|
6
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Lists', 'lists')
|
7
6
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Movies', 'movies')
|
8
7
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Movies', 'movie')
|
9
8
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Reviews', 'review')
|
10
9
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Actors', 'actor')
|
10
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Lists', 'lists')
|
11
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Posters', 'posters')
|
12
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'badfruit', 'Scores', 'scores')
|
11
13
|
|
12
14
|
module BadFruit
|
13
15
|
def self.new(apikey)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: badfruit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Michel
|
@@ -41,15 +41,19 @@ executables: []
|
|
41
41
|
extensions: []
|
42
42
|
|
43
43
|
extra_rdoc_files:
|
44
|
+
- LICENSE
|
44
45
|
- README.md
|
45
46
|
- lib/badfruit.rb
|
46
47
|
- lib/badfruit/Actors/actor.rb
|
47
48
|
- lib/badfruit/Lists/lists.rb
|
48
49
|
- lib/badfruit/Movies/movie.rb
|
49
50
|
- lib/badfruit/Movies/movies.rb
|
51
|
+
- lib/badfruit/Posters/posters.rb
|
50
52
|
- lib/badfruit/Reviews/review.rb
|
53
|
+
- lib/badfruit/Scores/scores.rb
|
51
54
|
- lib/badfruit/base.rb
|
52
55
|
files:
|
56
|
+
- LICENSE
|
53
57
|
- Manifest
|
54
58
|
- README.md
|
55
59
|
- Rakefile
|
@@ -58,7 +62,9 @@ files:
|
|
58
62
|
- lib/badfruit/Lists/lists.rb
|
59
63
|
- lib/badfruit/Movies/movie.rb
|
60
64
|
- lib/badfruit/Movies/movies.rb
|
65
|
+
- lib/badfruit/Posters/posters.rb
|
61
66
|
- lib/badfruit/Reviews/review.rb
|
67
|
+
- lib/badfruit/Scores/scores.rb
|
62
68
|
- lib/badfruit/base.rb
|
63
69
|
- badfruit.gemspec
|
64
70
|
homepage: http://www.github.com/brianmichel/badfruit
|