royw-tmdb 0.1.6 → 0.1.7
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.
- data/Rakefile +1 -0
- data/VERSION.yml +2 -2
- data/spec/tmdb_image_spec.rb +78 -72
- data/spec/tmdb_movie_spec.rb +43 -38
- data/spec/tmdb_profile_spec.rb +78 -83
- metadata +2 -2
data/Rakefile
CHANGED
@@ -22,6 +22,7 @@ require 'spec/rake/spectask'
|
|
22
22
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
23
|
spec.libs << 'lib' << 'spec'
|
24
24
|
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
spec.spec_opts = ["--color", "--format nested"]
|
25
26
|
end
|
26
27
|
|
27
28
|
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
data/VERSION.yml
CHANGED
data/spec/tmdb_image_spec.rb
CHANGED
@@ -28,96 +28,102 @@ describe "TmdbImage" do
|
|
28
28
|
@image.should_not == nil
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
describe "Image finds" do
|
32
|
+
it "should find image via profile" do
|
33
|
+
profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :logger => @logger)
|
34
|
+
profile.image.imdb_id.should == 'tt0465234'
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
it "should find image via movie" do
|
38
|
+
profile = TmdbMovie.new('0465234', TMDB_API_KEY, @logger)
|
39
|
+
profile.image.imdb_id.should == 'tt0465234'
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
describe "Image contents" do
|
44
|
+
it "should find original size fanart" do
|
45
|
+
src_url = nil
|
46
|
+
src_url = @image.fanart_original unless @image.nil?
|
47
|
+
src_url.should_not be_nil
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
it "should find mid size fanart" do
|
51
|
+
src_url = nil
|
52
|
+
src_url = @image.fanart_mid unless @image.nil?
|
53
|
+
src_url.should_not be_nil
|
54
|
+
end
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
it "should find thumb size fanart" do
|
57
|
+
src_url = nil
|
58
|
+
src_url = @image.fanart_thumb unless @image.nil?
|
59
|
+
src_url.should_not be_nil
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
it "should find original size poster" do
|
63
|
+
src_url = nil
|
64
|
+
src_url = @image.poster_original unless @image.nil?
|
65
|
+
src_url.should_not be_nil
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
it "should find mid size poster" do
|
69
|
+
src_url = nil
|
70
|
+
src_url = @image.poster_mid unless @image.nil?
|
71
|
+
src_url.should_not be_nil
|
72
|
+
end
|
70
73
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
it "should find thumb size poster" do
|
75
|
+
src_url = nil
|
76
|
+
src_url = @image.poster_thumb unless @image.nil?
|
77
|
+
src_url.should_not be_nil
|
78
|
+
end
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
it "should find cover size poster" do
|
81
|
+
src_url = nil
|
82
|
+
src_url = @image.poster_cover unless @image.nil?
|
83
|
+
src_url.should_not be_nil
|
84
|
+
end
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
it "should find all fanarts" do
|
87
|
+
buf = []
|
88
|
+
@image.fanart_sizes.each do |size|
|
89
|
+
buf << "fanart(#{size}) returned nil" if @image.fanart(size).nil?
|
90
|
+
end
|
91
|
+
puts buf.join("\n") unless buf.empty?
|
92
|
+
buf.empty?.should be_true
|
87
93
|
end
|
88
|
-
puts buf.join("\n") unless buf.empty?
|
89
|
-
buf.empty?.should be_true
|
90
|
-
end
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
it "should find all posters" do
|
96
|
+
buf = []
|
97
|
+
@image.poster_sizes.each do |size|
|
98
|
+
buf << "poster(#{size}) returned nil" if @image.poster(size).nil?
|
99
|
+
end
|
100
|
+
puts buf.join("\n") unless buf.empty?
|
101
|
+
buf.empty?.should be_true
|
96
102
|
end
|
97
|
-
puts buf.join("\n") unless buf.empty?
|
98
|
-
buf.empty?.should be_true
|
99
|
-
end
|
100
103
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
# the same routine is used by all the getters to fetch the image so only
|
105
|
+
# need to test one case
|
106
|
+
it "should fetch fanart" do
|
107
|
+
filespec = get_temp_filename
|
108
|
+
src_url = @image.fanart_original(filespec)
|
109
|
+
filespec += File.extname(src_url)
|
110
|
+
(File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
|
111
|
+
end
|
108
112
|
end
|
109
113
|
|
110
|
-
|
111
|
-
|
114
|
+
describe "bug tests" do
|
115
|
+
# these are a couple of white box tests to show a bug where
|
116
|
+
# src_url was nil but copy_image was trying to copy from it anyway.
|
112
117
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
118
|
+
it "should not attempt to copy if src_url is blank" do
|
119
|
+
dest_filespec = get_temp_filename
|
120
|
+
@image.send('copy_image', nil, dest_filespec).should be_nil
|
121
|
+
end
|
117
122
|
|
118
|
-
|
119
|
-
|
120
|
-
|
123
|
+
it "should not attempt to copy if dest_filespec is blank" do
|
124
|
+
src_url = @image.send('image_url', 'tt0465234', 'fanarts', 'original')
|
125
|
+
@image.send('copy_image', src_url, nil).should be_nil
|
126
|
+
end
|
121
127
|
end
|
122
128
|
|
123
129
|
def get_temp_filename
|
data/spec/tmdb_movie_spec.rb
CHANGED
@@ -20,58 +20,63 @@ describe "TmdbMovie" do
|
|
20
20
|
Dir.glob(File.join(TMPDIR,'tmdb_movie_spec*')).each { |filename| File.delete(filename) }
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
describe "Find movie" do
|
24
|
+
it "should find by imdb_id" do
|
25
|
+
@profile.should_not == nil
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
describe "Movie contents" do
|
30
|
+
it "should find tmdb id" do
|
31
|
+
@profile.idents.first.should == '6637'
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
it "should find fanarts" do
|
35
|
+
@profile.fanarts.size.should == 3
|
36
|
+
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
it "should find posters" do
|
39
|
+
@profile.posters.size.should == 4
|
40
|
+
end
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
it "should find the tmdb url" do
|
43
|
+
@profile.urls.first.should == 'http://www.themoviedb.org/movie/6637'
|
44
|
+
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
it "should find the imdb_id" do
|
47
|
+
@profile.imdb_ids.first.should == 'tt0465234'
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
it "should find the title" do
|
51
|
+
@profile.titles.first.should == 'National Treasure: Book of Secrets'
|
52
|
+
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
it "should find the short_overview" do
|
55
|
+
@profile.short_overviews.first.should =~ /Benjamin Franklin Gates/
|
56
|
+
end
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
it "should find the type" do
|
59
|
+
@profile.types.first.should == 'movie'
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
it "should find the alternative_titles" do
|
63
|
+
@profile.alternative_titles.first.should == 'National Treasure 2'
|
64
|
+
end
|
62
65
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
it "should find the release" do
|
67
|
+
@profile.releases.first.should == '2007-12-13'
|
68
|
+
end
|
66
69
|
|
67
|
-
|
68
|
-
|
70
|
+
it "should find the score" do
|
71
|
+
@profile.scores.first.should == '1.0'
|
72
|
+
end
|
69
73
|
end
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
describe "bug tests" do
|
76
|
+
it "should handle The Sand Pebble" do
|
77
|
+
profile = TmdbMovie.new('tt0060934', TMDB_API_KEY, @logger)
|
78
|
+
profile.idents.should be_nil
|
79
|
+
end
|
74
80
|
end
|
75
|
-
|
76
81
|
end
|
77
82
|
|
data/spec/tmdb_profile_spec.rb
CHANGED
@@ -21,115 +21,110 @@ describe "TmdbProfile" do
|
|
21
21
|
Dir.glob(File.join(TMPDIR,'tmdb_profile_spec*')).each { |filename| File.delete(filename) }
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
describe "Finder" do
|
25
|
+
it "should find by imdb_id" do
|
26
|
+
@profile.should_not == nil
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
30
|
+
describe "Contents" do
|
31
|
+
it "should find tmdb id" do
|
32
|
+
@profile.movie['idents'].first.should == '6637'
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
35
|
+
it "should find fanarts" do
|
36
|
+
@profile.movie['fanarts'].size.should == 3
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
begin
|
42
|
-
xml = @profile.to_xml
|
43
|
-
hash = XmlSimple.xml_in(xml)
|
44
|
-
rescue
|
45
|
-
hash = nil
|
39
|
+
it "should find posters" do
|
40
|
+
@profile.movie['posters'].size.should == 4
|
46
41
|
end
|
47
|
-
hash.should_not be_nil
|
48
|
-
end
|
49
42
|
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
it "should find the tmdb url" do
|
44
|
+
@profile.movie['urls'].first.should == 'http://www.themoviedb.org/movie/6637'
|
45
|
+
end
|
53
46
|
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
it "should find the imdb_id" do
|
48
|
+
@profile.movie['imdb_ids'].first.should == 'tt0465234'
|
49
|
+
end
|
57
50
|
|
58
|
-
|
59
|
-
|
60
|
-
|
51
|
+
it "should find the title" do
|
52
|
+
@profile.movie['titles'].first.should == 'National Treasure: Book of Secrets'
|
53
|
+
end
|
61
54
|
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
it "should find the short_overview" do
|
56
|
+
@profile.movie['short_overviews'].first.should =~ /Benjamin Franklin Gates/
|
57
|
+
end
|
65
58
|
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
it "should find the type" do
|
60
|
+
@profile.movie['types'].first.should == 'movie'
|
61
|
+
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
it "should find the alternative_titles" do
|
64
|
+
@profile.movie['alternative_titles'].first.should == 'National Treasure 2'
|
65
|
+
end
|
73
66
|
|
74
|
-
|
75
|
-
|
76
|
-
|
67
|
+
it "should find the release" do
|
68
|
+
@profile.movie['releases'].first.should == '2007-12-13'
|
69
|
+
end
|
77
70
|
|
78
|
-
|
79
|
-
|
71
|
+
it "should find the score" do
|
72
|
+
@profile.movie['scores'].first.should == '1.0'
|
73
|
+
end
|
80
74
|
end
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
76
|
+
describe "XML" do
|
77
|
+
it "should be able to convert to xml" do
|
78
|
+
xml = @profile.to_xml
|
79
|
+
(xml.should_not be_nil) && (xml.length.should > 0)
|
80
|
+
end
|
85
81
|
|
86
|
-
|
87
|
-
|
82
|
+
it "should be able to convert to xml and then from xml" do
|
83
|
+
hash = nil
|
84
|
+
begin
|
85
|
+
xml = @profile.to_xml
|
86
|
+
hash = XmlSimple.xml_in(xml)
|
87
|
+
rescue
|
88
|
+
hash = nil
|
89
|
+
end
|
90
|
+
hash.should_not be_nil
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
|
94
|
+
describe "File" do
|
95
|
+
it "should save the profile to a file" do
|
96
|
+
filespec = get_temp_filename
|
97
|
+
profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
|
98
|
+
(File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
|
99
|
+
end
|
93
100
|
|
94
|
-
# let's
|
101
|
+
# now let's test caching the profile to/from a file
|
95
102
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY)
|
100
|
-
xml = profile.to_xml
|
101
|
-
hash = XmlSimple.xml_in(xml)
|
102
|
-
rescue
|
103
|
-
hash = nil
|
103
|
+
it "should not create a file if a :filespec option is passed that is nil" do
|
104
|
+
profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => nil)
|
105
|
+
Dir.glob(File.join(TMPDIR, "imdb_profile_spec*")).empty?.should be_true
|
104
106
|
end
|
105
|
-
hash.should_not be_nil
|
106
|
-
end
|
107
|
-
|
108
|
-
# now let's test caching the profile to/from a file
|
109
107
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
it "should create a file if a :filespec option is passed" do
|
109
|
+
filespec = get_temp_filename
|
110
|
+
profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
|
111
|
+
(File.exist?(filespec) && (File.size(filespec) > 0)).should be_true
|
112
|
+
end
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
114
|
+
it "should load from a file if a :filespec option is passed and the file exists" do
|
115
|
+
filespec = get_temp_filename
|
116
|
+
profile1 = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
|
117
|
+
profile2 = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
|
118
|
+
profile1.imdb_id.should == profile2.imdb_id
|
119
|
+
end
|
120
120
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
it "should not load from a file if a :filespec option is passed and the file does not exists" do
|
122
|
+
filespec = get_temp_filename
|
123
|
+
profile = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
|
124
|
+
profile.should be_nil
|
125
|
+
end
|
126
126
|
end
|
127
127
|
|
128
|
-
it "should not load from a file if a :filespec option is passed and the file does not exists" do
|
129
|
-
filespec = get_temp_filename
|
130
|
-
profile = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
|
131
|
-
profile.should be_nil
|
132
|
-
end
|
133
128
|
|
134
129
|
def get_temp_filename
|
135
130
|
outfile = Tempfile.new('tmdb_profile_spec', TMPDIR)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: royw-tmdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roy Wright
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|