diffall 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.10.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.1.3"
12
+ gem "jeweler", "~> 1.8.3"
13
+ gem "simplecov", ">= 0"
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 ippei94da
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,2 @@
1
+ bin/diffall uses external hash commands (md5sum/sha256sum) and not uses Digest library in Ruby 1.9.1.
2
+ Because the Digest library consumes many memory spaces without released.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = diffall
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to diffall
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 ippei94da. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "diffall"
18
+ gem.homepage = "http://github.com/ippei94da/diffall"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{This gem provides a command to check identical files among many files.}
21
+ gem.description = %Q{Checking process is composed of two steps; file size and checksum hash. Not using diff command. User can stop the first step by indicationg an option.}
22
+ gem.email = "ippei94da@gmail.com"
23
+ gem.authors = ["ippei94da"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "diffall #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
data/bin/diffall ADDED
@@ -0,0 +1,56 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ #HASH_COMMAND = 'sha256sum'
5
+ HASH_COMMAND = 'md5sum'
6
+
7
+ require "pp"
8
+ require "optparse"
9
+ #require "digest/sha1"
10
+ #require "digest/sha2"
11
+ require "rubygems"
12
+ gem "builtinextension"
13
+ require "string_escape_zsh.rb"
14
+ #/home/ippei/devel/builtinextension/lib/
15
+
16
+ def show_groups(hash)
17
+ hash.each do |key, files|
18
+ puts key
19
+ files.each do |file|
20
+ puts " " + file
21
+ end
22
+ puts
23
+ end
24
+ end
25
+
26
+ ## option analysis
27
+ OPTIONS = {}
28
+ op = OptionParser.new
29
+ op.on("-s" , "--size" , "Check size."){OPTIONS[:size] = true}
30
+ op.on("-h" , "--hash", "Check size and hash(default)."){OPTIONS[:hash] = true}
31
+ #op.on("-d" , "--diff" , "Check size, checksum and diff command."){OPTIONS[:size] = true}
32
+ op.parse!(ARGV)
33
+
34
+ size_groups = {}
35
+ ARGV.each do |file|
36
+ size_groups[File.size(file)] ||= []
37
+ size_groups[File.size(file)] << file
38
+ end
39
+ if OPTIONS[:size]
40
+ show_groups(size_groups)
41
+ exit
42
+ end
43
+
44
+ hash_groups = {}
45
+ size_groups.each do |size, files|
46
+ next if files.size < 2
47
+ files.each do |file|
48
+ #puts file
49
+ command = "#{HASH_COMMAND} #{file.escape_zsh}"
50
+ hash = `#{command}`.sub(" #{file}", '')
51
+ #hash = Digest::SHA256.hexdigest(File.open(file, "rb").read)
52
+ hash_groups[hash] ||= []
53
+ hash_groups[hash] << file
54
+ end
55
+ end
56
+ show_groups(hash_groups)
data/lib/diffall.rb ADDED
File without changes
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Diffall" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
data/spec/files/12_a ADDED
@@ -0,0 +1 @@
1
+ 12
data/spec/files/1_a ADDED
@@ -0,0 +1 @@
1
+ 1
data/spec/files/1_b ADDED
@@ -0,0 +1 @@
1
+ 1
data/spec/files/2_a ADDED
@@ -0,0 +1 @@
1
+ 2
data/spec/files/2_b ADDED
@@ -0,0 +1 @@
1
+ 2
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'diffall'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diffall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ippei94da
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &87381160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.10.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *87381160
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &87380860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.12'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *87380860
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &87380580 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.3
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *87380580
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &87380310 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *87380310
58
+ - !ruby/object:Gem::Dependency
59
+ name: simplecov
60
+ requirement: &87380010 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *87380010
69
+ description: Checking process is composed of two steps; file size and checksum hash.
70
+ Not using diff command. User can stop the first step by indicationg an option.
71
+ email: ippei94da@gmail.com
72
+ executables:
73
+ - diffall
74
+ extensions: []
75
+ extra_rdoc_files:
76
+ - LICENSE.txt
77
+ - README
78
+ - README.rdoc
79
+ files:
80
+ - .document
81
+ - .rspec
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README
85
+ - README.rdoc
86
+ - Rakefile
87
+ - VERSION
88
+ - bin/diffall
89
+ - lib/diffall.rb
90
+ - spec/diffall_spec.rb
91
+ - spec/files/12_a
92
+ - spec/files/1_a
93
+ - spec/files/1_b
94
+ - spec/files/2_a
95
+ - spec/files/2_b
96
+ - spec/files/empty_a
97
+ - spec/files/empty_b
98
+ - spec/spec_helper.rb
99
+ homepage: http://github.com/ippei94da/diffall
100
+ licenses:
101
+ - MIT
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ segments:
113
+ - 0
114
+ hash: 4894515
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.11
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: This gem provides a command to check identical files among many files.
127
+ test_files: []