dfm 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +31 -0
  3. data/bin/dfm +8 -7
  4. data/lib/dfm/version.rb +3 -1
  5. data/lib/dfm.rb +1 -5
  6. metadata +3 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODJlN2RkMDc1YzFkOGNjMmViZWI5Y2EwM2YwMmRiZTkxNjkwYTg5Yw==
4
+ ZjAyNGI2NDE4M2M4NzRmODUwNjQzYjkxZTFjNjQxZTJlNjg3NTAxMA==
5
5
  data.tar.gz: !binary |-
6
- YTAwMTA5OWJiMWZhMWMyZmIyZjMzNWJkZTIyYjBjYTRjNzBjZjNlZQ==
6
+ MzBiY2RkYTcxNmI0ODlhMGE0ZTdhNmU3NjFhMTRkYTBhZGE4ODRiZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2VkNzZjMDNjMDY1ZWMxMTZlNDVmNTI1ZmY4OGU5OTRiYTc0YTJkNDA4MDdj
10
- NDQ4MDg5YzY0YzdiYWJlNzY4ZDI3YTg3OGVmYzRhYTBjMDVjZGNkNGQzNmEz
11
- ZjIwMWE2YjcyOGE1ZGY0Zjg5MTkzOGEyYzBhYjE0ODVhZDE5Yjc=
9
+ M2IxYzYyZGIyZDQzYmU2ZTIyOTM1NzIyYWE1ZDNkM2QwNGZjYTE4OGIxNTJk
10
+ ZmMwYWYzZDZiMTBjMWE0NjVmNmIwOTIyMzg0ODZkNmMyZjgwZTljOWZkZmU4
11
+ ZjYyODNlM2VkMDZkMjAwYWE4NTNkYjMxZjllODFjYThkYTY2NWE=
12
12
  data.tar.gz: !binary |-
13
- MTkzMzZhMDI5NzJhYTBkODg0MzkxNjFkZDUwNDllNmY5OTNlYzFmNmJhZmE0
14
- YjhlN2E2YWJiYzZjMDhiYzdhNTQzZmY1Zjk5M2UxNGYzNDI0MTdjMTc5Mjk4
15
- ODQzODk5ZTc0NDE2YzFkZjk5MTFjNjkxYzZkYWRjNWU0ZmQzYmQ=
13
+ Yjc3OTc5MTlhYmVmOTM5OTgyY2MxZGQyYzg2OGZkZDcwMjE4YjM1ZWIzMDYy
14
+ NTljYjZlNmVmZDJlMjg3NDI1ODFjMmM1ZWJhYjEwM2RiNmE4MjMyZTJjZDYx
15
+ OGMxZWM1MDQ1OWQ2NjBlNzJhNmJlNWMxN2NkZmM1ZDc1MTU1OTE=
data/README.md CHANGED
@@ -2,3 +2,34 @@ dfm
2
2
  ===
3
3
 
4
4
  Duplicate File Manager
5
+
6
+ The purpose of dfm is to locate duplicate files through a recursive search.
7
+
8
+ You can create an instance of the DFM object with optionally secifing the
9
+ directory path and the file extensions.
10
+
11
+ instance = DFM.new( path: './', filters: ["jpg","png"] )
12
+
13
+ If you are using a ruby version before 2 then this would be:
14
+
15
+ instance = DFM.new( { :path => './', :filters => ["jpg","png"] } )
16
+
17
+ Then you may get a hash of the hex matches (indacating files with identical content) by
18
+
19
+ instance.hex
20
+
21
+ And by duplicate faile name by
22
+
23
+ instance.name
24
+
25
+ Either of these can be called with false if you want only single instances of files.
26
+
27
+ instance.hex( false )
28
+ instance.name( false )
29
+
30
+ ---
31
+
32
+ Also included is a command line version which outputs nicely formatted JSON in case
33
+ you would like to use it with anything else. Type `dfm -h` on the command line to get
34
+ a list of available options. Running `dfm` by itself will recursively search the current
35
+ folder for all duplicates by both file name and hash indexes.
data/bin/dfm CHANGED
@@ -13,7 +13,7 @@ options = {}
13
13
  printers = Array.new
14
14
 
15
15
  OptionParser.new do |opts|
16
- opts.banner = "Usage: dfm [options] [path]\nDefaults: dfm -x -d ." + File::SEPARATOR
16
+ opts.banner = "Usage: dfm [options] [path]\nDefaults: dfm -xd ." + File::SEPARATOR
17
17
  opts.on("-f", "--filters FILTERS", Array, "File extension filters") do |filters|
18
18
  options[:filters] = filters
19
19
  end
@@ -33,11 +33,12 @@ end.parse!
33
33
  path = ARGV.select {|i| File.directory? i }[0]
34
34
  program = DFM.new( options.update( { :path => path } ) )
35
35
  if printers.empty?
36
- program.print_duplicates
37
- program.print_duplicates( "name" )
36
+ puts JSON.pretty_generate( program.hex.update( program.name ) )
38
37
  else
39
- if printers.include? "dh"; program.print_duplicates; end
40
- if printers.include? "dn"; program.print_duplicates( "name" ); end
41
- if printers.include? "sh"; program.print_singles; end
42
- if printers.include? "sn"; program.print_singles( "name" ); end
38
+ hash = {}
39
+ if printers.include? "dh"; hash.update( program.hex ); end
40
+ if printers.include? "dn"; hash.update( program.name ); end
41
+ if printers.include? "sh"; hash.update( program.hex( false ) ); end
42
+ if printers.include? "sn"; hash.update( program.name( false ) ); end
43
+ puts JSON.pretty_generate( hash )
43
44
  end
data/lib/dfm/version.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  class DFM
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
5
+ # Version 0.0.3
6
+ # * Updated commandline app to merge miltiple JSON searches as single JSON output
5
7
  # Version 0.0.2
6
8
  # * A little more DRY
7
9
  # * Fixed duplicates of only 2
data/lib/dfm.rb CHANGED
@@ -57,11 +57,7 @@ class DFM
57
57
  end
58
58
 
59
59
  def select_duplicates( opt = { :hash => @files_by_hexdigest, :duplicates => true } )
60
- if opt[ :duplicates ]
61
- opt[ :hash ].select { |k,v| v.length >= 2 }
62
- else
63
- opt[ :hash ].select { |k,v| v.length == 1 }
64
- end
60
+ opt[ :hash ].select { |k,v| opt[ :duplicates ] ? ( v.length >= 2 ) : ( v.length == 1 ) }
65
61
  end
66
62
 
67
63
  def print_match( opt = { :type => "hex", :duplicates => true } )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark / 6ftDan(TM)
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Parse duplicate files to process!
13
+ description: Duplicate File Manager. Parse duplicate files to process!
14
14
  email: webmaster@6ftdan.com
15
15
  executables:
16
16
  - dfm
@@ -45,5 +45,5 @@ rubyforge_project:
45
45
  rubygems_version: 2.2.2
46
46
  signing_key:
47
47
  specification_version: 4
48
- summary: Duplicate File Manager!
48
+ summary: Duplicate File Manager.
49
49
  test_files: []