unified_db 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,12 +9,12 @@ module UnifiedDB
9
9
  movie = handler.find_movie_by_id(id)
10
10
  @result = Result::ID.new(
11
11
  :id => movie.imdb_id,
12
- :title => movie.title,
13
- :overview => movie.plot,
14
- :release_date => movie.release_date,
12
+ :title => movie.title.to_s,
13
+ :overview => movie.plot.to_s,
14
+ :release_date => movie.release_date.to_s,
15
15
  :genres => movie.genres,
16
- :rating => movie.rating,
17
- :runtime => movie.runtime.to_i,
16
+ :rating => movie.rating.to_s,
17
+ :runtime => movie.runtime.to_i.to_s,
18
18
  :actors => format_actors(movie.actors),
19
19
  :directors => format_directors(movie.directors),
20
20
  :writers => format_writers(movie.writers),
@@ -29,8 +29,8 @@ module UnifiedDB
29
29
  movies = Imdb::Search.new(title).movies
30
30
  movies.each do |movie|
31
31
  id = "tt#{movie.id}"
32
- title = movie.title.encode('iso-8859-1')
33
- title.force_encoding('utf-8')
32
+ title = movie.title
33
+ title = title.encode('iso-8859-1').force_encoding('utf-8') if title.respond_to? :force_encoding
34
34
  title1, year, tmp, title2 = title.match(/(.*) \(([0-9]{4})(\/[a-zA-Z]*)?\)(.*)/)[1..4] rescue next
35
35
  @result << Result::Title.new(
36
36
  :id => id,
@@ -10,12 +10,12 @@ module UnifiedDB
10
10
 
11
11
  @result = Result::ID.new(
12
12
  :id => movie.id,
13
- :title => movie.name,
14
- :overview => movie.overview,
13
+ :title => movie.name.to_s,
14
+ :overview => movie.overview.to_s,
15
15
  :release_date => movie.first_aired.to_s,
16
16
  :genres => movie.genres,
17
- :rating => movie.rating,
18
- :runtime => movie.runtime.to_i,
17
+ :rating => movie.rating.to_s,
18
+ :runtime => movie.runtime.to_i.to_s,
19
19
  :actors => format_actors(movie.actors),
20
20
  :directors => [],
21
21
  :writers => [],
@@ -1,5 +1,5 @@
1
1
  module UnifiedDB
2
2
 
3
- VERSION = '0.2.4'
3
+ VERSION = '0.2.5'
4
4
 
5
5
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe UnifiedDB::Backend::IMDB do
4
4
  subject { described_class.new }
5
-
5
+
6
6
  it "should return valid find by title" do
7
7
  result = subject.find(:title => 'Dark Knight')
8
8
  result.class.should eql(Hash)
@@ -11,30 +11,30 @@ describe UnifiedDB::Backend::IMDB do
11
11
  result[:service].should eql('imdb')
12
12
  result[:result].class.should eql(Array)
13
13
  result[:result].size.should be > 18
14
-
14
+
15
15
  first_result = result[:result].first
16
16
  first_result.class.should eql(UnifiedDB::Result::Title)
17
17
  first_result.id.should eql('tt0468569')
18
18
  first_result.title.should eql('The Dark Knight')
19
19
  first_result.year.should eql('2008')
20
-
20
+
21
21
  encoded = Yajl::Encoder.new.encode result
22
22
  decoded = Yajl::Parser.new.parse encoded
23
-
23
+
24
24
  decoded.class.should eql(Hash)
25
25
  do_sort(decoded.keys).should eql(['result', 'service', 'status'])
26
26
  decoded['status'].should eql('success')
27
27
  decoded['service'].should eql('imdb')
28
28
  decoded['result'].class.should eql(Array)
29
29
  decoded['result'].size.should be > 18
30
-
30
+
31
31
  first_result = decoded['result'].first
32
32
  first_result.class.should eql(Hash)
33
33
  first_result['id'].should eql('tt0468569')
34
34
  first_result['title'].should eql('The Dark Knight')
35
35
  first_result['year'].should eql('2008')
36
36
  end
37
-
37
+
38
38
  it "should return empty array if invalid find by title specified" do
39
39
  result = subject.find(:title => "qwertyuiopasdfghjkllzxcvbnm")
40
40
  result.class.should eql(Hash)
@@ -44,15 +44,15 @@ describe UnifiedDB::Backend::IMDB do
44
44
  result[:result].class.should eql(Array)
45
45
  result[:result].size.should eql(0)
46
46
  end
47
-
48
-
47
+
48
+
49
49
  it "should return valid find by id" do
50
50
  result = subject.find(:id => 'tt0468569')
51
51
  result.class.should eql(Hash)
52
52
  do_sort(result.keys).should eql([:result, :service, :status])
53
53
  result[:status].should eql('success')
54
54
  result[:service].should eql('imdb')
55
-
55
+
56
56
  result[:result].class.should eql(UnifiedDB::Result::ID)
57
57
  result[:result].id.should eql('tt0468569')
58
58
  result[:result].title.should eql('The Dark Knight')
@@ -60,10 +60,10 @@ describe UnifiedDB::Backend::IMDB do
60
60
  result[:result].overview.length.should be > 20
61
61
  result[:result].release_date.class.should eql(String)
62
62
  result[:result].genres.should eql(["Action", "Crime", "Drama", "Thriller"])
63
- result[:result].rating.class.should eql(Float)
64
- result[:result].rating.should be > 4
65
- result[:result].rating.should be < 10
66
- result[:result].runtime.should eql(152)
63
+ result[:result].rating.class.should eql(String)
64
+ result[:result].rating.to_f.should be > 4
65
+ result[:result].rating.to_f.should be < 10
66
+ result[:result].runtime.should eql("152")
67
67
  result[:result].actors.class.should eql(Array)
68
68
  result[:result].actors.first.should eql({"Christian Bale" => "Bruce Wayne/Batman"})
69
69
  result[:result].directors.should eql(["Christopher Nolan"])
@@ -71,7 +71,7 @@ describe UnifiedDB::Backend::IMDB do
71
71
  result[:result].posters.class.should eql(Array)
72
72
  result[:result].posters.size.should be > 0
73
73
  end
74
-
74
+
75
75
  it "should return error if id was not found" do
76
76
  result = subject.find(:id => 'tt046856910')
77
77
  result.class.should eql(Hash)
@@ -79,5 +79,5 @@ describe UnifiedDB::Backend::IMDB do
79
79
  result[:status].should eql('error')
80
80
  result[:reason].should eql('not found')
81
81
  end
82
-
82
+
83
83
  end
@@ -60,10 +60,10 @@ describe UnifiedDB::Backend::TVDB do
60
60
  result[:result].overview.length.should be > 20
61
61
  result[:result].release_date.class.should eql(String)
62
62
  result[:result].genres.should eql(["Action and Adventure", "Science-Fiction"])
63
- result[:result].rating.class.should eql(Float)
64
- result[:result].rating.should be > 4
65
- result[:result].rating.should be < 10
66
- result[:result].runtime.should eql(60)
63
+ result[:result].rating.class.should eql(String)
64
+ result[:result].rating.to_f.should be > 4
65
+ result[:result].rating.to_f.should be < 10
66
+ result[:result].runtime.should eql("60")
67
67
  result[:result].actors.class.should eql(Array)
68
68
  result[:result].actors.first.should eql({"Christopher Judge"=>"Teal'c"})
69
69
  result[:result].directors.should eql([])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unified_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
16
- requirement: &70337166374040 !ruby/object:Gem::Requirement
16
+ requirement: &70366345717140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70337166374040
24
+ version_requirements: *70366345717140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: imdb
27
- requirement: &70337166373020 !ruby/object:Gem::Requirement
27
+ requirement: &70366345716240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.6.8
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70337166373020
35
+ version_requirements: *70366345716240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: httparty
38
- requirement: &70337166372180 !ruby/object:Gem::Requirement
38
+ requirement: &70366345715020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.8.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70337166372180
46
+ version_requirements: *70366345715020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: imdb_party
49
- requirement: &70337166371420 !ruby/object:Gem::Requirement
49
+ requirement: &70366345714080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.6.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70337166371420
57
+ version_requirements: *70366345714080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: tvdb_party
60
- requirement: &70337166370800 !ruby/object:Gem::Requirement
60
+ requirement: &70366345713460 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.6.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70337166370800
68
+ version_requirements: *70366345713460
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70337166370320 !ruby/object:Gem::Requirement
71
+ requirement: &70366345712940 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '2.0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70337166370320
79
+ version_requirements: *70366345712940
80
80
  description: Scrapper for multiple Movie Databases
81
81
  email:
82
82
  - bernard.potocki@imanel.org