melon 0.3.0 → 0.4.0

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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.4.0 2011-01-31
2
+ * Major improvements:
3
+ * Updated hashing strategy to be more robust against collisions
4
+
1
5
  === 0.3.0 2011-01-28
2
6
  * Major improvements:
3
7
  * added 'help' command'
@@ -2,6 +2,6 @@ require 'rubygems'
2
2
  require 'aruba/cucumber'
3
3
 
4
4
  Before do
5
- @aruba_timeout_seconds = 2
5
+ @aruba_timeout_seconds = 5
6
6
  end
7
7
 
data/lib/melon/hasher.rb CHANGED
@@ -4,11 +4,33 @@ require 'digestif/hasher'
4
4
  module Melon
5
5
  class Hasher
6
6
  # TODO: scale seek size up with file size
7
+ # 100M => 0
8
+ # 1000M =>
9
+ # 2000M =>
10
+ #
11
+ # Data points for 3s:
12
+ # 4194996638 => 40000000
13
+ # 6372304495 => 80000000
14
+ # 2346880790 => 29000000
15
+ # 11730897879 => 190000000
16
+ # 5451346280 => 76000000
17
+ # 7007074117 => 95000000
7
18
  def self.digest(filename)
8
19
  hasher = Digestif::Hasher.new(filename)
9
20
  hasher.options.read_size = 40000
10
- hasher.options.seek_size = 80000000
21
+ hasher.options.seek_size = self.seek_size(filename)
22
+ # hasher.options.seek_size = 80000000
11
23
  hasher.digest
12
24
  end
25
+
26
+ def self.seek_size(filename)
27
+ # get the file size in megs
28
+ file_size = File.size(filename) / 1024 ** 2
29
+ case file_size
30
+ when 0...150 then 0
31
+ when 150...2000 then 15000000
32
+ else file_size * 18629 - 24863642
33
+ end
34
+ end
13
35
  end
14
36
  end
data/lib/melon/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Melon
2
2
  def self.version
3
- "0.3.0"
3
+ "0.4.0"
4
4
  end
5
5
 
6
6
  def self.version_string
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: melon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Roberts
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-28 00:00:00 -05:00
18
+ date: 2011-01-31 00:00:00 -05:00
19
19
  default_executable: melon
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency