olde_code_finder 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/README.md +6 -1
- data/lib/olde_code_finder/finder.rb +10 -4
- data/lib/olde_code_finder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d45c246fadab214519b8402077cf0438c87ecb5
|
4
|
+
data.tar.gz: 15a42634315cfa95ac6b9541a3ce576c0dde1f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f201c9944542b5722c7a67a6a5eac097c7eca2d48b98bd9e6e21c427cc309b865ddc950709e33f88b727f84356f1e6a29c3a1940fe813f92dfbca33ab9d84bd4
|
7
|
+
data.tar.gz: 1eaa22f5d033ebe559b413961522cb40efc804ce31e6d936519c8c248f7a8e5742ca9cbf82a1eb880d44c3082d8412f539a49b40986b26e636e9c5d0e67441f3
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -47,7 +47,7 @@ Or you can run a different task and find code older than a certain date instead:
|
|
47
47
|
The output will be a list of files that meet the criteria:
|
48
48
|
|
49
49
|
foo> $ bundle exec rake olde_code_finder:find_by_author['app/models/*.rb','Benjamin Franklin','80']
|
50
|
-
More than 80% of app/models/foobar.rb was written by Benjamin Franklin
|
50
|
+
More than 80% of app/models/foobar.rb was written by Benjamin Franklin (85%)
|
51
51
|
|
52
52
|
## How does it work?
|
53
53
|
|
@@ -60,3 +60,8 @@ It uses `git blame` to see who last touched each line of a file and when.
|
|
60
60
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
61
|
4. Push to the branch (`git push origin my-new-feature`)
|
62
62
|
5. Create new Pull Request
|
63
|
+
|
64
|
+
## Credits
|
65
|
+
|
66
|
+
* Tom Copeland: Author
|
67
|
+
* Joe Rafaniello: Added percentage display
|
@@ -14,8 +14,9 @@ module OldeCodeFinder
|
|
14
14
|
return if binary?
|
15
15
|
total_lines = git_blame_output.size
|
16
16
|
author_lines = git_blame_output.grep(/#{author}/).size
|
17
|
-
|
18
|
-
|
17
|
+
actual_percent = calculate_percent(author_lines, total_lines)
|
18
|
+
if actual_percent > pctg.to_f
|
19
|
+
puts "More than #{pctg}% of #{file} was written by #{author} (#{actual_percent}%)"
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
@@ -25,13 +26,18 @@ module OldeCodeFinder
|
|
25
26
|
date_threshold = (Date.today - (years_ago*365))
|
26
27
|
total_lines = git_blame_output.size
|
27
28
|
older_lines = git_blame_output.select {|line| Date.strptime(line.match(/.*(\d{4}-\d{2}-\d{2})/)[1]) < date_threshold }.size
|
28
|
-
|
29
|
-
|
29
|
+
actual_percent = calculate_percent(older_lines, total_lines)
|
30
|
+
if actual_percent > pctg.to_f
|
31
|
+
puts "More than #{pctg}% of #{file} was written more than #{years_ago} years ago (#{actual_percent}%)"
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
private
|
34
36
|
|
37
|
+
def calculate_percent(matched_lines, total_lines)
|
38
|
+
((matched_lines / total_lines.to_f) * 100).round
|
39
|
+
end
|
40
|
+
|
35
41
|
def binary?
|
36
42
|
`git diff --numstat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD -- #{file}`.match(/^-\t-\t/)
|
37
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: olde_code_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Copeland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|