olde_code_finder 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b87bd384b4ecdfffab49055cff0dcc97d1c3b32
4
- data.tar.gz: ea435c3ff5ea35f3c2feb2cdd10dc5bae06a7e93
3
+ metadata.gz: 5d45c246fadab214519b8402077cf0438c87ecb5
4
+ data.tar.gz: 15a42634315cfa95ac6b9541a3ce576c0dde1f2c
5
5
  SHA512:
6
- metadata.gz: bc73009fed83f593862ea034d9028cfcb7314db0c537797c4a6c75524aa331473caf081d626bd1783e28721dcc6b93ec381e4350e7212fe7eb04ced8e0550e74
7
- data.tar.gz: c1e514fe0eb9d24585b21d2eef08933ae1f129a4ed9b57f76674f591c56eef29bddd9469f569a01bf3ae75a99b57149511ee3dc915a3d8729f99941fb701e786
6
+ metadata.gz: f201c9944542b5722c7a67a6a5eac097c7eca2d48b98bd9e6e21c427cc309b865ddc950709e33f88b727f84356f1e6a29c3a1940fe813f92dfbca33ab9d84bd4
7
+ data.tar.gz: 1eaa22f5d033ebe559b413961522cb40efc804ce31e6d936519c8c248f7a8e5742ca9cbf82a1eb880d44c3082d8412f539a49b40986b26e636e9c5d0e67441f3
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ Jan 29, 2015: 0.0.7
2
+ Show percentage of old lines (Joe Rafaniello)
3
+
1
4
  Sep 24, 2014: 0.0.6
2
5
  Filter out binary files.
3
6
 
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
- if (author_lines / total_lines.to_f) > (pctg.to_f / 100.0)
18
- puts "More than #{pctg}% of #{file} was written by #{author}"
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
- if (older_lines / total_lines.to_f) > (pctg.to_f / 100.0)
29
- puts "More than #{pctg}% of #{file} was written more than #{years_ago} years ago"
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
@@ -1,3 +1,3 @@
1
1
  module OldeCodeFinder
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  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.6
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: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler