inimit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/.rvmrc ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3@inimit"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.15.5 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ if [[ $- == *i* ]] # check for interactive shells
29
+ then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
30
+ else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
31
+ fi
32
+ else
33
+ # If the environment file has not yet been created, use the RVM CLI to select.
34
+ rvm --create use "$environment_id" || {
35
+ echo "Failed to create RVM environment '${environment_id}'."
36
+ return 1
37
+ }
38
+ fi
39
+
40
+ # If you use bundler, this might be useful to you:
41
+ # if [[ -s Gemfile ]] && {
42
+ # ! builtin command -v bundle >/dev/null ||
43
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
44
+ # }
45
+ # then
46
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
47
+ # gem install bundler
48
+ # fi
49
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
50
+ # then
51
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
52
+ # fi
@@ -0,0 +1,7 @@
1
+ source $HOME/.screenrc
2
+
3
+ screen -t vim 0 $EDITOR -c GG
4
+ screen -t zsh 1
5
+ screen -t spec 2
6
+ stuff "rake"
7
+ select vim
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'paint', '~> 0.8.5'
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem 'bundler'
12
+ gem 'rake'
13
+ gem 'rspec'
14
+ gem 'jeweler'
15
+ gem 'gemcutter'
16
+ gem 'gem-release'
17
+ gem 'rake-version'
18
+ gem 'simplecov'
19
+ end
@@ -0,0 +1,46 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ gem-release (0.4.1)
6
+ gemcutter (0.7.1)
7
+ git (1.2.5)
8
+ jeweler (1.8.4)
9
+ bundler (~> 1.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rdoc
13
+ json (1.7.5)
14
+ multi_json (1.3.6)
15
+ paint (0.8.5)
16
+ rake (0.9.2.2)
17
+ rake-version (0.3.0)
18
+ rake (~> 0.9.2)
19
+ rdoc (3.12)
20
+ json (~> 1.4)
21
+ rspec (2.11.0)
22
+ rspec-core (~> 2.11.0)
23
+ rspec-expectations (~> 2.11.0)
24
+ rspec-mocks (~> 2.11.0)
25
+ rspec-core (2.11.1)
26
+ rspec-expectations (2.11.3)
27
+ diff-lcs (~> 1.1.3)
28
+ rspec-mocks (2.11.2)
29
+ simplecov (0.6.4)
30
+ multi_json (~> 1.0)
31
+ simplecov-html (~> 0.5.3)
32
+ simplecov-html (0.5.3)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler
39
+ gem-release
40
+ gemcutter
41
+ jeweler
42
+ paint (~> 0.8.5)
43
+ rake
44
+ rake-version
45
+ rspec
46
+ simplecov
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Alpha Hydrae
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.
@@ -0,0 +1,13 @@
1
+ # inimit
2
+
3
+ **Recursive file comparison utility.**
4
+
5
+ ## License (MIT)
6
+
7
+ Copyright (c) 2011 Alpha Hydrae
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
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 = "inimit"
18
+ gem.homepage = "http://github.com/AlphaHydrae/inimit"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Recursive file comparison command.}
21
+ gem.description = %Q{Compares files in two directories using SHA1.}
22
+ gem.email = "hydrae.alpha@gmail.com"
23
+ gem.authors = ["AlphaHydrae"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ Rake::TaskManager.class_eval do
29
+ def remove_task(task_name)
30
+ @tasks.delete(task_name.to_s)
31
+ end
32
+ end
33
+
34
+ [ 'version', 'version:bump:major', 'version:bump:minor', 'version:bump:patch', 'version:write' ].each do |task|
35
+ Rake.application.remove_task task
36
+ end
37
+
38
+ # version tasks
39
+ require 'rake-version'
40
+ RakeVersion::Tasks.new do |v|
41
+ v.copy 'lib/inimit.rb'
42
+ end
43
+
44
+ require 'rspec/core/rake_task'
45
+ desc "Run specs"
46
+ RSpec::Core::RakeTask.new do |t|
47
+ #t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
48
+ # Put spec opts in a file named .rspec in root
49
+ end
50
+
51
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'inimit')
3
+
4
+ Inimit::compare *ARGV
@@ -0,0 +1,91 @@
1
+ require 'find'
2
+ require 'digest/sha1'
3
+ require 'paint'
4
+
5
+ module Inimit
6
+ VERSION = '0.0.1'
7
+
8
+ def self.compare *args
9
+
10
+ self.abort "A source and target directory are required (got #{args.length} arguments)" unless args.length == 2
11
+
12
+ source, target = args.shift, args.shift
13
+ self.abort "Source #{source} is not a directory" unless File.directory? source
14
+ self.abort "Target #{target} is not a directory" unless File.directory? target
15
+
16
+ source, target = File.expand_path(source), File.expand_path(target)
17
+
18
+ puts
19
+ puts "Comparing files in #{source} to #{target}:"
20
+ puts
21
+
22
+ Dir.chdir source
23
+ unknown = []
24
+ different = []
25
+
26
+ Find.find '.' do |file|
27
+
28
+ # skip directories
29
+ next unless File.file? file
30
+
31
+ print "- #{file.sub /^\.\//, ''}..."
32
+
33
+ source_file = File.join source, file
34
+ target_file = File.join target, file
35
+
36
+ if !File.file? target_file
37
+ unknown << file
38
+ puts Paint[" not found", :yellow]
39
+ next
40
+ end
41
+
42
+ source_sha1 = self.hash source_file
43
+ target_sha1 = self.hash target_file
44
+
45
+ if source_sha1 == target_sha1
46
+ puts Paint[" #{source_sha1[0,7]} == #{target_sha1[0,7]}", :green]
47
+ else
48
+ puts Paint[" #{source_sha1[0,7]} != #{target_sha1[0,7]}", :red]
49
+ different << { :file => file, :source => source_sha1, :target => target_sha1 }
50
+ end
51
+ end
52
+
53
+ if different.empty? and unknown.empty?
54
+ puts
55
+ puts Paint["All files in #{source} are the same in #{target}.", :green, :bold]
56
+ puts
57
+ return
58
+ end
59
+
60
+ if unknown.any?
61
+ puts
62
+ puts Paint["The following files in #{source} were not found in #{target}:", :yellow, :bold]
63
+ unknown.each do |file|
64
+ puts "- #{file}"
65
+ end
66
+ end
67
+
68
+ if different.any?
69
+ puts
70
+ puts Paint["The following files in #{source} do not have the same content in #{target}:", :red, :bold]
71
+ different.each do |h|
72
+ puts "- #{h[:file]}"
73
+ end
74
+ end
75
+
76
+ puts
77
+ end
78
+
79
+ def self.hash file
80
+ dig = Digest::SHA1.new
81
+ File.open file, 'rb' do |io|
82
+ dig.update io.readpartial(4096) while !io.eof
83
+ end
84
+ dig.hexdigest
85
+ end
86
+
87
+ def self.abort msg
88
+ warn msg
89
+ exit 1
90
+ end
91
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'simplecov'
13
+ SimpleCov.start
14
+
15
+ require 'rspec'
16
+ require 'inimit'
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ describe "Version" do
4
+
5
+ it "should be correct" do
6
+ version_file = File.join File.dirname(__FILE__), '..', 'VERSION'
7
+ Inimit::VERSION.should == File.open(version_file, 'r').read
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inimit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - AlphaHydrae
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: paint
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.5
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: gemcutter
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: gem-release
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake-version
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: simplecov
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ description: Compares files in two directories using SHA1.
159
+ email: hydrae.alpha@gmail.com
160
+ executables:
161
+ - inimit
162
+ extensions: []
163
+ extra_rdoc_files:
164
+ - LICENSE.txt
165
+ - README.md
166
+ files:
167
+ - .rspec
168
+ - .rvmrc
169
+ - .screenrc
170
+ - .travis.yml
171
+ - Gemfile
172
+ - Gemfile.lock
173
+ - LICENSE.txt
174
+ - README.md
175
+ - Rakefile
176
+ - VERSION
177
+ - bin/inimit
178
+ - lib/inimit.rb
179
+ - spec/helper.rb
180
+ - spec/version_spec.rb
181
+ homepage: http://github.com/AlphaHydrae/inimit
182
+ licenses:
183
+ - MIT
184
+ post_install_message:
185
+ rdoc_options: []
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 1.8.24
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: Recursive file comparison command.
206
+ test_files: []