analdiffist 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +20 -0
- data/README.md +58 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/bin/analdiffist +94 -0
- data/spec/spec_helper.rb +12 -0
- metadata +135 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
flog (2.5.1)
|
6
|
+
ruby_parser (~> 2.0)
|
7
|
+
sexp_processor (~> 3.0)
|
8
|
+
git (1.2.5)
|
9
|
+
jeweler (1.5.2)
|
10
|
+
bundler (~> 1.0.0)
|
11
|
+
git (>= 1.2.5)
|
12
|
+
rake
|
13
|
+
rake (0.8.7)
|
14
|
+
rcov (0.9.9)
|
15
|
+
reek (1.2.8)
|
16
|
+
ruby2ruby (~> 1.2)
|
17
|
+
ruby_parser (~> 2.0)
|
18
|
+
sexp_processor (~> 3.0)
|
19
|
+
rspec (2.3.0)
|
20
|
+
rspec-core (~> 2.3.0)
|
21
|
+
rspec-expectations (~> 2.3.0)
|
22
|
+
rspec-mocks (~> 2.3.0)
|
23
|
+
rspec-core (2.3.1)
|
24
|
+
rspec-expectations (2.3.0)
|
25
|
+
diff-lcs (~> 1.1.2)
|
26
|
+
rspec-mocks (2.3.0)
|
27
|
+
ruby2ruby (1.2.5)
|
28
|
+
ruby_parser (~> 2.0)
|
29
|
+
sexp_processor (~> 3.0)
|
30
|
+
ruby_parser (2.0.6)
|
31
|
+
sexp_processor (~> 3.0)
|
32
|
+
sexp_processor (3.0.5)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
bundler (~> 1.0.0)
|
39
|
+
flog
|
40
|
+
jeweler (~> 1.5.2)
|
41
|
+
rcov
|
42
|
+
reek
|
43
|
+
rspec (~> 2.3.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Adam Pearson
|
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.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
analdiffist
|
2
|
+
============
|
3
|
+
|
4
|
+
A professional twice over: an analyst and a diffist.
|
5
|
+
|
6
|
+
analdiffist uses [flog](http://ruby.sadi.st/Flog.html) and [reek](https://github.com/kevinrutherford/reek/wiki) to analyze ruby code.
|
7
|
+
Given two git refs (for example *master* and *feature-branch*), it will show you any differences in code metrics introduced between the refs.
|
8
|
+
|
9
|
+
Usage
|
10
|
+
-------
|
11
|
+
|
12
|
+
analdiffist [*ref-1*] [*ref-2*]
|
13
|
+
|
14
|
+
If not supplied, ref-1 defaults to *origin/master* and ref-2 defaults to the current head.
|
15
|
+
|
16
|
+
note that before starting, analdiffist will stash your local changes, if any exist. After running, it will unstash your changes, leaving your local tree untouched... I think. No warranties are made.
|
17
|
+
|
18
|
+
Diff w/ analysis and metrics for `origin/master..HEAD`:
|
19
|
+
|
20
|
+
$> analdiffist origin/master
|
21
|
+
|
22
|
+
_or use analdiffist's default default, `origin/master`:
|
23
|
+
|
24
|
+
$> analdiffist
|
25
|
+
|
26
|
+
Diff w/ analysis and metrics for `origin/master..master`:
|
27
|
+
|
28
|
+
$> analdiffist origin/master master
|
29
|
+
|
30
|
+
Future
|
31
|
+
------
|
32
|
+
|
33
|
+
Diff each commit in a range (once we implement this):
|
34
|
+
|
35
|
+
$> analdiffist origin/master..master
|
36
|
+
|
37
|
+
|
38
|
+
Sample Output
|
39
|
+
--------------
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Contributing to analdiffist
|
44
|
+
------------------------------
|
45
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
46
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
47
|
+
* Fork the project
|
48
|
+
* Start a feature/bugfix branch
|
49
|
+
* Commit and push until you are happy with your contribution
|
50
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
51
|
+
* 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.
|
52
|
+
|
53
|
+
Copyright
|
54
|
+
--------------------
|
55
|
+
|
56
|
+
Copyright (c) 2011 Adam Pearson. See LICENSE.txt for
|
57
|
+
further details.
|
58
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "analdiffist"
|
16
|
+
gem.homepage = "http://github.com/radamant/analdiffist"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{A professional twice over: an analyst and a diffist.}
|
19
|
+
gem.description = %Q{A tool for comparing the complexity and code smells between two git revisions}
|
20
|
+
gem.email = "davidmfoley@gmail.com"
|
21
|
+
gem.authors = ["Adam Pearson", "Dave Foley"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "analdiffist #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/analdiffist
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
def main
|
6
|
+
current_branch = get_current_branch
|
7
|
+
puts "current branch: #{current_branch}"
|
8
|
+
stashed = try_to_stash
|
9
|
+
|
10
|
+
ref = get_refs_to_diff
|
11
|
+
|
12
|
+
file_1 = analyze_ref(ref[0])
|
13
|
+
file_2 = analyze_ref(ref[1])
|
14
|
+
|
15
|
+
begin
|
16
|
+
echo_exec "git checkout #{current_branch}" if current_branch != ref[1]
|
17
|
+
rescue Exception
|
18
|
+
end
|
19
|
+
|
20
|
+
if stashed
|
21
|
+
echo "unstashing"
|
22
|
+
echo_exec "git stash apply"
|
23
|
+
end
|
24
|
+
|
25
|
+
diff file_1, file_2
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_current_branch
|
29
|
+
current_branch_raw = echo_exec "git branch --no-color"
|
30
|
+
lines = current_branch_raw.split("\n")
|
31
|
+
current_branch_line = lines.detect{|x| x[0] == '*'}
|
32
|
+
current_branch = current_branch_line.split(' ')[1]
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_refs_to_diff
|
36
|
+
[ ARGV[0] || "origin/master", ARGV[1] || current_branch]
|
37
|
+
end
|
38
|
+
|
39
|
+
def analyze_ref ref_name
|
40
|
+
file = get_file_name ref_name
|
41
|
+
begin
|
42
|
+
echo_exec "git checkout #{ref_name}"
|
43
|
+
do_analytics file, ref_name
|
44
|
+
rescue Exception
|
45
|
+
end
|
46
|
+
|
47
|
+
file
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_file_name ref_name
|
51
|
+
|
52
|
+
File.join(Dir.tmpdir, "#{ref_name.gsub('/', '_')}-analytics.txt")
|
53
|
+
end
|
54
|
+
|
55
|
+
def do_analytics dest_filename, ref_name
|
56
|
+
puts 'writing analytics to ' + dest_filename
|
57
|
+
reek_result = `reek -q app lib`
|
58
|
+
flog_result = `flog -g app lib`
|
59
|
+
File.open(dest_filename, 'w') do |f|
|
60
|
+
f.write"--- Analytics for #{ref_name} ---\n\n"
|
61
|
+
|
62
|
+
f.write"\n\n--- FLOG ---\n\n"
|
63
|
+
f.write clean_up_flog(flog_result)
|
64
|
+
|
65
|
+
f.write"\n\n--- REEK ---\n\n"
|
66
|
+
f.write reek_result
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def clean_up_flog(flog_result)
|
71
|
+
flog_result.gsub(/:[0-9]+$/, '')
|
72
|
+
end
|
73
|
+
|
74
|
+
def echo s
|
75
|
+
puts s
|
76
|
+
end
|
77
|
+
|
78
|
+
def echo_exec command
|
79
|
+
puts command
|
80
|
+
result = `#{command}`
|
81
|
+
puts result
|
82
|
+
result
|
83
|
+
end
|
84
|
+
|
85
|
+
def try_to_stash
|
86
|
+
result = echo_exec "git stash"
|
87
|
+
!(result =~ /No local changes to save/)
|
88
|
+
end
|
89
|
+
|
90
|
+
def diff f1, f2
|
91
|
+
echo_exec "git diff --color=always -U1 -- '#{f1}' '#{f2}'"
|
92
|
+
end
|
93
|
+
|
94
|
+
main
|
data/spec/spec_helper.rb
ADDED
@@ -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 'analdiffist'
|
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,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: analdiffist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Pearson
|
9
|
+
- Dave Foley
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-03-09 00:00:00 -08:00
|
15
|
+
default_executable: analdiffist
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: reek
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: flog
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: rspec
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.3.0
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: bundler
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.0.0
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jeweler
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.5.2
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id005
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rcov
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: *id006
|
83
|
+
description: A tool for comparing the complexity and code smells between two git revisions
|
84
|
+
email: davidmfoley@gmail.com
|
85
|
+
executables:
|
86
|
+
- analdiffist
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.md
|
92
|
+
files:
|
93
|
+
- .document
|
94
|
+
- .rspec
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- bin/analdiffist
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
has_rdoc: true
|
104
|
+
homepage: http://github.com/radamant/analdiffist
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 4399973097454794320
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: "0"
|
127
|
+
requirements: []
|
128
|
+
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.5.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: "A professional twice over: an analyst and a diffist."
|
134
|
+
test_files:
|
135
|
+
- spec/spec_helper.rb
|