churn 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.md +137 -120
- data/bin/churn +27 -12
- data/churn.gemspec +7 -21
- data/lib/churn/calculator.rb +24 -11
- data/lib/churn/history.rb +1 -1
- data/lib/churn/location_mapping.rb +1 -1
- data/lib/churn/options.rb +7 -3
- data/lib/churn/scm/bzr_analyzer.rb +11 -4
- data/lib/churn/scm/git_analyzer.rb +5 -3
- data/lib/churn/scm/hg_analyzer.rb +11 -4
- data/lib/churn/scm/source_control.rb +6 -8
- data/lib/churn/scm/svn_analyzer.rb +9 -3
- data/lib/churn/version.rb +1 -1
- metadata +24 -190
- data/.deferred_server +0 -1
- data/.document +0 -5
- data/.gitignore +0 -11
- data/.travis.yml +0 -6
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -79
- data/Rakefile +0 -41
- data/doc/Churn.html +0 -165
- data/doc/Churn/BzrAnalyzer.html +0 -276
- data/doc/Churn/ChurnCalculator.html +0 -578
- data/doc/Churn/ChurnHistory.html +0 -250
- data/doc/Churn/ChurnOptions.html +0 -393
- data/doc/Churn/GitAnalyzer.html +0 -311
- data/doc/Churn/HgAnalyzer.html +0 -276
- data/doc/Churn/LocationMapping.html +0 -448
- data/doc/Churn/SourceControl.html +0 -451
- data/doc/Churn/SvnAnalyzer.html +0 -311
- data/doc/LICENSE.html +0 -123
- data/doc/Object.html +0 -246
- data/doc/created.rid +0 -15
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -100
- data/doc/js/darkfish.js +0 -155
- data/doc/js/jquery.js +0 -18
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -94
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/rdoc.css +0 -595
- data/doc/table_of_contents.html +0 -167
- data/test/data/churn_calculator.rb +0 -217
- data/test/data/test_helper.rb +0 -14
- data/test/test_helper.rb +0 -21
- data/test/unit/bzr_analyzer_test.rb +0 -65
- data/test/unit/churn_calculator_test.rb +0 -181
- data/test/unit/churn_history_test.rb +0 -24
- data/test/unit/churn_options_test.rb +0 -16
- data/test/unit/git_analyzer_test.rb +0 -88
- data/test/unit/hg_analyzer_test.rb +0 -66
- data/test/unit/location_mapping_test.rb +0 -35
- data/test/unit/source_control_test.rb +0 -22
- data/test/unit/svn_analyzer_test.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbe39389e7238ce9ac55fb37224083a50b65692de78df6189e1b2cba21819211
|
4
|
+
data.tar.gz: adf3e40ea5e98297181a1bf78316fc42c368c560e336797f1d59c38dabfcee4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca92c6967f4873fa57836bf5ebbc2f05d80a510eda2b61b3fd9fce40b2ca80338962cef98d56930a5520cd73bb53d4665753d41512cb33c86ac3edf40b1470f
|
7
|
+
data.tar.gz: d8228f4bcf60a6777e0a590170462019b46d0cfde0fcba4324b2ca5bffef8cf351ce4d4b6036861ac7eb1d6de6d0e77739d5436e45beee8eb1ccbff72be17609
|
data/{LICENSE → LICENSE.txt}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,134 +1,132 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
[![Build Status](https://travis-ci.org/danmayer/churn.svg?branch=master)](http://travis-ci.org/danmayer/churn)
|
2
|
+
|
3
|
+
# Churn
|
3
4
|
|
4
5
|
A Project to give the churn file, class, and method for a project for a given checkin. Over time the tool adds up the history of churns to give the number of times a file, class, or method is changing during the life of a project.
|
5
6
|
Churn for files is immediate, but classes and methods requires building up a history using churn between revisions. The history is stored in ./tmp
|
6
7
|
|
7
8
|
Currently has full Git, Mercurial (hg), Bazaar (bzr) support, and partial SVN support (supports only file level churn currently)
|
8
9
|
|
9
|
-
File changes can be calculated on any single commit to look at method changes you need to be running churn over time. Using a git post-commit hook, configuring your CI to run churn
|
10
|
-
|
11
|
-
####Authors:
|
12
|
-
* danmayer
|
13
|
-
* ajwalters
|
14
|
-
* cldwalker
|
15
|
-
* absurdhero
|
16
|
-
* bf4
|
17
|
-
|
18
|
-
## CI Build Status
|
10
|
+
File changes can be calculated on any single commit to look at method changes you need to be running churn over time. Using a git post-commit hook, configuring your CI to run churn. See the --past_history (-p) option to do a one time run building up past class and method level churn.
|
19
11
|
|
20
|
-
|
12
|
+
## TODO
|
21
13
|
|
22
|
-
|
14
|
+
Want to help out, there are easy tasks ready for some attention. The list of items is hosted on [github issues](https://github.com/danmayer/churn/issues)
|
23
15
|
|
24
|
-
##
|
16
|
+
## Churn Usage
|
25
17
|
|
26
|
-
|
18
|
+
Install with `gem install churn` or for bundler add to your Gemfile
|
27
19
|
|
28
|
-
[![Stories in Ready](https://badge.waffle.io/danmayer/churn.png)](http://waffle.io/danmayer/churn)
|
29
20
|
|
30
|
-
|
21
|
+
```
|
22
|
+
group :development do
|
23
|
+
gem 'churn'
|
24
|
+
end
|
25
|
+
```
|
31
26
|
|
32
|
-
|
27
|
+
### Rake
|
33
28
|
|
34
|
-
|
29
|
+
* Add `require 'churn'` to Rakefile
|
30
|
+
* Then run `rake churn` or `bundle exec rake churn`
|
31
|
+
* Use environment variables to control churn defaults
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
``` ruby
|
34
|
+
ENV['CHURN_MINIMUM_CHURN_COUNT']
|
35
|
+
ENV['CHURN_START_DATE']
|
36
|
+
ENV['CHURN_IGNORES']
|
37
|
+
```
|
40
38
|
|
41
|
-
|
42
|
-
ENV['CHURN_MINIMUM_CHURN_COUNT']
|
43
|
-
ENV['CHURN_START_DATE']
|
44
|
-
ENV['CHURN_IGNORE_FILES']
|
45
|
-
```
|
39
|
+
### CLI
|
46
40
|
|
47
|
-
*
|
48
|
-
|
49
|
-
|
50
|
-
* run the executable passing in options to override defaults
|
41
|
+
* On the command line run `churn` or `bundle exec churn`
|
42
|
+
* Need help? Run `churn -h` to get additional information
|
43
|
+
* Run the executable, passing in options to override defaults
|
51
44
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
45
|
+
```shell
|
46
|
+
churn -i "churn.gemspec, Gemfile" # Ignore files
|
47
|
+
churn -y # Output yaml format opposed to text
|
48
|
+
churn -c 10 # Set minimum churn count on a file to 10
|
49
|
+
churn -c 5 -y -i "Gemfile" # Mix and match
|
50
|
+
churn -e rb # Specify a file extension. The dot will be prepended automatically ("rb" -> ".rb")
|
51
|
+
churn -f app # Specify a file prefix, e.g. app/models
|
52
|
+
churn --start_date "6 months ago" # Start looking at file changes from 6 months ago
|
53
|
+
churn -p "4 months ago" # Churn the past history to build up data for the last 4 months
|
54
|
+
churn --past_history # Churn the past history for default 3 months to build up data
|
55
|
+
```
|
61
56
|
|
62
57
|
## Example Output
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
59
|
+
```
|
60
|
+
**********************************************************************
|
61
|
+
* Revision Changes
|
62
|
+
**********************************************************************
|
63
|
+
Files:
|
64
|
+
+-------------------------------+
|
65
|
+
| file |
|
66
|
+
+-------------------------------+
|
67
|
+
| Rakefile |
|
68
|
+
| lib/churn/churn_calculator.rb |
|
69
|
+
+-------------------------------+
|
70
|
+
|
71
|
+
Classes:
|
72
|
+
+-------------------------------+-----------------+
|
73
|
+
| file | klass |
|
74
|
+
+-------------------------------+-----------------+
|
75
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator |
|
76
|
+
+-------------------------------+-----------------+
|
77
|
+
|
78
|
+
Methods:
|
79
|
+
+-------------------------------+-----------------+-------------------------------+
|
80
|
+
| file | klass | method |
|
81
|
+
+-------------------------------+-----------------+-------------------------------+
|
82
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters |
|
83
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#display_array |
|
84
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s |
|
85
|
+
+-------------------------------+-----------------+-------------------------------+
|
86
|
+
|
87
|
+
**********************************************************************
|
88
|
+
* Project Churn
|
89
|
+
**********************************************************************
|
90
|
+
Files:
|
91
|
+
+------------------------------------+---------------+
|
92
|
+
| file_path | times_changed |
|
93
|
+
+------------------------------------+---------------+
|
94
|
+
| lib/churn/churn_calculator.rb | 14 |
|
95
|
+
| README.rdoc | 7 |
|
96
|
+
| lib/tasks/churn_tasks.rb | 6 |
|
97
|
+
| Rakefile | 6 |
|
98
|
+
| lib/churn/git_analyzer.rb | 4 |
|
99
|
+
| VERSION | 4 |
|
100
|
+
| test/test_helper.rb | 4 |
|
101
|
+
| test/unit/churn_calculator_test.rb | 3 |
|
102
|
+
| test/churn_test.rb | 3 |
|
103
|
+
+------------------------------------+---------------+
|
104
|
+
|
105
|
+
Classes:
|
106
|
+
+-------------------------------+-----------------+---------------+
|
107
|
+
| file | klass | times_changed |
|
108
|
+
+-------------------------------+-----------------+---------------+
|
109
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | 1 |
|
110
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | 1 |
|
111
|
+
+-------------------------------+-----------------+---------------+
|
112
|
+
|
113
|
+
Methods:
|
114
|
+
+-------------------------------+-----------------+-----------------------------------------+---------------+
|
115
|
+
| file | klass | method | times_changed |
|
116
|
+
+-------------------------------+-----------------+-----------------------------------------+---------------+
|
117
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s | 1 |
|
118
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#display_array | 1 |
|
119
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#calculate_revision_data | 1 |
|
120
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters | 1 |
|
121
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#initialize | 1 |
|
122
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters | 1 |
|
123
|
+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s | 1 |
|
124
|
+
+-------------------------------+-----------------+-----------------------------------------+---------------+
|
125
|
+
```
|
129
126
|
|
130
127
|
## CLI Options
|
131
128
|
|
129
|
+
```
|
132
130
|
[~/projects/churn] churn -h
|
133
131
|
NAME
|
134
132
|
churn
|
@@ -140,28 +138,35 @@ The reason you want require false is that when required by default churn is expe
|
|
140
138
|
--minimum_churn_count=minimum_churn_count, -c (0 ~>
|
141
139
|
int(minimum_churn_count=3))
|
142
140
|
--yaml, -y
|
141
|
+
--extension, -e (0 ~> string(file_extension=))
|
142
|
+
--prefix, -f (0 ~> string(file_prefix=))
|
143
143
|
--ignore_files=[ignore_files], -i (0 ~> string(ignore_files=))
|
144
144
|
--start_date=[start_date], -s (0 ~> string(start_date=))
|
145
145
|
--data_directory=[data_directory], -d (0 ~> string(data_directory=))
|
146
146
|
--past_history=[past_history], -p (0 ~> string(past_history=))
|
147
147
|
--help, -h
|
148
|
+
```
|
148
149
|
|
149
150
|
## Library Options
|
150
151
|
|
151
152
|
All the CLI options are parsed and just passed into the library. If you want to run the library directly from other code. The best way to see current options is where the [churn executable](https://github.com/danmayer/churn/blob/master/bin/churn) passes the parsed options into the `ChurnCalculator` class
|
152
153
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
154
|
+
```ruby
|
155
|
+
###
|
156
|
+
# Available options
|
157
|
+
###
|
158
|
+
options = {:minimum_churn_count => params['minimum_churn_count'].value,
|
159
|
+
:ignore_files => params['ignore_files'].value,
|
160
|
+
:file_extension => params['file_extension'].value,
|
161
|
+
:file_prefix => params['file_prefix'].value,
|
162
|
+
:start_date => params['start_date'].value,
|
163
|
+
:data_directory => params['data_directory'].value,
|
164
|
+
:history => params['past_history'].value,
|
165
|
+
:report => params['report'].value,
|
166
|
+
:name => params['name'].value
|
167
|
+
}
|
168
|
+
result = Churn::ChurnCalculator.new(options).report(false)
|
169
|
+
```
|
165
170
|
|
166
171
|
## Notes on Patches/Pull Requests
|
167
172
|
|
@@ -174,6 +179,18 @@ All the CLI options are parsed and just passed into the library. If you want to
|
|
174
179
|
bump version in a commit by itself I can ignore when I pull)
|
175
180
|
* Send me a pull request. Bonus points for topic branches.
|
176
181
|
|
182
|
+
## Authors
|
183
|
+
|
184
|
+
* danmayer
|
185
|
+
* ajwalters
|
186
|
+
* cldwalker
|
187
|
+
* absurdhero
|
188
|
+
* bf4
|
189
|
+
|
190
|
+
## Code of Conduct
|
191
|
+
|
192
|
+
Please see our [Code of Conduct](https://github.com/danmayer/churn/blob/master/CODE_OF_CONDUCT.md)
|
193
|
+
|
177
194
|
## Copyright
|
178
195
|
|
179
|
-
Copyright (c)
|
196
|
+
Copyright (c) 2019 Dan Mayer. See LICENSE for details.
|
data/bin/churn
CHANGED
@@ -39,7 +39,7 @@ Main do
|
|
39
39
|
cast :string
|
40
40
|
argument :optional
|
41
41
|
default ''
|
42
|
-
description 'name is
|
42
|
+
description 'name is required if remotely reporting churn results. If available as a github project, pass name in the form of username/project_name'
|
43
43
|
end
|
44
44
|
|
45
45
|
option('start_date', 's') do
|
@@ -61,25 +61,40 @@ Main do
|
|
61
61
|
default ''
|
62
62
|
end
|
63
63
|
|
64
|
+
option('extension', 'e') do
|
65
|
+
cast :string
|
66
|
+
argument :optional
|
67
|
+
default ''
|
68
|
+
end
|
69
|
+
|
70
|
+
option('prefix', 'f') do
|
71
|
+
cast :string
|
72
|
+
argument :optional
|
73
|
+
default ''
|
74
|
+
end
|
75
|
+
|
64
76
|
def report_churn(output_string)
|
65
|
-
options = {
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
77
|
+
options = {
|
78
|
+
minimum_churn_count: params['minimum_churn_count'].value,
|
79
|
+
ignore_files: params['ignore_files'].value,
|
80
|
+
start_date: params['start_date'].value,
|
81
|
+
data_directory: params['data_directory'].value,
|
82
|
+
history: params['past_history'].value,
|
83
|
+
report: params['report'].value,
|
84
|
+
name: params['name'].value,
|
85
|
+
file_extension: params['extension'].value,
|
86
|
+
file_prefix: params['prefix'].value
|
72
87
|
}
|
73
88
|
result = Churn::ChurnCalculator.new(options).report(output_string)
|
74
|
-
|
75
|
-
result
|
89
|
+
if output_string
|
90
|
+
result
|
91
|
+
else
|
92
|
+
YAML::dump(result)
|
76
93
|
end
|
77
|
-
result
|
78
94
|
end
|
79
95
|
|
80
96
|
def run
|
81
97
|
report = report_churn(!params['yaml'].value)
|
82
98
|
puts report
|
83
99
|
end
|
84
|
-
|
85
100
|
end
|
data/churn.gemspec
CHANGED
@@ -6,34 +6,20 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "churn"
|
7
7
|
s.version = Churn::VERSION
|
8
8
|
|
9
|
-
s.
|
10
|
-
s.authors = ["Dan Mayer"]
|
11
|
-
s.date = "2012-12-17"
|
9
|
+
s.author = "Dan Mayer"
|
12
10
|
s.summary = "Providing additional churn metrics over the original metric_fu churn"
|
13
11
|
s.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. "
|
14
12
|
s.email = "dan@mayerdan.com"
|
15
13
|
s.homepage = "http://github.com/danmayer/churn"
|
16
|
-
s.rubyforge_project = "churn"
|
17
14
|
|
18
|
-
s.
|
19
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.require_paths = ["lib"]
|
15
|
+
s.executables = %w[churn]
|
22
16
|
|
23
|
-
s.
|
24
|
-
s.
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
s.files = %w[churn.gemspec LICENSE.txt README.md] + Dir["bin/*", "lib/**/*.rb", "man/*"]
|
18
|
+
s.license = "MIT"
|
19
|
+
s.require_paths = %w[lib]
|
20
|
+
s.required_ruby_version = ">= 1.9.3"
|
21
|
+
s.requirements = "bzr, git, hg or svn"
|
28
22
|
|
29
|
-
s.add_development_dependency "minitest", "~> 5.3"
|
30
|
-
s.add_development_dependency "shoulda", ">= 0"
|
31
|
-
s.add_development_dependency "test_construct", "~> 2.0.0"
|
32
|
-
s.add_development_dependency "rake", ">= 0"
|
33
|
-
s.add_development_dependency "mocha", "~> 1.1.0"
|
34
|
-
s.add_development_dependency "simplecov", ">= 0"
|
35
|
-
s.add_development_dependency "rdoc", ">= 0"
|
36
|
-
#s.add_development_dependency "ruby-debug", "~> 0.10.4"
|
37
23
|
s.add_runtime_dependency "main", ">= 0"
|
38
24
|
s.add_runtime_dependency "json_pure", ">= 0"
|
39
25
|
s.add_runtime_dependency "chronic", ">= 0.2.3"
|
data/lib/churn/calculator.rb
CHANGED
@@ -6,16 +6,16 @@ require 'hirb'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'rest_client'
|
8
8
|
|
9
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
|
-
require 'scm/source_control'
|
11
|
-
require 'scm/git_analyzer'
|
12
|
-
require 'scm/svn_analyzer'
|
13
|
-
require 'scm/hg_analyzer'
|
14
|
-
require 'scm/bzr_analyzer'
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
require_relative 'scm/source_control'
|
11
|
+
require_relative 'scm/git_analyzer'
|
12
|
+
require_relative 'scm/svn_analyzer'
|
13
|
+
require_relative 'scm/hg_analyzer'
|
14
|
+
require_relative 'scm/bzr_analyzer'
|
15
|
+
|
16
|
+
require_relative 'location_mapping'
|
17
|
+
require_relative 'history'
|
18
|
+
require_relative 'options'
|
19
19
|
|
20
20
|
module Churn
|
21
21
|
|
@@ -45,7 +45,7 @@ module Churn
|
|
45
45
|
# prepares the data for the given project to be reported.
|
46
46
|
# reads git/svn logs analyzes the output, generates a report and either
|
47
47
|
# formats as a nice string or returns hash.
|
48
|
-
# @param [Boolean]
|
48
|
+
# @param [Boolean] print to return the data, true for string or false for hash
|
49
49
|
# @return [Object] returns either a pretty string or a hash representing the
|
50
50
|
# churn of the project
|
51
51
|
def report(print = true)
|
@@ -89,6 +89,7 @@ module Churn
|
|
89
89
|
# on the edited files
|
90
90
|
def analyze
|
91
91
|
@changes = sort_changes(@changes)
|
92
|
+
@changes = filter_changes(@changes)
|
92
93
|
@changes = @changes.map {|file_path, times_changed| {:file_path => file_path, :times_changed => times_changed }}
|
93
94
|
|
94
95
|
calculate_revision_changes
|
@@ -157,6 +158,18 @@ module Churn
|
|
157
158
|
changes.to_a.sort! {|first,second| second[1] <=> first[1]}
|
158
159
|
end
|
159
160
|
|
161
|
+
def filter_changes(changes)
|
162
|
+
if @churn_options.file_extension && !@churn_options.file_extension.empty?
|
163
|
+
changes = changes.select { |file_path, _revision_count| file_path =~ /\.#{@churn_options.file_extension}\z/ }
|
164
|
+
end
|
165
|
+
|
166
|
+
if @churn_options.file_prefix && !@churn_options.file_prefix.empty?
|
167
|
+
changes = changes.select! { |file_path, _revision_count| file_path =~ /\A#{@churn_options.file_prefix}/ }
|
168
|
+
end
|
169
|
+
|
170
|
+
changes
|
171
|
+
end
|
172
|
+
|
160
173
|
def filters
|
161
174
|
/.*\.rb/
|
162
175
|
end
|
@@ -226,7 +239,7 @@ module Churn
|
|
226
239
|
classes = classes.map{ |klass| {'file' => file, 'klass' => klass} }
|
227
240
|
methods = methods.map{ |method| {'file' => file, 'klass' => get_klass_for(method), 'method' => method} }
|
228
241
|
[classes, methods]
|
229
|
-
rescue
|
242
|
+
rescue
|
230
243
|
[[],[]]
|
231
244
|
end
|
232
245
|
|