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.
@@ -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,year = '',director = '',title = '',part = '',imdb = nil)
24
- @year = year
25
- @director = director
26
- @title = title
27
- @part = part
28
- @imdb = imdb
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,'','', title)
80
+ return Movie.new(filename,:title => title)
83
81
  end
84
82
 
85
83
  # rename a movie according to movie data
@@ -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','','','movie1'),MovieRenamer::readMovie(@movies.first)
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('movie1.avi','2001','me','famous')
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('movie1.avi','2001','me','famous','1')
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('movie1.avi','2001','me','famous',' ')
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('movie1.avi','2001','me','famous','1')
53
+ movie = MovieRenamer::Movie.new 'movie1.avi', year: '2001' , director: 'me', title: 'famous'
54
54
  assert MovieRenamer::printMovieInfo(movie)
55
55
 
56
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: movie-renamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ghedamat