movie-renamer 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/movie-renamer.rb +8 -10
- data/test/test_movie-renamer.rb +6 -6
- metadata +1 -1
data/lib/movie-renamer.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
2
|
|
6
3
|
require 'imdb'
|
7
4
|
|
@@ -20,12 +17,13 @@ module MovieRenamer
|
|
20
17
|
|
21
18
|
class Movie
|
22
19
|
|
23
|
-
def initialize(filename,
|
24
|
-
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
20
|
+
def initialize(filename,opts={})
|
21
|
+
opts = { year: '', director: '', title: '', part: '', imdb: ''}.merge(opts)
|
22
|
+
@year = opts[:year]
|
23
|
+
@director = opts[:director]
|
24
|
+
@title = opts[:title]
|
25
|
+
@part = opts[:part]
|
26
|
+
@imdb = opts[:imdb]
|
29
27
|
@filename = filename
|
30
28
|
end
|
31
29
|
|
@@ -79,7 +77,7 @@ module MovieRenamer
|
|
79
77
|
# TODO insert logic here
|
80
78
|
filename = File.basename(filename)
|
81
79
|
title = File.basename(filename,'.*')
|
82
|
-
return Movie.new(filename
|
80
|
+
return Movie.new(filename,:title => title)
|
83
81
|
end
|
84
82
|
|
85
83
|
# rename a movie according to movie data
|
data/test/test_movie-renamer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
-
require 'movie-renamer'
|
2
|
+
require File.join(File.dirname(__FILE__),'..', 'lib','movie-renamer')
|
3
3
|
require 'stringio'
|
4
4
|
|
5
5
|
class TestMovieRenamer < Test::Unit::TestCase
|
@@ -23,7 +23,7 @@ class TestMovieRenamer < Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
# test read movie
|
25
25
|
must "create a movie object" do
|
26
|
-
assert_equal MovieRenamer::Movie.new('movie1.avi','
|
26
|
+
assert_equal MovieRenamer::Movie.new('movie1.avi',title: 'movie1'),MovieRenamer::readMovie(@movies.first)
|
27
27
|
end
|
28
28
|
|
29
29
|
# simple checks that rename is done
|
@@ -33,24 +33,24 @@ class TestMovieRenamer < Test::Unit::TestCase
|
|
33
33
|
|
34
34
|
# newname check
|
35
35
|
must "rename a movie correctly" do
|
36
|
-
movie = MovieRenamer::Movie.new
|
36
|
+
movie = MovieRenamer::Movie.new 'movie1.avi', year: '2001' , director: 'me', title: 'famous'
|
37
37
|
assert_equal "2001 - me - famous.avi",MovieRenamer::newName(movie)
|
38
38
|
end
|
39
39
|
|
40
40
|
must "rename a movie correctly with parts" do
|
41
|
-
movie = MovieRenamer::Movie.new
|
41
|
+
movie = MovieRenamer::Movie.new 'movie1.avi', year: '2001' , director: 'me', title: 'famous', part: '1'
|
42
42
|
assert_equal "2001 - me - famous - part1.avi",MovieRenamer::newName(movie)
|
43
43
|
end
|
44
44
|
|
45
45
|
must "rename a movie correctly without part because part is wrong" do
|
46
|
-
movie = MovieRenamer::Movie.new
|
46
|
+
movie = MovieRenamer::Movie.new 'movie1.avi', year: '2001' , director: 'me', title: 'famous', part: ' '
|
47
47
|
assert_equal "2001 - me - famous.avi",MovieRenamer::newName(movie)
|
48
48
|
end
|
49
49
|
|
50
50
|
# print movie info check
|
51
51
|
# XXX usless check for now
|
52
52
|
must "print movie info correctly" do
|
53
|
-
movie = MovieRenamer::Movie.new
|
53
|
+
movie = MovieRenamer::Movie.new 'movie1.avi', year: '2001' , director: 'me', title: 'famous'
|
54
54
|
assert MovieRenamer::printMovieInfo(movie)
|
55
55
|
|
56
56
|
end
|