serienrenamer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.0.5 2012-03-20
2
+
3
+ * improved md5sum performance with an explicit byte count so that only
4
+ the first x bytes are hashed
5
+
1
6
  === 0.0.1 2012-02-01
2
7
 
3
8
  * 1 major enhancement:
data/bin/serienrenamer CHANGED
@@ -22,6 +22,7 @@ STANDARD_CONFIG = {
22
22
  :default_directory => File.join(File.expand_path("~"), "Downloads"),
23
23
  :store_episode_info => false,
24
24
  :store_path => File.join(CONFIG_DIR, "information_storage.yml"),
25
+ :byte_count_for_md5 => 2048,
25
26
  :illegal_words => %w{ ML },
26
27
  }
27
28
 
@@ -96,7 +97,8 @@ Dir.chdir(episode_directory)
96
97
 
97
98
  ###
98
99
  # Iterate through all directory entries
99
- info_storage = Serienrenamer::InformationStore.new(config[:store_path])
100
+ info_storage = Serienrenamer::InformationStore.new(
101
+ config[:store_path], config[:byte_count_for_md5])
100
102
 
101
103
  begin
102
104
 
@@ -159,10 +159,19 @@ module Serienrenamer
159
159
 
160
160
  # returns the md5sum of the episode_path so that it can
161
161
  # be distinguished
162
- def md5sum
162
+ #
163
+ # if :byte_count is set to a value different from nil than these size
164
+ # of bytes is read instead of the whole file, otherwise the whole file
165
+ def md5sum(byte_count=nil)
163
166
  if File.file?(@episodepath)
164
167
  d = Digest::MD5.new
165
- return d.hexdigest(open(@episodepath, 'rb').read)
168
+
169
+ file = File.new(@episodepath)
170
+ if byte_count.nil?
171
+ byte_count = file.size
172
+ end
173
+
174
+ return d.hexdigest(open(file, 'rb').read(byte_count))
166
175
  end
167
176
  return nil
168
177
  end
@@ -6,12 +6,13 @@ module Serienrenamer
6
6
  # in form of a yaml file which can be used from other tools
7
7
  class InformationStore
8
8
 
9
- attr_reader :episode_hash
9
+ attr_reader :episode_hash, :byte_count
10
10
 
11
11
  # this method will load an exisiting yaml file and tries to rebuild
12
12
  # the used hash with episode data
13
- def initialize(yaml_path)
13
+ def initialize(yaml_path, byte_count=2048)
14
14
  @yaml_path = yaml_path
15
+ @byte_count = byte_count
15
16
  @episode_hash = {}
16
17
 
17
18
  if File.file?(yaml_path)
@@ -26,7 +27,7 @@ module Serienrenamer
26
27
  episode.is_a? Serienrenamer::Episode
27
28
 
28
29
  unless @episode_hash[episode.md5sum]
29
- @episode_hash[episode.md5sum] = episode.series
30
+ @episode_hash[episode.md5sum(@byte_count)] = episode.series
30
31
  end
31
32
  end
32
33
 
data/lib/serienrenamer.rb CHANGED
@@ -3,7 +3,7 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
 
5
5
  module Serienrenamer
6
- VERSION = '0.0.4'
6
+ VERSION = '0.0.5'
7
7
 
8
8
  require 'serienrenamer/episode.rb'
9
9
  require 'serienrenamer/information_store.rb'
data/test/test_episode.rb CHANGED
@@ -210,5 +210,9 @@ class TestEpisode < Test::Unit::TestCase
210
210
  assert_equal("d538bf7632bd3b14601015fbc3a39f60", chuck.md5sum)
211
211
  chuck.rename
212
212
  assert_equal("d538bf7632bd3b14601015fbc3a39f60", chuck.md5sum)
213
+
214
+ # explicit bytecount
215
+ assert_equal("78193bb6ffe829b49981b494ab243a82", chuck.md5sum(5))
216
+ assert_equal("0f2788bb1324330898fffddcafd2b8e1", chuck.md5sum(12))
213
217
  end
214
218
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serienrenamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-03-19 00:00:00.000000000 Z
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: wlapi
16
- requirement: &26451300 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.8.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *26451300
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.4
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: mediawiki-gateway
27
- requirement: &26450420 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 0.4.4
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *26450420
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.4
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: mechanize
38
- requirement: &26484760 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '2.3'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *26484760
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: highline
49
- requirement: &26483520 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.6.11
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *26483520
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.11
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rdoc
60
- requirement: &26482500 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '3.10'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *26482500
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.10'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: newgem
71
- requirement: &26481160 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,18 +101,28 @@ dependencies:
76
101
  version: 1.5.3
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *26481160
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.5.3
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: hoe
82
- requirement: &26479520 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
86
116
  - !ruby/object:Gem::Version
87
- version: '2.15'
117
+ version: '2.16'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *26479520
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.16'
91
126
  description: ! 'Ruby Script that brings your series into an appropriate format
92
127
 
93
128
  like "S01E01 - Episodename.avi"'
@@ -150,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
185
  version: '0'
151
186
  requirements: []
152
187
  rubyforge_project: serienrenamer
153
- rubygems_version: 1.8.15
188
+ rubygems_version: 1.8.19
154
189
  signing_key:
155
190
  specification_version: 3
156
191
  summary: Ruby Script that brings your series into an appropriate format like "S01E01