churn 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +62 -38
  2. data/Rakefile +2 -1
  3. data/VERSION +1 -1
  4. data/lib/churn/churn_calculator.rb +15 -14
  5. metadata +22 -2
@@ -5,47 +5,71 @@ Over time the tool adds up the history of chruns to give the number of times a f
5
5
  Churn for files is immediate, but classes and methods requires buildings up a history using churn between revisions. The history is stored in ./tmp
6
6
 
7
7
  == Example Output
8
+ **********************************************************************
9
+ * Revision Changes
10
+ **********************************************************************
11
+ Files:
12
+ +-------------------------------+
13
+ | file |
14
+ +-------------------------------+
15
+ | Rakefile |
16
+ | lib/churn/churn_calculator.rb |
17
+ +-------------------------------+
18
+
19
+ Classes:
20
+ +-------------------------------+-----------------+
21
+ | file | klass |
22
+ +-------------------------------+-----------------+
23
+ | lib/churn/churn_calculator.rb | ChurnCalculator |
24
+ +-------------------------------+-----------------+
25
+
26
+ Methods:
27
+ +-------------------------------+-----------------+-------------------------------+
28
+ | file | klass | method |
29
+ +-------------------------------+-----------------+-------------------------------+
30
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters |
31
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#display_array |
32
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s |
33
+ +-------------------------------+-----------------+-------------------------------+
34
+
8
35
  **********************************************************************
9
36
  * Project Churn
10
37
  **********************************************************************
11
- files:
12
- * {:file_path=>"lib/churn/churn_calculator.rb", :times_changed=>11}
13
- * {:file_path=>"README.rdoc", :times_changed=>6}
14
- * {:file_path=>"lib/tasks/churn_tasks.rb", :times_changed=>6}
15
- * {:file_path=>"Rakefile", :times_changed=>4}
16
- * {:file_path=>"lib/churn/git_analyzer.rb", :times_changed=>4}
17
- * {:file_path=>"test/test_helper.rb", :times_changed=>4}
18
- * {:file_path=>"test/unit/churn_calculator_test.rb", :times_changed=>3}
19
- * {:file_path=>"test/churn_test.rb", :times_changed=>3}
20
- * {:file_path=>"VERSION", :times_changed=>3}
21
-
22
- classes:
23
- * {"klass"=>{"klass"=>"ChurnCalculator", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>7}
24
- * {"klass"=>{"klass"=>"LocationMapping", "file"=>"lib/churn/location_mapping.rb"}, "times_changed"=>1}
25
- * {"klass"=>{"klass"=>"GitAnalyzer", "file"=>"lib/churn/git_analyzer.rb"}, "times_changed"=>1}
26
- * {"klass"=>{"klass"=>"ChurnTest", "file"=>"test/churn_test.rb"}, "times_changed"=>1}
27
- * {"klass"=>{"klass"=>"ChurnCalculatorTest", "file"=>"test/unit/churn_calculator_test.rb"}, "times_changed"=>1}
28
-
29
- methods:
30
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#to_h", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>3}
31
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#analyze", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>2}
32
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#report", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>2}
33
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#calculate_changes!", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
34
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#display_array", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
35
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#calculate_revision_changes", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
36
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#initialize", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
37
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#set_source_control", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
38
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#get_changes", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
39
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#calculate_revision_data", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
40
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#emit", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
41
- * {"method"=>{"klass"=>"GitAnalyzer", "method"=>"GitAnalyzer#date_range", "file"=>"lib/churn/git_analyzer.rb"}, "times_changed"=>1}
42
- * {"method"=>{"klass"=>"", "method"=>"#report_churn", "file"=>"lib/tasks/churn_tasks.rb"}, "times_changed"=>1}
43
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#get_klass_for", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
44
- * {"method"=>{"klass"=>"GitAnalyzer", "method"=>"GitAnalyzer#get_recent_file", "file"=>"lib/churn/git_analyzer.rb"}, "times_changed"=>1}
45
- * {"method"=>{"klass"=>"GitAnalyzer", "method"=>"GitAnalyzer#get_updated_files_change_info", "file"=>"lib/churn/git_analyzer.rb"}, "times_changed"=>1}
46
- * {"method"=>{"klass"=>"GitAnalyzer", "method"=>"GitAnalyzer#get_changed_range", "file"=>"lib/churn/git_analyzer.rb"}, "times_changed"=>1}
47
- * {"method"=>{"klass"=>"ChurnCalculator", "method"=>"ChurnCalculator#parse_logs_for_updated_files", "file"=>"lib/churn/churn_calculator.rb"}, "times_changed"=>1}
48
- * {"method"=>{"klass"=>"LocationMapping", "method"=>"LocationMapping#process_class", "file"=>"lib/churn/location_mapping.rb"}, "times_changed"=>1}
38
+ Files:
39
+ +------------------------------------+---------------+
40
+ | file_path | times_changed |
41
+ +------------------------------------+---------------+
42
+ | lib/churn/churn_calculator.rb | 14 |
43
+ | README.rdoc | 7 |
44
+ | lib/tasks/churn_tasks.rb | 6 |
45
+ | Rakefile | 6 |
46
+ | lib/churn/git_analyzer.rb | 4 |
47
+ | VERSION | 4 |
48
+ | test/test_helper.rb | 4 |
49
+ | test/unit/churn_calculator_test.rb | 3 |
50
+ | test/churn_test.rb | 3 |
51
+ +------------------------------------+---------------+
52
+
53
+ Classes:
54
+ +-------------------------------+-----------------+---------------+
55
+ | file | klass | times_changed |
56
+ +-------------------------------+-----------------+---------------+
57
+ | lib/churn/churn_calculator.rb | ChurnCalculator | 1 |
58
+ | lib/churn/churn_calculator.rb | ChurnCalculator | 1 |
59
+ +-------------------------------+-----------------+---------------+
60
+
61
+ Methods:
62
+ +-------------------------------+-----------------+-----------------------------------------+---------------+
63
+ | file | klass | method | times_changed |
64
+ +-------------------------------+-----------------+-----------------------------------------+---------------+
65
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s | 1 |
66
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#display_array | 1 |
67
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#calculate_revision_data | 1 |
68
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters | 1 |
69
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#initialize | 1 |
70
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters | 1 |
71
+ | lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s | 1 |
72
+ +-------------------------------+-----------------+-----------------------------------------+---------------+
49
73
 
50
74
  TODO:
51
75
  * SVN only supports file
data/Rakefile CHANGED
@@ -12,12 +12,13 @@ begin
12
12
  gem.homepage = "http://github.com/danmayer/churn"
13
13
  gem.authors = ["Dan Mayer"]
14
14
  gem.add_development_dependency "thoughtbot-shoulda"
15
+ gem.add_development_dependency "devver-construct"
15
16
  gem.add_dependency "main"
16
17
  gem.add_dependency "json"
17
18
  gem.add_dependency "chronic", '~> 0.2.3'
18
19
  gem.add_dependency "sexp_processor", '~> 3.0.3'
19
20
  gem.add_dependency "ruby_parser", '~> 2.0.4'
20
-
21
+ gem.add_dependency 'hirb'
21
22
  gem.executables = ['churn']
22
23
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
24
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -2,6 +2,7 @@ require 'chronic'
2
2
  require 'sexp_processor'
3
3
  require 'ruby_parser'
4
4
  require 'json'
5
+ require 'hirb'
5
6
  require 'fileutils'
6
7
 
7
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -69,21 +70,23 @@ module Churn
69
70
  result = seperator
70
71
  result +="* Revision Changes \n"
71
72
  result += seperator
72
- result += "files: \n"
73
- result += display_array(hash[:churn][:changed_files])
74
- result += "\nclasses: \n"
73
+ result += "Files: \n"
74
+ result += display_array(hash[:churn][:changed_files], :fields=>[:to_str], :headers=>{:to_str=>'file'})
75
+ result += "\nClasses: \n"
75
76
  result += display_array(hash[:churn][:changed_classes])
76
- result += "\nmethods: \n"
77
- result += display_array(hash[:churn][:changed_methods])
77
+ result += "\nMethods: \n"
78
+ result += display_array(hash[:churn][:changed_methods]) + "\n"
78
79
  result += seperator
79
80
  result +="* Project Churn \n"
80
81
  result += seperator
81
- result += "files: \n"
82
+ result += "Files: \n"
82
83
  result += display_array(hash[:churn][:changes])
83
- result += "\nclasses: \n"
84
- result += display_array(hash[:churn][:class_churn])
85
- result += "\nmethods: \n"
86
- result += display_array(hash[:churn][:method_churn])
84
+ result += "\nClasses: \n"
85
+ class_churn = hash[:churn][:class_churn].map {|e| (e.delete('klass') || {}).merge(e) }
86
+ result += display_array(class_churn)
87
+ result += "\nMethods: \n"
88
+ method_churn = hash[:churn][:method_churn].map {|e| (e.delete('method') || {}).merge(e) }
89
+ result += display_array(method_churn)
87
90
  end
88
91
 
89
92
  private
@@ -92,10 +95,8 @@ module Churn
92
95
  /.*\.rb/
93
96
  end
94
97
 
95
- def display_array(array)
96
- result = ""
97
- array.each { |element| result += " * #{element.inspect}\n" } if array
98
- result
98
+ def display_array(array, options={})
99
+ array ? Hirb::Helpers::AutoTable.render(array, options.merge(:description=>false)) + "\n" : ''
99
100
  end
100
101
 
101
102
  def seperator
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: churn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-12 00:00:00 -05:00
12
+ date: 2010-01-14 00:00:00 -05:00
13
13
  default_executable: churn
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: devver-construct
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: main
27
37
  type: :runtime
@@ -72,6 +82,16 @@ dependencies:
72
82
  - !ruby/object:Gem::Version
73
83
  version: 2.0.4
74
84
  version:
85
+ - !ruby/object:Gem::Dependency
86
+ name: hirb
87
+ type: :runtime
88
+ version_requirement:
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
75
95
  description: "High method and class churn has been shown to have increased bug and error rates. This gem helps you know what is changing a lot so you can do additional testing, code review, or refactoring to try to tame the volatile code. "
76
96
  email: dan@devver.net
77
97
  executables: