jekyll-git-authors 0.1.1 → 0.2.0
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 +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +18 -3
- data/Gemfile +1 -1
- data/README.md +3 -1
- data/Rakefile +7 -2
- data/jekyll-git-authors.gemspec +4 -2
- data/lib/jekyll-git-authors.rb +27 -126
- data/lib/jekyll-git-authors/git.rb +55 -0
- data/lib/jekyll-git-authors/markdown.rb +9 -0
- data/lib/jekyll-git-authors/version.rb +1 -1
- metadata +47 -4
- data/Gemfile.lock +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4da7350ddf894bb087396bbcdd866cc128e03d7678c471f56e6ea08fafc4e2
|
4
|
+
data.tar.gz: 3b92eef4c6399de9bc9384331ef53bebf38c2b300dd7b49d564232e68eade1d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc25d3f46dba490466259ce48d19d16fecf30d8abc3edcf4584929d64f088f821418e2788c7d170fcdc8a6d273124fc98aed8d12c4e73d22b2397fab0db22f0
|
7
|
+
data.tar.gz: 0e832ecd08ec6d381eebae13bc5c36bd080f1674a6aee10d2e8a21202fdfa3a9bca783c47f12aaf2b74a4918698f11481bd73d2eab402ab67785358cc3f33cd0
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -1,13 +1,28 @@
|
|
1
1
|
before_script:
|
2
|
-
- bundle update listen
|
3
2
|
- bundle install
|
4
3
|
|
5
4
|
test:2.4:
|
6
5
|
image: ruby:2.4
|
7
6
|
script:
|
8
|
-
-
|
7
|
+
- rake
|
9
8
|
|
10
9
|
test:2.5:
|
11
10
|
image: ruby:2.5
|
12
11
|
script:
|
13
|
-
-
|
12
|
+
- CODE_COV=TRUE rake
|
13
|
+
artifacts:
|
14
|
+
paths:
|
15
|
+
- coverage/
|
16
|
+
|
17
|
+
pages:
|
18
|
+
stage: deploy
|
19
|
+
dependencies:
|
20
|
+
- test:2.5
|
21
|
+
script:
|
22
|
+
- mv coverage/ public/
|
23
|
+
artifacts:
|
24
|
+
paths:
|
25
|
+
- public
|
26
|
+
expire_in: 30 days
|
27
|
+
only:
|
28
|
+
- master
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://gitlab.com/jackorp/jekyll-git-authors/commits/master) [](https://gitlab.com/jackorp/jekyll-git-authors/commits/master)
|
2
|
+
|
1
3
|
# Git Authors Generator for Jekyll
|
2
4
|
|
3
5
|
This generator adds last 5 authors and their obfuscated email adress from git commit history into markdown formatted page.
|
@@ -24,7 +26,7 @@ $ gem install jekyll-git-authors
|
|
24
26
|
After the plugin has been installed successfully, add the following lines to your `_config.yml` in order to tell Jekyll to use the plugin:
|
25
27
|
|
26
28
|
```
|
27
|
-
|
29
|
+
plugins:
|
28
30
|
- jekyll-git-authors
|
29
31
|
```
|
30
32
|
## Contributing
|
data/Rakefile
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
require 'rake/testtask'
|
2
|
+
require 'cucumber/rake/task'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
desc "Run tests by default"
|
5
|
+
task :default => [:test]
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
5
8
|
t.libs = ["lib"]
|
6
9
|
t.verbose = true
|
7
10
|
t.test_files = FileList['test/*_test.rb']
|
8
11
|
end
|
12
|
+
|
13
|
+
Cucumber::Rake::Task.new(:test)
|
data/jekyll-git-authors.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "jekyll-git-authors/version"
|
@@ -6,7 +5,7 @@ require "jekyll-git-authors/version"
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = "jekyll-git-authors"
|
8
7
|
spec.version = JekyllGitAuthors::VERSION
|
9
|
-
spec.authors = ["
|
8
|
+
spec.authors = ["Jaroslav Prokop"]
|
10
9
|
spec.email = ["jar.prokop@volny.cz"]
|
11
10
|
|
12
11
|
spec.summary = %q{Jekyll plugin that adds git authors into your page.}
|
@@ -31,7 +30,10 @@ Gem::Specification.new do |spec|
|
|
31
30
|
spec.add_dependency "jekyll"
|
32
31
|
spec.add_dependency "jekyll-email-protect"
|
33
32
|
|
33
|
+
spec.add_development_dependency "simplecov"
|
34
34
|
spec.add_development_dependency "bundler", "~> 1.16"
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "minitest"
|
37
|
+
spec.add_development_dependency "cucumber"
|
38
|
+
spec.add_development_dependency "rspec"
|
37
39
|
end
|
data/lib/jekyll-git-authors.rb
CHANGED
@@ -1,98 +1,11 @@
|
|
1
|
-
|
1
|
+
require 'jekyll-git-authors/version'
|
2
|
+
require 'jekyll-git-authors/markdown'
|
3
|
+
require 'jekyll-git-authors/git'
|
4
|
+
|
2
5
|
require 'jekyll'
|
3
6
|
|
4
7
|
# This script gets last 5 authors of a file and writes them at the end of the file.
|
5
8
|
|
6
|
-
module Git
|
7
|
-
# Git::Log parses output passed from Git#log and creates a hash with author as a key and email as value
|
8
|
-
class Log
|
9
|
-
# We are expecting output from "git log" command
|
10
|
-
def initialize(log)
|
11
|
-
@log = log
|
12
|
-
end
|
13
|
-
|
14
|
-
# Iterate through each line in the log
|
15
|
-
# filter out whitespace characters, split the line by semicolon
|
16
|
-
# assign the returned pair (i.e. author and email) to author and email variables
|
17
|
-
# then create hash with author as key and email as value and return it.
|
18
|
-
def author_email
|
19
|
-
author_email = Hash.new
|
20
|
-
@log.each_line do |line|
|
21
|
-
author, mail = line.strip.split(';')
|
22
|
-
|
23
|
-
author_email[author] = mail unless author_email.key?(author)
|
24
|
-
end
|
25
|
-
author_email
|
26
|
-
end
|
27
|
-
|
28
|
-
# To ensure log will be text when we want
|
29
|
-
def to_s
|
30
|
-
@log
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Git::Submodules parses output from Git#submodules and creates an array of submodules
|
35
|
-
class Submodules
|
36
|
-
# Expected input is "git submodule foreach 'echo $path'".
|
37
|
-
# That command gives us paths relative to current directory.
|
38
|
-
def initialize(paths)
|
39
|
-
@paths = paths
|
40
|
-
end
|
41
|
-
|
42
|
-
# Clean the @path from redundant text that git generates.
|
43
|
-
# First we take the @paths. We iterate through each line,
|
44
|
-
# ignore ballast git puts there 'Entering ...'
|
45
|
-
# and make it a path relative to the current directory
|
46
|
-
# that git puts there, we then add the absolute path into an array.
|
47
|
-
def extract_path
|
48
|
-
submodules = Array.new
|
49
|
-
@paths.each_line do |line|
|
50
|
-
unless line =~ /Entering/
|
51
|
-
line.strip!
|
52
|
-
line.sub!(/^#{Dir.pwd}\//, '')
|
53
|
-
|
54
|
-
submodules << line
|
55
|
-
end
|
56
|
-
end
|
57
|
-
submodules
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Take a git command and execute
|
62
|
-
# Abort if command didn't execute successfully
|
63
|
-
# then return output of the command.
|
64
|
-
def self.execute(command)
|
65
|
-
output = `git #{command}`
|
66
|
-
|
67
|
-
abort "Unknown git command: '#{command}'" unless $?.success?
|
68
|
-
|
69
|
-
return output
|
70
|
-
end
|
71
|
-
|
72
|
-
# Create instance of Git::Submodules and execute expected command.
|
73
|
-
# We receive array of absolute paths of all submodules
|
74
|
-
def self.submodules
|
75
|
-
Submodules.new(execute('submodule foreach pwd'))
|
76
|
-
end
|
77
|
-
|
78
|
-
# Create instance of Git::Log and pass it output from git log command
|
79
|
-
# return 5 last authors of a particular file
|
80
|
-
# %an returns author, semicolon for effortless parsing, %ae return email of author
|
81
|
-
def self.log(file)
|
82
|
-
Log.new(execute("log -5 --pretty=format:'%an;%ae' #{file}"))
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
module Markdown
|
87
|
-
def self.mailto(a, e)
|
88
|
-
"[#{a}](mailto:{{ '#{e}' | encode_email }})"
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.center(text)
|
92
|
-
'{:center: style="text-align: center"}' + "\n#{text}\n{:center}"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
9
|
module Jekyll
|
97
10
|
class AuthorsGenerator < Generator
|
98
11
|
safe true
|
@@ -104,46 +17,34 @@ module Jekyll
|
|
104
17
|
def generate(site)
|
105
18
|
puts "\nGenerating authors"
|
106
19
|
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
#
|
111
|
-
# before executing Git#log, then go back where we were.
|
20
|
+
# Find every .md file that is in subdirectory,
|
21
|
+
# then go into directory where page is located.
|
22
|
+
# Git finds authors for us if we call Git#log in directory
|
23
|
+
# where the file is located.
|
112
24
|
site.pages.each do |page|
|
113
25
|
file = page.path
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
author_md = Git.log(file).author_email
|
123
|
-
author_md = author_md.sort
|
124
|
-
author_md = author_md.map { |a, e| Markdown.mailto(a, e) }
|
125
|
-
|
126
|
-
output = author_md.join ', '
|
127
|
-
output = "Authors: #{output}"
|
128
|
-
output = Markdown.center output
|
129
|
-
|
130
|
-
page.content += output
|
131
|
-
|
132
|
-
Dir.chdir original_dir
|
133
|
-
else
|
134
|
-
author_md = Git.log(file).author_email
|
135
|
-
author_md = author_md.sort
|
136
|
-
author_md = author_md.map { |a, e| Markdown.mailto(a, e) }
|
137
|
-
|
138
|
-
output = author_md.join ', '
|
139
|
-
output = "Authors: #{output}"
|
140
|
-
output = Markdown.center output
|
141
|
-
|
142
|
-
page.content += output
|
143
|
-
end
|
26
|
+
# If file ends with md and if it is subdir.
|
27
|
+
# Jekyll does not add "./" into pages paths,
|
28
|
+
# so we can use this approach.
|
29
|
+
if file =~ /\.md/ and file =~ /\//
|
30
|
+
Dir.chdir File.dirname(file) do |path|
|
31
|
+
output = authors File.basename(file)
|
32
|
+
|
33
|
+
page.content += output
|
144
34
|
end
|
145
35
|
end
|
146
36
|
end
|
147
37
|
end
|
38
|
+
|
39
|
+
# Gets the authors and then adds required formatting.
|
40
|
+
def authors(file)
|
41
|
+
author_md = Git.log(file).author_email
|
42
|
+
author_md = author_md.sort
|
43
|
+
author_md = author_md.map { |a, e| Markdown.mailto(a, e) }
|
44
|
+
|
45
|
+
output = author_md.join ', '
|
46
|
+
output = "Authors: #{output}"
|
47
|
+
Markdown.center output
|
48
|
+
end
|
148
49
|
end
|
149
50
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Git
|
2
|
+
# Git::Log parses output passed from Git#log and creates a hash with author as a key and email as value
|
3
|
+
class Log
|
4
|
+
# We are expecting output from "git log" command
|
5
|
+
def initialize(log)
|
6
|
+
@log = log
|
7
|
+
end
|
8
|
+
|
9
|
+
# Iterate through each line in the log
|
10
|
+
# filter out whitespace characters, split the line by semicolon
|
11
|
+
# assign the returned pair (i.e. author and email) to author and email variables
|
12
|
+
# then create hash with author as key and email as value and return it.
|
13
|
+
# Return from function if we have 5 authors
|
14
|
+
def author_email
|
15
|
+
author_email = Hash.new
|
16
|
+
@log.each_line do |line|
|
17
|
+
author, mail = line.strip.split(';')
|
18
|
+
|
19
|
+
author_email[author] = mail unless author_email.key?(author)
|
20
|
+
|
21
|
+
return author_email if author_email.size == 5
|
22
|
+
end
|
23
|
+
author_email
|
24
|
+
end
|
25
|
+
|
26
|
+
# To ensure log will be text when we want
|
27
|
+
def to_s
|
28
|
+
@log
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Take a git command and execute
|
33
|
+
# Abort if command didn't execute successfully
|
34
|
+
# then return output of the command.
|
35
|
+
# Print custom message if required.
|
36
|
+
def self.execute(command, msg = '')
|
37
|
+
output = `git #{command}`
|
38
|
+
|
39
|
+
abort "Git command failed: '#{command}'" + " #{msg}" unless $?.success?
|
40
|
+
|
41
|
+
return output
|
42
|
+
end
|
43
|
+
|
44
|
+
# Check if file is tracked with git.
|
45
|
+
# If it is not, exit status 1 will be returned by git.
|
46
|
+
# so it will be aborted by execute method.
|
47
|
+
#
|
48
|
+
# Create instance of Git::Log and pass it output from git log command
|
49
|
+
# return 5 last authors of a particular file
|
50
|
+
# %an returns author, semicolon for effortless parsing, %ae return email of author
|
51
|
+
def self.log(file)
|
52
|
+
Git.execute("ls-files --error-unmatch #{file}", "File is not added in git: #{file}")
|
53
|
+
Log.new(execute("log --pretty=format:'%an;%ae' #{file}"))
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-git-authors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Jaroslav Prokop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,34 @@ dependencies:
|
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: cucumber
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
83
125
|
description: Jekyll plugin that adds git authors and their obfuscated email address
|
84
126
|
into page using markdown and liquid.
|
85
127
|
email:
|
@@ -91,12 +133,13 @@ files:
|
|
91
133
|
- ".gitignore"
|
92
134
|
- ".gitlab-ci.yml"
|
93
135
|
- Gemfile
|
94
|
-
- Gemfile.lock
|
95
136
|
- LICENSE.txt
|
96
137
|
- README.md
|
97
138
|
- Rakefile
|
98
139
|
- jekyll-git-authors.gemspec
|
99
140
|
- lib/jekyll-git-authors.rb
|
141
|
+
- lib/jekyll-git-authors/git.rb
|
142
|
+
- lib/jekyll-git-authors/markdown.rb
|
100
143
|
- lib/jekyll-git-authors/version.rb
|
101
144
|
homepage: https://gitlab.com/jackorp/jekyll-git-authors
|
102
145
|
licenses:
|
data/Gemfile.lock
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
jekyll-git-authors (0.1.0)
|
5
|
-
jekyll
|
6
|
-
jekyll-email-protect
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.5.2)
|
12
|
-
public_suffix (>= 2.0.2, < 4.0)
|
13
|
-
colorator (1.1.0)
|
14
|
-
concurrent-ruby (1.0.5)
|
15
|
-
em-websocket (0.5.1)
|
16
|
-
eventmachine (>= 0.12.9)
|
17
|
-
http_parser.rb (~> 0.6.0)
|
18
|
-
eventmachine (1.2.7)
|
19
|
-
ffi (1.9.25)
|
20
|
-
forwardable-extended (2.6.0)
|
21
|
-
http_parser.rb (0.6.0)
|
22
|
-
i18n (0.9.5)
|
23
|
-
concurrent-ruby (~> 1.0)
|
24
|
-
jekyll (3.8.3)
|
25
|
-
addressable (~> 2.4)
|
26
|
-
colorator (~> 1.0)
|
27
|
-
em-websocket (~> 0.5)
|
28
|
-
i18n (~> 0.7)
|
29
|
-
jekyll-sass-converter (~> 1.0)
|
30
|
-
jekyll-watch (~> 2.0)
|
31
|
-
kramdown (~> 1.14)
|
32
|
-
liquid (~> 4.0)
|
33
|
-
mercenary (~> 0.3.3)
|
34
|
-
pathutil (~> 0.9)
|
35
|
-
rouge (>= 1.7, < 4)
|
36
|
-
safe_yaml (~> 1.0)
|
37
|
-
jekyll-email-protect (1.1.0)
|
38
|
-
jekyll-sass-converter (1.5.2)
|
39
|
-
sass (~> 3.4)
|
40
|
-
jekyll-watch (2.0.0)
|
41
|
-
listen (~> 3.0)
|
42
|
-
kramdown (1.17.0)
|
43
|
-
liquid (4.0.0)
|
44
|
-
listen (3.1.5)
|
45
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
46
|
-
mercenary (0.3.6)
|
47
|
-
minitest (5.11.3)
|
48
|
-
pathutil (0.16.1)
|
49
|
-
forwardable-extended (~> 2.6)
|
50
|
-
public_suffix (3.0.2)
|
51
|
-
rake (10.5.0)
|
52
|
-
rb-fsevent (0.10.3)
|
53
|
-
rb-inotify (0.9.10)
|
54
|
-
ffi (>= 0.5.0, < 2)
|
55
|
-
rouge (3.1.1)
|
56
|
-
safe_yaml (1.0.4)
|
57
|
-
sass (3.5.6)
|
58
|
-
sass-listen (~> 4.0.0)
|
59
|
-
sass-listen (4.0.0)
|
60
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
61
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
62
|
-
|
63
|
-
PLATFORMS
|
64
|
-
ruby
|
65
|
-
|
66
|
-
DEPENDENCIES
|
67
|
-
bundler (~> 1.16)
|
68
|
-
jekyll-git-authors!
|
69
|
-
minitest
|
70
|
-
rake (~> 10.0)
|
71
|
-
|
72
|
-
BUNDLED WITH
|
73
|
-
1.16.1
|