royw-dvdprofiler_collection 0.1.4 → 0.1.5

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.
data/Rakefile CHANGED
@@ -30,6 +30,7 @@ require 'spec/rake/spectask'
30
30
  Spec::Rake::SpecTask.new(:spec) do |spec|
31
31
  spec.libs << 'lib' << 'spec'
32
32
  spec.spec_files = FileList['spec/**/*_spec.rb']
33
+ spec.spec_opts = ["--color", "--format nested"]
33
34
  end
34
35
 
35
36
  Spec::Rake::SpecTask.new(:rcov) do |spec|
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 4
3
- :major: 0
4
2
  :minor: 1
3
+ :patch: 5
4
+ :major: 0
@@ -13,113 +13,121 @@ describe "Collection" do
13
13
 
14
14
  before(:all) do
15
15
  File.mkdirs(TMPDIR)
16
- puts "\nCollection Specs"
17
16
  end
18
17
 
19
- it 'should build Collection.yaml when Collection.yaml does not exist' do
20
- File.delete(COLLECTION_YAML) if File.exist?(COLLECTION_YAML)
21
- collection = Collection.new(COLLECTION_XML)
22
- File.exist?(COLLECTION_YAML).should be_true
23
- end
18
+ describe "Parsing Collection.xml/yaml" do
19
+ it 'should build Collection.yaml when Collection.yaml does not exist' do
20
+ File.delete(COLLECTION_YAML) if File.exist?(COLLECTION_YAML)
21
+ collection = Collection.new(COLLECTION_XML)
22
+ File.exist?(COLLECTION_YAML).should be_true
23
+ end
24
24
 
25
- it 'should build Collection.yaml when Collection.xml is newer than existing Collection.yaml' do
26
- File.delete(COLLECTION_YAML) if File.exist?(COLLECTION_YAML)
27
- Collection.new(COLLECTION_XML)
28
- old_yaml_mtime = File.mtime(COLLECTION_YAML)
29
- old_xml_mtime = File.mtime(COLLECTION_XML)
25
+ it 'should build Collection.yaml when Collection.xml is newer than existing Collection.yaml' do
26
+ File.delete(COLLECTION_YAML) if File.exist?(COLLECTION_YAML)
27
+ Collection.new(COLLECTION_XML)
28
+ old_yaml_mtime = File.mtime(COLLECTION_YAML)
29
+ old_xml_mtime = File.mtime(COLLECTION_XML)
30
30
 
31
- sleep(2) # make sure there will be a difference between old yaml and new xml
32
- FileUtils.touch(COLLECTION_XML)
33
- new_xml_mtime = File.mtime(COLLECTION_XML)
31
+ sleep(2) # make sure there will be a difference between old yaml and new xml
32
+ FileUtils.touch(COLLECTION_XML)
33
+ new_xml_mtime = File.mtime(COLLECTION_XML)
34
34
 
35
- Collection.new(COLLECTION_XML)
36
- new_yaml_mtime = File.mtime(COLLECTION_YAML)
35
+ Collection.new(COLLECTION_XML)
36
+ new_yaml_mtime = File.mtime(COLLECTION_YAML)
37
37
 
38
- old_yaml_mtime.should < new_yaml_mtime
39
- end
38
+ old_yaml_mtime.should < new_yaml_mtime
39
+ end
40
40
 
41
- it 'should not build Collection.yaml when existing Collection.yaml is newer than Collection.xml' do
42
- File.delete(COLLECTION_YAML) if File.exist?(COLLECTION_YAML)
43
- Collection.new(COLLECTION_XML)
44
- old_yaml_mtime = File.mtime(COLLECTION_YAML)
45
- sleep(2)
41
+ it 'should not build Collection.yaml when existing Collection.yaml is newer than Collection.xml' do
42
+ File.delete(COLLECTION_YAML) if File.exist?(COLLECTION_YAML)
43
+ Collection.new(COLLECTION_XML)
44
+ old_yaml_mtime = File.mtime(COLLECTION_YAML)
45
+ sleep(2)
46
46
 
47
- Collection.new(COLLECTION_XML)
48
- new_yaml_mtime = File.mtime(COLLECTION_YAML)
47
+ Collection.new(COLLECTION_XML)
48
+ new_yaml_mtime = File.mtime(COLLECTION_YAML)
49
49
 
50
- old_yaml_mtime.should == new_yaml_mtime
50
+ old_yaml_mtime.should == new_yaml_mtime
51
+ end
51
52
  end
52
53
 
53
- it 'should have values in isbn_title_hash' do
54
- collection = Collection.new(COLLECTION_XML)
55
- collection.isbn_title_hash.empty?.should be_false
56
- end
54
+ describe "Collection contents" do
55
+ it 'should have values in isbn_title_hash' do
56
+ collection = Collection.new(COLLECTION_XML)
57
+ collection.isbn_title_hash.empty?.should be_false
58
+ end
57
59
 
58
- it 'should have values in title_isbh_hash' do
59
- collection = Collection.new(COLLECTION_XML)
60
- collection.title_isbn_hash.empty?.should be_false
61
- end
60
+ it 'should have values in title_isbh_hash' do
61
+ collection = Collection.new(COLLECTION_XML)
62
+ collection.title_isbn_hash.empty?.should be_false
63
+ end
62
64
 
63
- it 'should have values in isbn_dvd_hash' do
64
- collection = Collection.new(COLLECTION_XML)
65
- collection.isbn_dvd_hash.empty?.should be_false
65
+ it 'should have values in isbn_dvd_hash' do
66
+ collection = Collection.new(COLLECTION_XML)
67
+ collection.isbn_dvd_hash.empty?.should be_false
68
+ end
66
69
  end
67
70
 
68
- # dynamically create a set of specs for various title pattern generations
69
- {
70
- 'Extra Spaces' => 'extra spaces',
71
- ' leading spaces' => 'leading spaces',
72
- 'trailing spaces ' => 'trailing spaces',
73
- 'multiple : * [] () {} ~!@#$%^; punctuation' => 'multiple punctuation',
74
- 'replace & with and' => 'replace and with and',
75
- 'remove [foo] square brackets' => 'remove square brackets',
76
- 'remove {foo} curly brackets' => 'remove curly brackets',
77
- 'remove (foo) parens' => 'remove parens',
78
- 'remove &amp; html escapes' => 'remove html escapes',
79
- 'remove widescreen' => 'remove',
80
- 'remove special edition' => 'remove',
81
- }.each do |title, pattern|
82
- it "should replace '#{title}' with '#{pattern}'" do
83
- Collection.title_pattern(title).should == pattern
71
+ describe "Title patterns" do
72
+ # dynamically create a set of specs for various title pattern generations
73
+ {
74
+ 'Extra Spaces' => 'extra spaces',
75
+ ' leading spaces' => 'leading spaces',
76
+ 'trailing spaces ' => 'trailing spaces',
77
+ 'multiple : * [] () {} ~!@#$%^; punctuation' => 'multiple punctuation',
78
+ 'replace & with and' => 'replace and with and',
79
+ 'remove [foo] square brackets' => 'remove square brackets',
80
+ 'remove {foo} curly brackets' => 'remove curly brackets',
81
+ 'remove (foo) parens' => 'remove parens',
82
+ 'remove &amp; html escapes' => 'remove html escapes',
83
+ 'remove widescreen' => 'remove',
84
+ 'remove special edition' => 'remove',
85
+ }.each do |title, pattern|
86
+ it "should replace '#{title}' with '#{pattern}'" do
87
+ Collection.title_pattern(title).should == pattern
88
+ end
84
89
  end
85
90
  end
86
91
 
87
- # dynamically create a set of specs to test title permutations
88
- [
89
- 'foobar',
90
- 'a foobar',
91
- 'an foobar',
92
- 'the foobar'
93
- ].each do |title|
94
- it "should create proper title permutations for '#{title}'" do
95
- Collection.title_permutations(title).sort.should == ['foobar', 'a foobar', 'an foobar', 'the foobar'].sort
92
+ describe "Title permutations" do
93
+ # dynamically create a set of specs to test title permutations
94
+ [
95
+ 'foobar',
96
+ 'a foobar',
97
+ 'an foobar',
98
+ 'the foobar'
99
+ ].each do |title|
100
+ it "should create proper title permutations for '#{title}'" do
101
+ Collection.title_permutations(title).sort.should == ['foobar', 'a foobar', 'an foobar', 'the foobar'].sort
102
+ end
96
103
  end
97
104
  end
98
105
 
99
- it 'should use title patterns in title_isbn_hash' do
100
- collection = Collection.new(COLLECTION_XML)
101
- buf = []
102
- collection.title_isbn_hash.each do |title, isbn|
103
- buf << title unless title == Collection.title_pattern(title)
106
+ describe "Hash contents" do
107
+ it 'should use title patterns in title_isbn_hash' do
108
+ collection = Collection.new(COLLECTION_XML)
109
+ buf = []
110
+ collection.title_isbn_hash.each do |title, isbn|
111
+ buf << title unless title == Collection.title_pattern(title)
112
+ end
113
+ puts buf.join("\n") unless buf.empty?
114
+ buf.empty?.should be_true
104
115
  end
105
- puts buf.join("\n") unless buf.empty?
106
- buf.empty?.should be_true
107
- end
108
116
 
109
- it 'should use actual titles in isbn_title_hash' do
110
- collection = Collection.new(COLLECTION_XML)
111
- buf = []
112
- # collection.isbn_title_hash's value is the actual title
113
- # collection.title_isbn_hash uses the title pattern as the key
114
- # and returns an array of possible isbns, one of which should
115
- # match the key from collection.isbn_title_hash
116
- collection.isbn_title_hash.each do |isbn, actual_title|
117
- title_pattern = Collection.title_pattern(actual_title)
118
- isbns = collection.title_isbn_hash[title_pattern]
119
- buf << actual_title unless isbns.include?(isbn)
117
+ it 'should use actual titles in isbn_title_hash' do
118
+ collection = Collection.new(COLLECTION_XML)
119
+ buf = []
120
+ # collection.isbn_title_hash's value is the actual title
121
+ # collection.title_isbn_hash uses the title pattern as the key
122
+ # and returns an array of possible isbns, one of which should
123
+ # match the key from collection.isbn_title_hash
124
+ collection.isbn_title_hash.each do |isbn, actual_title|
125
+ title_pattern = Collection.title_pattern(actual_title)
126
+ isbns = collection.title_isbn_hash[title_pattern]
127
+ buf << actual_title unless isbns.include?(isbn)
128
+ end
129
+ puts buf.join("\n") unless buf.empty?
130
+ buf.empty?.should be_true
120
131
  end
121
- puts buf.join("\n") unless buf.empty?
122
- buf.empty?.should be_true
123
132
  end
124
-
125
133
  end
@@ -14,7 +14,6 @@ describe "DvdprofilerProfile" do
14
14
  # Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
15
15
  # @logger.level = Log4r::DEBUG
16
16
  File.mkdirs(TMPDIR)
17
- puts "\nDvdprofilerProfile Specs"
18
17
  end
19
18
 
20
19
  before(:each) do
@@ -26,56 +25,62 @@ describe "DvdprofilerProfile" do
26
25
  Dir.glob(File.join(TMPDIR, "dvdprofiler_profile_spec*")).each { |filename| File.delete(filename) }
27
26
  end
28
27
 
29
- it "should find by imdb_id" do
30
- @profile.should_not == nil
31
- end
28
+ describe "Finders" do
29
+ it "should find by imdb_id" do
30
+ @profile.should_not == nil
31
+ end
32
32
 
33
- it "should find by title" do
34
- profile = DvdprofilerProfile.first(:title => 'National Treasure 2: Book of Secrets')
35
- profile.should_not == nil
36
- end
33
+ it "should find by title" do
34
+ profile = DvdprofilerProfile.first(:title => 'National Treasure 2: Book of Secrets')
35
+ profile.should_not == nil
36
+ end
37
37
 
38
- it "should find find by fuzzy title" do
39
- profile = DvdprofilerProfile.first(:title => 'National Treasure 2 Book of Secrets')
40
- profile.should_not == nil
41
- end
38
+ it "should find find by fuzzy title" do
39
+ profile = DvdprofilerProfile.first(:title => 'National Treasure 2 Book of Secrets')
40
+ profile.should_not == nil
41
+ end
42
42
 
43
- it "should find by case insensitive title" do
44
- profile = DvdprofilerProfile.first(:title => 'national treasure 2: book of secrets')
45
- profile.should_not == nil
46
- end
43
+ it "should find by case insensitive title" do
44
+ profile = DvdprofilerProfile.first(:title => 'national treasure 2: book of secrets')
45
+ profile.should_not == nil
46
+ end
47
47
 
48
- it "should be able to convert to xml and then from xml" do
49
- hash = nil
50
- begin
51
- xml = @profile.to_xml
52
- hash = XmlSimple.xml_in(xml)
53
- rescue
54
- hash = nil
48
+ it "should find multiple movies with the same title" do
49
+ profiles = DvdprofilerProfile.all(:title => 'Sabrina')
50
+ profiles.length.should == 2
55
51
  end
56
- hash.should_not be_nil
57
- end
58
52
 
59
- it "should find multiple movies with the same title" do
60
- profiles = DvdprofilerProfile.all(:title => 'Sabrina')
61
- profiles.length.should == 2
62
- end
53
+ it "should find a single movie using the year when multiple movies have the same title" do
54
+ profiles = DvdprofilerProfile.all(:title => 'Sabrina', :year => '1995')
55
+ (profiles.length.should == 1) && (profiles.first.isbn.should == '097363304340')
56
+ end
63
57
 
64
- it "should find a single movie using the year when multiple movies have the same title" do
65
- profiles = DvdprofilerProfile.all(:title => 'Sabrina', :year => '1995')
66
- (profiles.length.should == 1) && (profiles.first.isbn.should == '097363304340')
58
+ it "should find the other single movie using the year when multiple movies have the same title" do
59
+ profiles = DvdprofilerProfile.all(:title => 'Sabrina', :year => '1954')
60
+ (profiles.length.should == 1) && (profiles.first.isbn.should == '097360540246')
61
+ end
67
62
  end
68
63
 
69
- it "should find the other single movie using the year when multiple movies have the same title" do
70
- profiles = DvdprofilerProfile.all(:title => 'Sabrina', :year => '1954')
71
- (profiles.length.should == 1) && (profiles.first.isbn.should == '097360540246')
64
+ describe "XML" do
65
+ it "should be able to convert to xml and then from xml" do
66
+ hash = nil
67
+ begin
68
+ xml = @profile.to_xml
69
+ hash = XmlSimple.xml_in(xml)
70
+ rescue
71
+ hash = nil
72
+ end
73
+ hash.should_not be_nil
74
+ end
72
75
  end
73
76
 
74
- it "should save to a file" do
75
- filespec = get_temp_filename
76
- profile = DvdprofilerProfile.first(:title => 'Sabrina', :year => '1995')
77
- profile.save(filespec)
78
- (File.exist?(filespec) && (File.size(filespec) > 0)).should be_true
77
+ describe "File" do
78
+ it "should save to a file" do
79
+ filespec = get_temp_filename
80
+ profile = DvdprofilerProfile.first(:title => 'Sabrina', :year => '1995')
81
+ profile.save(filespec)
82
+ (File.exist?(filespec) && (File.size(filespec) > 0)).should be_true
83
+ end
79
84
  end
80
85
 
81
86
  def get_temp_filename
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-dvdprofiler_collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
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-22 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency