royw-dvdprofiler2xbmc 0.1.2 → 0.1.4

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.
Files changed (30) hide show
  1. data/Rakefile +10 -0
  2. data/VERSION.yml +2 -2
  3. data/lib/dvdprofiler2xbmc/controllers/app.rb +4 -3
  4. data/lib/dvdprofiler2xbmc/models/dvdprofiler_info.rb +6 -2
  5. data/lib/dvdprofiler2xbmc/models/imdb_info.rb +6 -0
  6. data/lib/dvdprofiler2xbmc/models/media.rb +5 -6
  7. data/lib/dvdprofiler2xbmc/models/media_files.rb +11 -6
  8. data/lib/dvdprofiler2xbmc/models/tmdb_info.rb +4 -0
  9. data/spec/app_spec.rb +0 -1
  10. data/spec/config_editor_spec.rb +0 -1
  11. data/spec/dvdprofiler2xbmc_spec.rb +56 -56
  12. data/spec/dvdprofiler_info_spec.rb +85 -0
  13. data/spec/fanart_controller_spec.rb +96 -94
  14. data/spec/imdb_info_spec.rb +61 -0
  15. data/spec/media_files_spec.rb +103 -0
  16. data/spec/media_spec.rb +59 -56
  17. data/spec/nfo_controller_spec.rb +71 -72
  18. data/spec/samples/Collection.xml +645 -0
  19. data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0120616&api_key=7a2f6eb9b6aa01651000f0a9324db835 +26 -0
  20. data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0209163&api_key=7a2f6eb9b6aa01651000f0a9324db835 +26 -0
  21. data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0277296&api_key=7a2f6eb9b6aa01651000f0a9324db835 +8 -0
  22. data/spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0465234&api_key= +3 -0
  23. data/spec/samples/www.imdb.com/find?q=The+Mummy+Returns;s=tt +522 -0
  24. data/spec/samples/www.imdb.com/find?q=The+Mummy;s=tt +527 -0
  25. data/spec/samples/www.imdb.com/find?q=The+Scorpion+King;s=tt +526 -0
  26. data/spec/spec_helper.rb +2 -0
  27. data/spec/tmdb_info_spec.rb +47 -0
  28. data/spec/xbmc_info_spec.rb +31 -28
  29. metadata +17 -3
  30. data/lib/dvdprofiler2xbmc/open_cache_extension.rb +0 -39
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,8 @@ rescue LoadError
6
6
  require 'spec'
7
7
  end
8
8
 
9
+ require 'ruby-debug'
10
+
9
11
  $LOAD_PATH.unshift(File.dirname(__FILE__))
10
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
13
 
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ require 'tempfile'
4
+
5
+ # Time to add your specs!
6
+ # http://rspec.info/
7
+
8
+ describe "TmdbInfo" do
9
+
10
+ before(:all) do
11
+ logger = Log4r::Logger.new('dvdprofiler2xbmc')
12
+ logger.outputters = Log4r::StdoutOutputter.new(:console)
13
+ Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
14
+ logger.level = Log4r::WARN
15
+ AppConfig.default
16
+ AppConfig[:logger] = logger
17
+ AppConfig.load
18
+ File.mkdirs(TMPDIR)
19
+ end
20
+
21
+ describe "Finder" do
22
+ it "should find a profile" do
23
+ info = TmdbInfo.find(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => nil)
24
+ info.should_not be_nil
25
+ end
26
+
27
+ it "should return nil if profile not found" do
28
+ info = TmdbInfo.find(:title => 'should not find this title', :api_key => TMDB_API_KEY, :filespec => nil)
29
+ info.should be_nil
30
+ end
31
+ end
32
+
33
+ describe "Attributes" do
34
+ it "should generate xbmc_info" do
35
+ info = TmdbInfo.find(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => nil)
36
+ info.to_xbmc_info.length.should > 0
37
+ end
38
+
39
+ it "should generate valid xbmc_info" do
40
+ info = TmdbInfo.find(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => nil)
41
+ xbmc_info = info.to_xbmc_info
42
+ xbmc_info['plot'].should =~ /^Treasure hunter/
43
+ end
44
+ end
45
+
46
+ end
47
+
@@ -16,7 +16,6 @@ describe "XbmcInfo" do
16
16
  AppConfig[:logger] = logger
17
17
  AppConfig.load
18
18
  File.mkdirs(TMPDIR)
19
- AppConfig[:logger].warn { "\nXbmcInfo Specs" }
20
19
  end
21
20
 
22
21
  before(:each) do
@@ -28,40 +27,44 @@ describe "XbmcInfo" do
28
27
  Dir.glob(File.join(TMPDIR,'xbmcinfo_*')).each { |filename| File.delete(filename) }
29
28
  end
30
29
 
31
- it "should load from the .nfo file" do
32
- @xbmc_info.movie['title'].first.should == 'Die Hard'
33
- end
30
+ describe "File" do
31
+ it "should load from the .nfo file" do
32
+ @xbmc_info.movie['title'].first.should == 'Die Hard'
33
+ end
34
34
 
35
- it "should create a .nfo file" do
36
- outfile = Tempfile.new('xbmcinfo_spec_create', TMPDIR)
37
- new_xbmc_info = XbmcInfo.new(outfile.path)
38
- new_xbmc_info.movie = @xbmc_info.movie
39
- new_xbmc_info.save
40
- (File.exist?(outfile.path).should be_true) && (File.size(outfile.path).should > 0)
41
- end
35
+ it "should create a .nfo file" do
36
+ outfile = Tempfile.new('xbmcinfo_spec_create', TMPDIR)
37
+ new_xbmc_info = XbmcInfo.new(outfile.path)
38
+ new_xbmc_info.movie = @xbmc_info.movie
39
+ new_xbmc_info.save
40
+ (File.exist?(outfile.path).should be_true) && (File.size(outfile.path).should > 0)
41
+ end
42
42
 
43
- it "should overwrite the .nfo file" do
44
- outfile = Tempfile.new('xbmcinfo_spec_overwrite', TMPDIR)
45
- new_xbmc_info = XbmcInfo.new(outfile.path)
46
- new_xbmc_info.movie = @xbmc_info.movie
47
- new_xbmc_info.save
48
- verify_xbmc_info = XbmcInfo.new(outfile.path)
49
- verify_xbmc_info.movie.should == @xbmc_info.movie
50
- end
43
+ it "should overwrite the .nfo file" do
44
+ outfile = Tempfile.new('xbmcinfo_spec_overwrite', TMPDIR)
45
+ new_xbmc_info = XbmcInfo.new(outfile.path)
46
+ new_xbmc_info.movie = @xbmc_info.movie
47
+ new_xbmc_info.save
48
+ verify_xbmc_info = XbmcInfo.new(outfile.path)
49
+ verify_xbmc_info.movie.should == @xbmc_info.movie
50
+ end
51
51
 
52
- it "should not overwrite the .nfo file if not changed"
52
+ it "should not overwrite the .nfo file if not changed"
53
53
 
54
- it "should overwrite the .nfo file when changed"
54
+ it "should overwrite the .nfo file when changed"
55
+ end
55
56
 
56
- it "should be able to convert to xml and then from xml" do
57
- hash = nil
58
- begin
59
- xml = @xbmc_info.to_xml
60
- hash = XmlSimple.xml_in(xml)
61
- rescue
57
+ describe "XML" do
58
+ it "should be able to convert to xml and then from xml" do
62
59
  hash = nil
60
+ begin
61
+ xml = @xbmc_info.to_xml
62
+ hash = XmlSimple.xml_in(xml)
63
+ rescue
64
+ hash = nil
65
+ end
66
+ hash.should_not be_nil
63
67
  end
64
- hash.should_not be_nil
65
68
  end
66
69
 
67
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-dvdprofiler2xbmc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
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-23 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable: dvdprofiler2xbmc
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -150,13 +150,15 @@ files:
150
150
  - lib/dvdprofiler2xbmc/models/media_files.rb
151
151
  - lib/dvdprofiler2xbmc/models/tmdb_info.rb
152
152
  - lib/dvdprofiler2xbmc/models/xbmc_info.rb
153
- - lib/dvdprofiler2xbmc/open_cache_extension.rb
154
153
  - lib/dvdprofiler2xbmc/views/cli.rb
155
154
  - lib/dvdprofiler2xbmc/views/config_editor.rb
156
155
  - spec/app_spec.rb
157
156
  - spec/config_editor_spec.rb
158
157
  - spec/dvdprofiler2xbmc_spec.rb
158
+ - spec/dvdprofiler_info_spec.rb
159
159
  - spec/fanart_controller_spec.rb
160
+ - spec/imdb_info_spec.rb
161
+ - spec/media_files_spec.rb
160
162
  - spec/media_spec.rb
161
163
  - spec/nfo_controller_spec.rb
162
164
  - spec/samples/Collection.xml
@@ -182,14 +184,18 @@ files:
182
184
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0114437&api_key=7a2f6eb9b6aa01651000f0a9324db835
183
185
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0114924&api_key=7a2f6eb9b6aa01651000f0a9324db835
184
186
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0118617&api_key=7a2f6eb9b6aa01651000f0a9324db835
187
+ - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0120616&api_key=7a2f6eb9b6aa01651000f0a9324db835
188
+ - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0209163&api_key=7a2f6eb9b6aa01651000f0a9324db835
185
189
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0213149&api_key=7a2f6eb9b6aa01651000f0a9324db835
186
190
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0238112&api_key=7a2f6eb9b6aa01651000f0a9324db835
187
191
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0276751&api_key=7a2f6eb9b6aa01651000f0a9324db835
192
+ - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0277296&api_key=7a2f6eb9b6aa01651000f0a9324db835
188
193
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0318974&api_key=7a2f6eb9b6aa01651000f0a9324db835
189
194
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0368891&api_key=7a2f6eb9b6aa01651000f0a9324db835
190
195
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0388976&api_key=7a2f6eb9b6aa01651000f0a9324db835
191
196
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0407511&api_key=7a2f6eb9b6aa01651000f0a9324db835
192
197
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0454824&api_key=7a2f6eb9b6aa01651000f0a9324db835
198
+ - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0465234&api_key=
193
199
  - spec/samples/api.themoviedb.org/2.0/Movie.imdbLookup?imdb_id=tt0465234&api_key=7a2f6eb9b6aa01651000f0a9324db835
194
200
  - spec/samples/www.imdb.com/find?q=%2Abatteries+not+included;s=tt
195
201
  - spec/samples/www.imdb.com/find?q=About+a+Boy;s=tt
@@ -231,6 +237,9 @@ files:
231
237
  - spec/samples/www.imdb.com/find?q=The+Man+from+Snowy+River;s=tt
232
238
  - spec/samples/www.imdb.com/find?q=The+Mummy+Collector%27s+Set;s=tt
233
239
  - spec/samples/www.imdb.com/find?q=The+Mummy+Collector+s+Set;s=tt
240
+ - spec/samples/www.imdb.com/find?q=The+Mummy+Returns;s=tt
241
+ - spec/samples/www.imdb.com/find?q=The+Mummy;s=tt
242
+ - spec/samples/www.imdb.com/find?q=The+Scorpion+King;s=tt
234
243
  - spec/samples/www.imdb.com/find?q=Topper+Topper+%26+Topper+Returns;s=tt
235
244
  - spec/samples/www.imdb.com/find?q=batteries+not+included;s=tt
236
245
  - spec/samples/www.themoviedb.org/image/backdrops/13391/Sniper_1__Odst%c4%b9%e2%84%a2elova%c3%84%c5%a4_.jpg
@@ -247,6 +256,7 @@ files:
247
256
  - spec/samples/www.themoviedb.org/image/backdrops/8579/L%c3%a9on-fanart_thumb.jpg
248
257
  - spec/spec.opts
249
258
  - spec/spec_helper.rb
259
+ - spec/tmdb_info_spec.rb
250
260
  - spec/xbmc_info_spec.rb
251
261
  - test/test_dvdprofiler2xbmc.rb
252
262
  - test/test_dvdprofiler2xbmc_cli.rb
@@ -280,12 +290,16 @@ summary: TODO
280
290
  test_files:
281
291
  - spec/spec_helper.rb
282
292
  - spec/app_spec.rb
293
+ - spec/dvdprofiler_info_spec.rb
294
+ - spec/imdb_info_spec.rb
283
295
  - spec/config_editor_spec.rb
284
296
  - spec/fanart_controller_spec.rb
285
297
  - spec/media_spec.rb
298
+ - spec/tmdb_info_spec.rb
286
299
  - spec/nfo_controller_spec.rb
287
300
  - spec/xbmc_info_spec.rb
288
301
  - spec/dvdprofiler2xbmc_spec.rb
302
+ - spec/media_files_spec.rb
289
303
  - test/test_dvdprofiler2xbmc.rb
290
304
  - test/test_helper.rb
291
305
  - test/test_dvdprofiler2xbmc_cli.rb
@@ -1,39 +0,0 @@
1
-
2
- #
3
- class Kernel
4
- attr_accessor :html_cache_dir
5
- @html_cache_dir = '/tmp'
6
-
7
- # cache any files read using http protocol
8
- def open_cache(url)
9
- if url =~ /^https?:\/\//i
10
- filespec = url.gsub(/^http:\//, @html_cache_dir).gsub(/\/$/, '.html')
11
- begin
12
- fh = open(filespec)
13
- rescue Exception
14
- fh = open(url)
15
- cache_html_files(filespec, fh.read)
16
- fh.rewind
17
- end
18
- else
19
- fh = open(url)
20
- end
21
- fh
22
- end
23
-
24
- private
25
-
26
- # this is used to save imdb pages so they may be used by rspec
27
- def cache_html_files(filespec, html)
28
- begin
29
- unless File.exist?(filespec)
30
- puts "caching #{filespec}"
31
- File.mkdirs(File.dirname(filespec))
32
- File.open(filespec, 'w') { |f| f.puts html }
33
- end
34
- rescue Exception => eMsg
35
- puts eMsg.to_s
36
- end
37
- end
38
-
39
- end