git-headlines 0.0.2
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 +7 -0
- data/bin/githl +5 -0
- data/lib/git-headlines.rb +69 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b0c5862fefde0cb4f1bf45fd06d8612300469ff7bf4821c725b6af1f40215fb
|
4
|
+
data.tar.gz: 332a9a8a35b1f1c299c89e552d63710e6176ac2b6a7a30e450892478d3a194d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0243e987536a963d4aa7abf531ad465720249ca2e2325a6f48ebcb01b2e382575bff001b98734cec2f05ebf8992ae27befc939bca1bd9a1dbbe551056bcfc5d
|
7
|
+
data.tar.gz: 21f695e0459d597001bf056eb453ccfd7ebf70bf19a79351d43e4fd99cc11d8f7a05edadb4da41682ccebeee5ddbcf3c1cfb9d246030bbf298e4cd701f1a21ae
|
data/bin/githl
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'slop'
|
2
|
+
require 'byebug'
|
3
|
+
|
4
|
+
VERSION = '0.0.2'
|
5
|
+
|
6
|
+
class HeadLines
|
7
|
+
def initialize
|
8
|
+
parse_cla
|
9
|
+
construct_paths
|
10
|
+
handle_extensions
|
11
|
+
to_h
|
12
|
+
end
|
13
|
+
|
14
|
+
def print
|
15
|
+
puts 'Lines covered:'
|
16
|
+
@author_count.each do |author, count|
|
17
|
+
puts "#{author} - #{count}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def parse_cla
|
24
|
+
@opts = Slop.parse do |o|
|
25
|
+
o.string '-p', '--path', 'specify a different path'
|
26
|
+
o.array '-e', '--ext', 'specify file extensions'
|
27
|
+
o.array '-i', '--ignore', 'ignore certain files or directories', delimiter: ','
|
28
|
+
o.bool '-q', '--quiet', 'suppress output'
|
29
|
+
o.on '-v', '--version', 'print version' do
|
30
|
+
puts VERSION
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def construct_paths
|
37
|
+
search_path = @opts[:path] || 'app'
|
38
|
+
|
39
|
+
file_paths = `find #{search_path} -type f -not -path '*/\.*' \
|
40
|
+
#{@ignore_grep} #{@allow_grep}`.split("\n") - @opts[:ignore]
|
41
|
+
|
42
|
+
@contents = file_paths.map do |path|
|
43
|
+
`git blame --line-porcelain #{path}`.scan(/author \S.*$/)
|
44
|
+
end.flatten
|
45
|
+
end
|
46
|
+
|
47
|
+
def handle_extensions
|
48
|
+
prepend_dotglob = lambda do |array|
|
49
|
+
array.map do |ext|
|
50
|
+
ext =~ /\A[.]{1}/ ? ext.prepend('*') : ext.prepend('*.')
|
51
|
+
end.join('|')
|
52
|
+
end
|
53
|
+
|
54
|
+
ignored_extensions = prepend_dotglob.call(@opts[:ignore])
|
55
|
+
allowed_extensions = prepend_dotglob.call(@opts[:ext])
|
56
|
+
|
57
|
+
@ignore_grep = ignored_extensions.empty? ? '' : "| grep -vE '#{ignored_extensions}'"
|
58
|
+
@allow_grep = allowed_extensions.empty? ? '' : "| grep -E '#{allowed_extensions}'"
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_h
|
62
|
+
@author_count = Hash.new(0)
|
63
|
+
|
64
|
+
@contents.map do |line|
|
65
|
+
@author_count[line.sub('author ', '')] += 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-headlines
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- vikdotdev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: vikdotdev@gmail.com
|
15
|
+
executables:
|
16
|
+
- githl
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/githl
|
21
|
+
- lib/git-headlines.rb
|
22
|
+
homepage:
|
23
|
+
licenses: []
|
24
|
+
metadata:
|
25
|
+
source_code_uri: https://github.com/vikdotdev/git-headlines
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.0.6
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: output contributors' line count at HEAD
|
45
|
+
test_files: []
|