osdb 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe OSDb::Movie do
3
+ describe OSDb::MovieFile do
4
4
 
5
5
  subject do
6
- OSDb::Movie.new(File.dirname(__FILE__) + '/../fixtures/somemovie.avi')
6
+ OSDb::MovieFile.new(File.dirname(__FILE__) + '/../fixtures/somemovie.avi')
7
7
  end
8
8
 
9
9
  its(:hash) { should == '243339b48f4e8741' }
@@ -24,40 +24,51 @@ describe OSDb::Server do
24
24
  end
25
25
 
26
26
  it 'should respond to #info' do
27
- info = subject.info
28
- expected_info.each do |key, value|
29
- info[key].should == value
27
+ VCR.use_cassette('server_info') do
28
+ info = subject.info
29
+ expected_info.each do |key, value|
30
+ info[key].should == value
31
+ end
32
+ info['seconds'].should be_a(Float)
33
+ info['last_update_strings'].should be_a(Hash)
30
34
  end
31
- info['seconds'].should be_a(Float)
32
- info['last_update_strings'].should be_a(Hash)
33
35
  end
34
36
 
35
37
  it 'should automatically call #login when token is needed' do
36
- subject.instance_variable_get('@token').should be_nil
37
- subject.token.should match(/[a-z0-9]{26}/)
38
- subject.instance_variable_get('@token').should == subject.token
38
+ VCR.use_cassette('log_in') do
39
+ subject.instance_variable_get('@token').should be_nil
40
+ subject.token.should match(/[a-z0-9]{26}/)
41
+ subject.instance_variable_get('@token').should == subject.token
42
+ end
39
43
  end
40
44
 
41
45
  it 'should clear @login after #logout' do
42
- expect{
43
- subject.logout
44
- }.to change{ subject.instance_variable_get('@token') }.from(instance_of(String)).to(nil)
46
+ VCR.use_cassette('log_in') do
47
+ subject.token
48
+ end
49
+ VCR.use_cassette('log_out') do
50
+ expect {
51
+ subject.logout
52
+ }.to change{ subject.instance_variable_get('@token') }.from(instance_of(String)).to(nil)
53
+ end
45
54
  end
46
55
 
47
56
  describe "#check_movie_hash" do
48
57
 
49
58
  it 'should identify movie' do
50
- subject.check_movie_hash('37d0c7d0cfcbe280')['data'].should == {
51
- "37d0c7d0cfcbe280" => {
52
- "MovieYear" => "1996",
53
- "MovieImdbID" => "0117500",
54
- "MovieName" => "The Rock",
55
- "MovieHash" => "37d0c7d0cfcbe280",
56
- "MovieKind" => "movie",
57
- "SeriesSeason" => "0",
58
- "SeriesEpisode" => "0"
59
+ VCR.use_cassette('check_movie_hash') do
60
+ subject.check_movie_hash('37d0c7d0cfcbe280')['data'].should == {
61
+ "37d0c7d0cfcbe280" => {
62
+ "MovieYear" => "1996",
63
+ "MovieImdbID" => "0117500",
64
+ "MovieName" => "The Rock",
65
+ "MovieHash" => "37d0c7d0cfcbe280",
66
+ "MovieKind" => "movie",
67
+ "SeriesSeason" => "0",
68
+ "SeriesEpisode" => "0"
69
+ }
59
70
  }
60
- }
71
+ end
61
72
  end
62
73
 
63
74
  end
@@ -65,22 +76,26 @@ describe OSDb::Server do
65
76
  describe '#search_subtitles' do
66
77
 
67
78
  it 'can search by hash and size' do
68
- subs = subject.search_subtitles(:moviehash => 'bd71526264fd8bd9', :moviebytesize => '183406990', :sublanguageid => 'fre')
69
- subs.should be_a(Array)
70
- subs.length.should >= 2
71
- subs.each do |sub|
72
- sub.language.name.should == 'French'
73
- sub.raw_data['MovieName'].should =~ /How I Met Your Mother/
79
+ VCR.use_cassette('search_subtitles_for_himym') do
80
+ subs = subject.search_subtitles(:moviehash => 'bd71526264fd8bd9', :moviebytesize => '183406990', :sublanguageid => 'fre')
81
+ subs.should be_a(Array)
82
+ subs.length.should >= 2
83
+ subs.each do |sub|
84
+ sub.language.name.should == 'French'
85
+ sub.raw_data['MovieName'].should =~ /How I Met Your Mother/
86
+ end
74
87
  end
75
88
  end
76
89
 
77
90
  it 'can search by imdbid' do
78
- subs = subject.search_subtitles(:imdbid => "0117500", :sublanguageid => 'fre')
79
- subs.should be_a(Array)
80
- subs.length.should >= 1
81
- subs.each do |sub|
82
- sub.language.name.should == 'French'
83
- sub.raw_data['MovieName'].should == 'The Rock'
91
+ VCR.use_cassette('search_subtitles_for_the_rock') do
92
+ subs = subject.search_subtitles(:imdbid => "0117500", :sublanguageid => 'fre')
93
+ subs.should be_a(Array)
94
+ subs.length.should >= 1
95
+ subs.each do |sub|
96
+ sub.language.name.should == 'French'
97
+ sub.raw_data['MovieName'].should == 'The Rock'
98
+ end
84
99
  end
85
100
  end
86
101
 
@@ -88,9 +103,19 @@ describe OSDb::Server do
88
103
 
89
104
  describe "#search_imdb" do
90
105
  it "can search imdb by title" do
91
- imdb = subject.search_imdb(:query => "Troy")
92
- imdb.each do |movie|
93
- movie.title.should =~ /Troy/
106
+ VCR.use_cassette('search_imdb') do
107
+ imdb = subject.search_imdb(:query => "Troy")
108
+ imdb.each do |movie|
109
+ movie.title.should =~ /Troy/
110
+ end
111
+ end
112
+ end
113
+
114
+ it "can get the details of a movie from an id" do
115
+ VCR.use_cassette('get_imdb_movie_details') do
116
+ movie = subject.get_imdb_movie_details('0176415')
117
+ movie.title.should == 'El abuelo'
118
+ movie.year.should == 1998
94
119
  end
95
120
  end
96
121
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/../lib/osdb'
2
2
  require 'rspec'
3
3
 
4
+ require 'webmock/rspec'
5
+ require 'vcr'
6
+
4
7
  RSpec.configure do |c|
5
8
  c.mock_with :rspec
6
- end
9
+ end
10
+
11
+ VCR.configure do |c|
12
+ c.cassette_library_dir = 'spec/fixtures/http'
13
+ c.hook_into :webmock
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-26 00:00:00.000000000 Z
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70311392052000 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,60 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70311392052000
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70311392067940 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
28
41
  none: false
29
42
  requirements:
30
43
  - - ! '>='
31
44
  - !ruby/object:Gem::Version
32
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: webmock
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.11
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.11
62
+ - !ruby/object:Gem::Dependency
63
+ name: vcr
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.3.0
33
70
  type: :development
34
71
  prerelease: false
35
- version_requirements: *70311392067940
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.3.0
36
78
  description:
37
79
  email:
38
80
  - jean.boussier @nospam@ gmail.com
@@ -49,15 +91,37 @@ files:
49
91
  - Rakefile
50
92
  - bin/getsub
51
93
  - lib/osdb.rb
94
+ - lib/osdb/finder.rb
95
+ - lib/osdb/finder/first.rb
96
+ - lib/osdb/finder/interactive.rb
97
+ - lib/osdb/finder/score.rb
52
98
  - lib/osdb/language.rb
53
99
  - lib/osdb/movie.rb
100
+ - lib/osdb/movie_file.rb
101
+ - lib/osdb/search.rb
102
+ - lib/osdb/search/imdb.rb
103
+ - lib/osdb/search/movie_hash.rb
104
+ - lib/osdb/search/name.rb
105
+ - lib/osdb/search/path.rb
106
+ - lib/osdb/selector.rb
107
+ - lib/osdb/selector/format.rb
108
+ - lib/osdb/selector/movie.rb
54
109
  - lib/osdb/server.rb
55
110
  - lib/osdb/sub.rb
111
+ - lib/osdb/subtitle_finder.rb
56
112
  - lib/osdb/version.rb
57
113
  - osdb.gemspec
114
+ - spec/fixtures/http/check_movie_hash.yml
115
+ - spec/fixtures/http/get_imdb_movie_details.yml
116
+ - spec/fixtures/http/log_in.yml
117
+ - spec/fixtures/http/log_out.yml
118
+ - spec/fixtures/http/search_imdb.yml
119
+ - spec/fixtures/http/search_subtitles_for_himym.yml
120
+ - spec/fixtures/http/search_subtitles_for_the_rock.yml
121
+ - spec/fixtures/http/server_info.yml
58
122
  - spec/fixtures/somemovie.avi
59
123
  - spec/osdb/language_spec.rb
60
- - spec/osdb/movie_spec.rb
124
+ - spec/osdb/movie_file_spec.rb
61
125
  - spec/osdb/server_spec.rb
62
126
  - spec/osdb/sub_spec.rb
63
127
  - spec/spec_helper.rb
@@ -73,22 +137,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
137
  - - ! '>='
74
138
  - !ruby/object:Gem::Version
75
139
  version: '0'
140
+ segments:
141
+ - 0
142
+ hash: 3778629745082147470
76
143
  required_rubygems_version: !ruby/object:Gem::Requirement
77
144
  none: false
78
145
  requirements:
79
146
  - - ! '>='
80
147
  - !ruby/object:Gem::Version
81
148
  version: '0'
149
+ segments:
150
+ - 0
151
+ hash: 3778629745082147470
82
152
  requirements: []
83
153
  rubyforge_project: osdb
84
- rubygems_version: 1.8.15
154
+ rubygems_version: 1.8.24
85
155
  signing_key:
86
156
  specification_version: 3
87
157
  summary: Ruby library to access OSDb services like OpenSubtitles.org
88
158
  test_files:
159
+ - spec/fixtures/http/check_movie_hash.yml
160
+ - spec/fixtures/http/get_imdb_movie_details.yml
161
+ - spec/fixtures/http/log_in.yml
162
+ - spec/fixtures/http/log_out.yml
163
+ - spec/fixtures/http/search_imdb.yml
164
+ - spec/fixtures/http/search_subtitles_for_himym.yml
165
+ - spec/fixtures/http/search_subtitles_for_the_rock.yml
166
+ - spec/fixtures/http/server_info.yml
89
167
  - spec/fixtures/somemovie.avi
90
168
  - spec/osdb/language_spec.rb
91
- - spec/osdb/movie_spec.rb
169
+ - spec/osdb/movie_file_spec.rb
92
170
  - spec/osdb/server_spec.rb
93
171
  - spec/osdb/sub_spec.rb
94
172
  - spec/spec_helper.rb