jekyll-git-authors 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 962f274c866f991682c026c110fce361df5fbb1a138a41ba469ac7be6efc580d
4
+ data.tar.gz: 8554f452c67fb539b3c02ce4e2ff0193c7518950176c2258d95c34bc97b7d412
5
+ SHA512:
6
+ metadata.gz: f41aa87099c2b994b1cf66a57fd15a1716c21f72e434611494b7b2cca3fb5786b3844c65e2c8cb111806c8f5a36d6edc9f22d01296f32326d5052651159ea7dd
7
+ data.tar.gz: 8b1d6dfab838638a2e2f7fc455684fb72e92c203a067fe61d864d6f669915a81ec575254c6afc6cac44430b7b8011978f48a07ef546b356f1a328f7e6f5ada0b
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.swp
10
+ *.gem
11
+ *.bak
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,13 @@
1
+ before_script:
2
+ - bundle update listen
3
+ - bundle install
4
+
5
+ test:2.4:
6
+ image: ruby:2.4
7
+ script:
8
+ - bundle exec rake
9
+
10
+ test:2.5:
11
+ image: ruby:2.5
12
+ script:
13
+ - bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:gitlab) {|repo_name| "https://gitlab.com/#{repo_name}" }
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
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
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 jackorp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Git Authors Generator for Jekyll
2
+
3
+ This generator adds last 5 authors and their obfuscated email adress from git commit history into markdown formatted page.
4
+ Be sure to also have [jekyll-email-protect](https://github.com/vwochnik/jekyll-email-protect) installed correctly to obfuscate email addresses!
5
+
6
+ ## Installation
7
+
8
+ This plugin is available as a [rubygem]().
9
+
10
+ Add this line to your application's `Gemfile`:
11
+
12
+ ```
13
+ gem 'jekyll-git-authors'
14
+ ```
15
+
16
+ And then execute the `bundle` command to install the gem.
17
+
18
+ Alternatively, you can also manually install the gem using the following command:
19
+
20
+ ```
21
+ $ gem install jekyll-git-authors
22
+ ```
23
+
24
+ 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
+
26
+ ```
27
+ gems:
28
+ - jekyll-git-authors
29
+ ```
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome at https://gitlab.com/jackorp/jekyll-git-authors.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ task :default => :test
4
+ Rake::TestTask.new do |t|
5
+ t.libs = ["lib"]
6
+ t.verbose = true
7
+ t.test_files = FileList['test/*_test.rb']
8
+ end
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "jekyll-git-authors/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-git-authors"
8
+ spec.version = JekyllGitAuthors::VERSION
9
+ spec.authors = ["jackorp"]
10
+ spec.email = ["jar.prokop@volny.cz"]
11
+
12
+ spec.summary = %q{Jekyll plugin that adds git authors into your page.}
13
+ spec.description = %q{Jekyll plugin that adds git authors and their obfuscated email address into page using markdown and liquid.}
14
+ spec.homepage = "https://gitlab.com/jackorp/jekyll-git-authors"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = 'https://rubygems.org'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "jekyll"
32
+ spec.add_dependency "jekyll-email-protect"
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.16"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "minitest"
37
+ end
@@ -0,0 +1,137 @@
1
+ require_relative './jekyll-git-authors/version.rb'
2
+ require 'jekyll'
3
+
4
+ # This script gets last 5 authors of a file and writes them at the end of the file.
5
+
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 --recursive 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
+ module Jekyll
97
+ class AuthorsGenerator < Generator
98
+ safe true
99
+ priority :high
100
+
101
+ # iterate through pages then pick those which are
102
+ # are markdown file then call Git#log on the page
103
+ # and add authors into its content
104
+ def generate(site)
105
+ puts "\nGenerating authors"
106
+
107
+ repositories = Git.submodules
108
+
109
+ # For each submodule we go into directory of that submodule
110
+ # before executing Git#log, then go back where we were.
111
+ site.pages.each do |page|
112
+ if page.path =~ /\.md/
113
+ repositories.each do |repository|
114
+ original_dir = Dir.pwd
115
+ Dir.chdir repository
116
+ p "Going into #{repository}"
117
+
118
+ author_md = Git.log(file).author_email
119
+ author_md = author_md.sort
120
+ author_md = author_md.map { |a, e| Markdown.mailto(a, e) }
121
+
122
+ output = author_md.join ', '
123
+ output = "Authors: #{output}"
124
+ output = Markdown.center output
125
+
126
+ page.content += output
127
+
128
+ p "Adding Authors into #{page.path}"
129
+
130
+ Dir.chdir original_dir
131
+ p "Going back to #{original_dir}"
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,3 @@
1
+ module JekyllGitAuthors
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-git-authors
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - jackorp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll-email-protect
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Jekyll plugin that adds git authors and their obfuscated email address
84
+ into page using markdown and liquid.
85
+ email:
86
+ - jar.prokop@volny.cz
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".gitlab-ci.yml"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - jekyll-git-authors.gemspec
99
+ - lib/jekyll-git-authors.rb
100
+ - lib/jekyll-git-authors/version.rb
101
+ homepage: https://gitlab.com/jackorp/jekyll-git-authors
102
+ licenses:
103
+ - MIT
104
+ metadata:
105
+ allowed_push_host: https://rubygems.org
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.7.6
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Jekyll plugin that adds git authors into your page.
126
+ test_files: []