right_data 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/main.rb +16 -5
  2. metadata +3 -8
data/lib/main.rb CHANGED
@@ -30,11 +30,17 @@ module RightData
30
30
  return false unless self.is_visual_media?(a) && self.is_visual_media?(b)
31
31
  # rmagick1.signature <=> rmagick2.signature
32
32
  # rmagick1.compare_channel(rmagick2, MeanAbsoluteErrorMetric).last == 0
33
- cmd = "compare -metric AE \"#{a.gsub(/\"/,'\"')}\" \"#{b.gsub(/\"/,'\"')}\" /dev/null 2>&1"
34
- puts "Executing comparison: #{cmd}"
35
- # >> a = `compare -metric ae a.png b.png /dev/null 2>&1`
36
- # => "0\n"
37
- "0" == `#{cmd}`.chomp
33
+
34
+ if true # Do fuzzy test:
35
+ cmd = "compare -metric AE -fuzz 5% -compose src \"#{a.gsub(/\"/,'\"')}\" \"#{b.gsub(/\"/,'\"')}\" /dev/null 2>&1"
36
+ `#{cmd}`.chomp.to_i < 1000
37
+ else
38
+ cmd = "compare -metric AE -compose src \"#{a.gsub(/\"/,'\"')}\" \"#{b.gsub(/\"/,'\"')}\" /dev/null 2>&1"
39
+ # puts "Executing comparison: #{cmd}"
40
+ # >> a = `compare -metric ae a.png b.png /dev/null 2>&1`
41
+ # => "0\n"
42
+ "0" == `#{cmd}`.chomp
43
+ end
38
44
 
39
45
  # TODO Consider checking rotated 90,180,270 degrees and scaled to other image...
40
46
  end
@@ -224,6 +230,10 @@ module RightData
224
230
 
225
231
  # dups = check_file_in_index(master_index, "/Users/jonathan/Dropbox/2261093437_fac9fa9008_b.jpg")
226
232
 
233
+ # Get prune count for progress updates:
234
+ prune_count = `cd #{prune}; ls -laR | wc -l`.chomp.to_i
235
+ prune_updates = (0..25).inject({}) { |a,i| a[(i * (prune_count / 25)).to_i]=true;a }
236
+
227
237
  count = 0
228
238
 
229
239
  # Recursively compare the files in the filesystem.
@@ -236,6 +246,7 @@ module RightData
236
246
  tree = FileSystemItem.new(prune, :parent => nil)
237
247
  # Mark the nodes:
238
248
  tree.traverse do |n|
249
+ puts "# [#{count} / #{prune_count}] #{((count/prune_count)*100).to_i}%" if prune_updates[count]
239
250
  # Could keep track of empty dirs too...
240
251
  if File.directory?(n.path)
241
252
  # If empty dir...
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_data
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 7
9
- - 8
10
- version: 0.7.8
8
+ - 9
9
+ version: 0.7.9
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jonathan Siegel
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-09 00:00:00 +01:00
17
+ date: 2010-10-10 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
@@ -40,7 +38,6 @@ dependencies:
40
38
  requirements:
41
39
  - - ">="
42
40
  - !ruby/object:Gem::Version
43
- hash: 3
44
41
  segments:
45
42
  - 0
46
43
  version: "0"
@@ -78,7 +75,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
75
  requirements:
79
76
  - - ">="
80
77
  - !ruby/object:Gem::Version
81
- hash: 3
82
78
  segments:
83
79
  - 0
84
80
  version: "0"
@@ -87,7 +83,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
83
  requirements:
88
84
  - - ">="
89
85
  - !ruby/object:Gem::Version
90
- hash: 3
91
86
  segments:
92
87
  - 0
93
88
  version: "0"