jekyll-git_metadata 0.0.1 → 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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +49 -9
  3. data/Rakefile +6 -0
  4. data/jekyll-git_metadata.gemspec +2 -0
  5. data/lib/jekyll/git_metadata/generator.rb +22 -26
  6. data/lib/jekyll/git_metadata/version.rb +1 -1
  7. data/test/helper.rb +28 -0
  8. data/test/test_git_metadata.rb +158 -0
  9. data/test/test_repo/.gitignore +1 -0
  10. data/test/test_repo/_config.yml +12 -0
  11. data/test/test_repo/_includes/footer.html +61 -0
  12. data/test/test_repo/_includes/head.html +12 -0
  13. data/test/test_repo/_includes/header.html +28 -0
  14. data/test/test_repo/_layouts/default.html +19 -0
  15. data/test/test_repo/_layouts/page.html +14 -0
  16. data/test/test_repo/_layouts/post.html +15 -0
  17. data/test/test_repo/_posts/2014-07-14-welcome-to-jekyll.markdown +28 -0
  18. data/test/test_repo/about.md +9 -0
  19. data/test/test_repo/css/main.css +410 -0
  20. data/test/test_repo/dot_git/COMMIT_EDITMSG +1 -0
  21. data/test/test_repo/dot_git/HEAD +1 -0
  22. data/test/test_repo/dot_git/config +7 -0
  23. data/test/test_repo/dot_git/description +1 -0
  24. data/test/test_repo/dot_git/hooks/applypatch-msg.sample +15 -0
  25. data/test/test_repo/dot_git/hooks/commit-msg.sample +24 -0
  26. data/test/test_repo/dot_git/hooks/post-update.sample +8 -0
  27. data/test/test_repo/dot_git/hooks/pre-applypatch.sample +14 -0
  28. data/test/test_repo/dot_git/hooks/pre-commit.sample +49 -0
  29. data/test/test_repo/dot_git/hooks/pre-push.sample +54 -0
  30. data/test/test_repo/dot_git/hooks/pre-rebase.sample +169 -0
  31. data/test/test_repo/dot_git/hooks/prepare-commit-msg.sample +36 -0
  32. data/test/test_repo/dot_git/hooks/update.sample +128 -0
  33. data/test/test_repo/dot_git/index +0 -0
  34. data/test/test_repo/dot_git/info/exclude +6 -0
  35. data/test/test_repo/dot_git/logs/HEAD +5 -0
  36. data/test/test_repo/dot_git/logs/refs/heads/master +5 -0
  37. data/test/test_repo/dot_git/objects/00/26c4c5df4d5148a07b9fbd790620f4e11d0802 +0 -0
  38. data/test/test_repo/dot_git/objects/0e/a9d20342677512902dde3175a73e1dd1059e67 +0 -0
  39. data/test/test_repo/dot_git/objects/25/d62f6feeb7190483f81564f4a76c1ec33d5118 +0 -0
  40. data/test/test_repo/dot_git/objects/32/3a65e20f0feb846438bbda1a0396ea2db7616e +0 -0
  41. data/test/test_repo/dot_git/objects/3e/d64bb62b98b0827096cda5da5a728ec1bf5e3e +1 -0
  42. data/test/test_repo/dot_git/objects/48/d97759a460f607e077eea99a2df7b3cd5a2601 +0 -0
  43. data/test/test_repo/dot_git/objects/4c/2dd956115a971f5376a998bc4b243022c8881e +0 -0
  44. data/test/test_repo/dot_git/objects/4d/1b13c2e1ef1c1a944aae52994682da833a5bef +1 -0
  45. data/test/test_repo/dot_git/objects/4d/7f8a4c1a1bac8d553ba169e18882a7f51235bd +0 -0
  46. data/test/test_repo/dot_git/objects/59/821b143fbc62850d08e3f70c70d02af08df684 +0 -0
  47. data/test/test_repo/dot_git/objects/60/9711c27d50b5ab6ecc7d8fd485082481f9fc4a +0 -0
  48. data/test/test_repo/dot_git/objects/62/61f5911f204a827c313081c33e2522f0dd457c +0 -0
  49. data/test/test_repo/dot_git/objects/78/845656f899d0bfd86d2806b85b0c54adddd3c8 +0 -0
  50. data/test/test_repo/dot_git/objects/7f/9eb0e6044998d71653c06fdc6e359dfbfc4211 +0 -0
  51. data/test/test_repo/dot_git/objects/83/65a44c640d5c7cafc8788607a274dfd91b89bb +3 -0
  52. data/test/test_repo/dot_git/objects/83/8ad7a02ebe551a90bea885c94191667f29009c +1 -0
  53. data/test/test_repo/dot_git/objects/83/8daa5e0163161d6e47bd1b0d783ca7307066c6 +0 -0
  54. data/test/test_repo/dot_git/objects/88/090a3ea8ce80e49ea42d249836aaa25f257454 +0 -0
  55. data/test/test_repo/dot_git/objects/8d/1f788990d1f80ebcbe7b78c3e5c393b7a41943 +0 -0
  56. data/test/test_repo/dot_git/objects/99/117f666995e8836652d9590daa2fdcb4de8b2a +0 -0
  57. data/test/test_repo/dot_git/objects/9e/00340e45d33e52bb16100f1b613a36f82f9c57 +0 -0
  58. data/test/test_repo/dot_git/objects/a9/f5097c614e0d4be7f900c04d782d3b1d675ee2 +0 -0
  59. data/test/test_repo/dot_git/objects/ae/45638b71046b28d46a764d8a2f7780fec58c01 +1 -0
  60. data/test/test_repo/dot_git/objects/af/415865cd1f1c0a5963a5d45b1335856e23dae8 +0 -0
  61. data/test/test_repo/dot_git/objects/ba/a938862bbe45533863069649b40fdebf59e81c +0 -0
  62. data/test/test_repo/dot_git/objects/c0/8f9add7a1d48045bec46451dfdbb5b5ebf8dc0 +0 -0
  63. data/test/test_repo/dot_git/objects/c8/f101653f2c1de3611232fc4c940246b06779cd +0 -0
  64. data/test/test_repo/dot_git/objects/da/077394cb4d5bf7ffac527dbfc652ec0592b423 +2 -0
  65. data/test/test_repo/dot_git/objects/e1/ec08bcf36967f7be9ec6df51c862cc86305f4f +3 -0
  66. data/test/test_repo/dot_git/objects/e3/c2be348eb0873f7ac3f500ae6daaa93ebd7959 +0 -0
  67. data/test/test_repo/dot_git/objects/e5/e6f26a0481e83434feb2de4ef29843c8a1b8b2 +0 -0
  68. data/test/test_repo/dot_git/objects/ff/74852f93c8e337b7ae3088c31cfe8673def356 +0 -0
  69. data/test/test_repo/dot_git/refs/heads/master +1 -0
  70. data/test/test_repo/feed.xml +30 -0
  71. data/test/test_repo/index.html +20 -0
  72. metadata +161 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84e075d40c99adec303ec67563ac8c95c9d14027
4
- data.tar.gz: 33c02709deea74dd3f1c36d16b2a9d45974d8146
3
+ metadata.gz: 342bad72e62590b3b7e30da46bcf49d1f2ca0f3e
4
+ data.tar.gz: 24cb75d6bdef4bdeffc284bbb9ef97729cd6a363
5
5
  SHA512:
6
- metadata.gz: cc811eeb6b0f2a1349df70eba61715ed429f5761fd2bfcb39c75c4deb3beebf28c7c074db8de9fbc4dfc78d558f30ce22d24bfe244594f1ba43d2c9d24208ae6
7
- data.tar.gz: 89fdf17ad935f296fc5f699ceec19018419c9332427f69daeec608dd5c0ab16383fe7d86174a42cb0074d451f5452c1002de13c6f3cbba46c5e5761c07ac4440
6
+ metadata.gz: 1cee24552d6e323f2c88ca4f9efcfbd497639f218accab9c764cfa2820d66c1aae6daf0ae6991ea5f7cd1579a24e1d0edce9d5a18a3147e1402c133290cca948
7
+ data.tar.gz: a9b28fb433038e6333691eb27589356c159e01acd6fd7e7392249cad6f2593f87a0633442aadd274ed6dc8013c7a9fe4b5a699e4d4a5398ed4a741e814af87a7
data/README.md CHANGED
@@ -1,24 +1,62 @@
1
1
  # Jekyll::GitMetadata
2
2
 
3
- TODO: Write a gem description
3
+ Expose Git metadata to Jekyll. Just like how Github exposes [repository metadata](https://help.github.com/articles/repository-metadata-on-github-pages), this plugin will expose information about your git repository for your templates. For example:
4
+
5
+ ```
6
+ {{site.git.total_commits}} # => Will return the total number of commits for your Jekyll repository
7
+ ```
4
8
 
5
9
  ## Installation
6
10
 
7
- Add this line to your application's Gemfile:
11
+ Add to your `Gemfile`:
8
12
 
9
- gem 'jekyll-git_metadata'
13
+ ```
14
+ gem 'jekyll-autolink_email'
15
+ ```
10
16
 
11
- And then execute:
17
+ Add to your `_config.yml`:
12
18
 
13
- $ bundle
19
+ ```yml
20
+ gems:
21
+ - jekyll-autolink_email
22
+ ```
14
23
 
15
- Or install it yourself as:
24
+ ## Usage
16
25
 
17
- $ gem install jekyll-git_metadata
26
+ This plugin adds a hash of git information to the `site` and `page` variables. The hash looks something like this:
18
27
 
19
- ## Usage
28
+ ```
29
+ {"authors"=>
30
+ [
31
+ {"commits"=>2, "name"=>"Ivan Tse", "email"=>"ivan@example.com"},
32
+ {"commits"=>5, "name"=>"John Smith", "email"=>"john@example.com"}
33
+ ],
34
+ "total_commits"=>7,
35
+ "total_additions"=>57,
36
+ "total_subtractions"=>22,
37
+ "first_commit"=>
38
+ {"short_sha"=>"d15cbe8",
39
+ "long_sha"=>"d15cbe8d0f4d4db9efda7a3daabbe966c21f3848",
40
+ "author_name"=>"John Smith",
41
+ "author_email"=>"john@example.com",
42
+ "author_date"=>"Thu Jan 16 23:36:00 2014 -0500",
43
+ "commit_name"=>"John Smith",
44
+ "commit_email"=>"john@example.com",
45
+ "commit_date"=>"Thu Jan 16 23:36:00 2014 -0500",
46
+ "message"=>"A commit!"},
47
+ "last_commit"=>
48
+ {"short_sha"=>"f88ca3b",
49
+ "long_sha"=>"f88ca3bff630efb6cdb356fad3d640534b109572",
50
+ "author_name"=>"Ivan Tse",
51
+ "author_email"=>"ivan@example.com",
52
+ "author_date"=>"Mon Jul 14 04:04:47 2014 -0400",
53
+ "commit_name"=>"John Smith",
54
+ "commit_email"=>"john@example.com",
55
+ "commit_date"=>"Mon Jul 14 04:04:47 2014 -0400",
56
+ "message"=>"Fix some stuff"}}
57
+ ```
20
58
 
21
- TODO: Write usage instructions here
59
+ To access this hash, use either `page.git` or `site.git`. `page.git` contains the git information about that particuliar page/file. `site.git` contains the git information for the entire git repository. `site.git` also includes `total_files` and `project_name` variables.
22
60
 
23
61
  ## Contributing
24
62
 
@@ -27,3 +65,5 @@ TODO: Write usage instructions here
27
65
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
66
  4. Push to the branch (`git push origin my-new-feature`)
29
67
  5. Create a new Pull Request
68
+
69
+ Suggestions for more git metadata are welcomed!
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
2
3
 
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/test_*.rb']
7
+ t.verbose = true
8
+ end
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "shoulda"
26
+ spec.add_development_dependency "mocha"
25
27
  end
@@ -11,10 +11,7 @@ module Jekyll
11
11
 
12
12
  Dir.chdir(site.source) do
13
13
  site.config['git'] = site_data
14
- site.pages.each do |page|
15
- page.data['git'] = page_data(page.relative_path)
16
- end
17
- site.posts.each do |page|
14
+ (site.pages + site.posts).each do |page|
18
15
  page.data['git'] = page_data(page.relative_path)
19
16
  end
20
17
  end
@@ -22,21 +19,13 @@ module Jekyll
22
19
  end
23
20
 
24
21
  def site_data
25
- authors = self.authors
26
- lines = self.lines
27
22
  {
28
23
  'project_name' => project_name,
29
- 'files_count' => files_count,
30
- 'authors' => authors,
31
- 'total_commits' => authors.inject(0) { |sum, h| sum += h['commits'] },
32
- 'total_additions' => lines.inject(0) { |sum, h| sum += h['additions'] },
33
- 'total_subtractions' => lines.inject(0) { |sum, h| sum += h['subtractions'] },
34
- 'first_commit' => commit(lines.last['sha']),
35
- 'last_commit' => commit(lines.first['sha'])
36
- }
24
+ 'files_count' => files_count
25
+ }.merge!(page_data)
37
26
  end
38
27
 
39
- def page_data(relative_path)
28
+ def page_data(relative_path = nil)
40
29
  authors = self.authors(relative_path)
41
30
  lines = self.lines(relative_path)
42
31
  {
@@ -53,7 +42,7 @@ module Jekyll
53
42
  results = []
54
43
  cmd = 'git shortlog -se'
55
44
  cmd << " -- #{file}" if file
56
- result = %x{#{cmd}}
45
+ result = %x{ #{cmd} }
57
46
  result.lines.each do |line|
58
47
  commits, name, email = line.scan(/(.*)\t(.*)<(.*)>/).first.map(&:strip)
59
48
  results << { 'commits' => commits.to_i, 'name' => name, 'email' => email }
@@ -64,32 +53,39 @@ module Jekyll
64
53
  def lines(file = nil)
65
54
  cmd = "git log --numstat --format='%h'"
66
55
  cmd << " -- #{file}" if file
67
- result = %x{#{cmd}}
68
- results = result.scan(/(.*)\n\n(.*)\t(.*)\t(.*)\n/)
69
- results.map { |a| a[1] = a[1].to_i; a[2] = a[2].to_i }
56
+ result = %x{ #{cmd} }
57
+ results = result.scan(/(.*)\n\n((?:.*\t.*\t.*\n)*)/)
58
+ results.map do |line|
59
+ files = line[1].scan(/(.*)\t(.*)\t(.*)\n/)
60
+ line[1] = files.inject(0){|s,a| s+=a[0].to_i}
61
+ line[2] = files.inject(0){|s,a| s+=a[1].to_i}
62
+ end
70
63
  results.map do |line|
71
- { 'sha' => line[0], 'additions' => line[1], 'subtractions' => line[2], 'file' => line[3] }
64
+ { 'sha' => line[0], 'additions' => line[1], 'subtractions' => line[2] }
72
65
  end
73
66
  end
74
67
 
75
68
  def commit(sha)
76
- result = %x{git show --format=fuller -q #{sha}}
77
- author_name, author_email, author_date, commit_name, commit_email, commit_date, message = result
78
- .scan(/.*Author:(.*)<(.*)>\nAuthorDate:(.*)\nCommit:(.*)<(.*)>\nCommitDate:(.*)\n\n(.*)/)
69
+ result = %x{ git show --format=fuller -q #{sha} }
70
+ long_sha, author_name, author_email, author_date, commit_name, commit_email, commit_date, message = result
71
+ .scan(/commit (.*)\nAuthor:(.*)<(.*)>\nAuthorDate:(.*)\nCommit:(.*)<(.*)>\nCommitDate:(.*)\n\n(.*)/)
79
72
  .first
80
73
  .map(&:strip)
81
74
  {
75
+ 'short_sha' => sha,
76
+ 'long_sha' => long_sha,
82
77
  'author_name' => author_name,
83
78
  'author_email' => author_email,
84
79
  'author_date' => author_date,
85
80
  'commit_name' => commit_name,
81
+ 'commit_email' => commit_email,
86
82
  'commit_date' => commit_date,
87
83
  'message' => message
88
84
  }
89
85
  end
90
86
 
91
87
  def project_name
92
- File.basename(%x{git rev-parse --show-toplevel}.strip)
88
+ File.basename(%x{ git rev-parse --show-toplevel }.strip)
93
89
  end
94
90
 
95
91
  def files_count
@@ -97,8 +93,8 @@ module Jekyll
97
93
  end
98
94
 
99
95
  def git_installed?
100
- void = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
101
- system "git --version >>#{void} 2>&1"
96
+ null = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
97
+ system "git --version >>#{null} 2>&1"
102
98
  end
103
99
  end
104
100
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module GitMetadata
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/unit'
3
+ require 'shoulda'
4
+ require 'mocha/mini_test'
5
+ require 'jekyll'
6
+ require 'jekyll-git_metadata'
7
+
8
+ class Minitest::Test
9
+ def jekyll_test_repo_path
10
+ File.join(File.dirname(__FILE__), 'test_repo')
11
+ end
12
+
13
+ def dot_git_path
14
+ File.join(jekyll_test_repo_path, 'dot_git')
15
+ end
16
+
17
+ def real_dot_git_path
18
+ File.join(jekyll_test_repo_path, '.git')
19
+ end
20
+
21
+ def create_temp_git_dir
22
+ FileUtils.cp_r(dot_git_path, real_dot_git_path)
23
+ end
24
+
25
+ def remove_temp_git_dir
26
+ FileUtils.rm_rf(real_dot_git_path)
27
+ end
28
+ end
@@ -0,0 +1,158 @@
1
+ require 'helper'
2
+
3
+ class Jekyll::GitMetadataTest < Minitest::Test
4
+ context 'GitMetadata' do
5
+
6
+ setup do
7
+ create_temp_git_dir
8
+ Jekyll.instance_variable_set(:@logger, Jekyll::LogAdapter.new(Jekyll::Stevenson.new, :error))
9
+
10
+ config = Jekyll.configuration(
11
+ :source => jekyll_test_repo_path,
12
+ :destination => File.join(jekyll_test_repo_path, '_site'))
13
+ @site = Jekyll::Site.new(config)
14
+ @site.read
15
+ @site.generate
16
+ end
17
+
18
+ teardown do
19
+ remove_temp_git_dir
20
+ end
21
+
22
+ context 'site data' do
23
+ setup do
24
+ @site_data = @site.config['git']
25
+ end
26
+
27
+ should 'have correct project name' do
28
+ assert_equal 'test_repo', @site_data['project_name']
29
+ end
30
+
31
+ should 'have correct files count' do
32
+ assert_equal 13, @site_data['files_count']
33
+ end
34
+
35
+ should 'have correct totals count' do
36
+ assert_equal 5, @site_data['total_commits']
37
+ assert_equal 670, @site_data['total_additions']
38
+ assert_equal 11, @site_data['total_subtractions']
39
+ end
40
+
41
+ should 'have correct authors data' do
42
+ assert_equal 2, @site_data['authors'].count
43
+ assert @site_data['authors'].include?({"commits"=>4, "name"=>"Ivan Tse", "email"=>"ivan.tse1@gmail.com"})
44
+ assert @site_data['authors'].include?({"commits"=>1, "name"=>"LeBron James", "email"=>"lbj@example.com"})
45
+ end
46
+
47
+ should 'have correct first commit data' do
48
+ assert_equal '7884565', @site_data['first_commit']['short_sha']
49
+ assert_equal '78845656f899d0bfd86d2806b85b0c54adddd3c8', @site_data['first_commit']['long_sha']
50
+ assert_equal 'Ivan Tse', @site_data['first_commit']['author_name']
51
+ assert_equal 'ivan.tse1@gmail.com', @site_data['first_commit']['author_email']
52
+ assert_equal 'Mon Jul 14 02:01:29 2014 -0400', @site_data['first_commit']['author_date']
53
+ assert_equal 'Ivan Tse', @site_data['first_commit']['commit_name']
54
+ assert_equal 'ivan.tse1@gmail.com', @site_data['first_commit']['commit_email']
55
+ assert_equal 'Mon Jul 14 02:01:29 2014 -0400', @site_data['first_commit']['commit_date']
56
+ assert_equal 'First commit with jekyll scaffold', @site_data['first_commit']['message']
57
+ end
58
+
59
+ should 'have correct last commit data' do
60
+ assert_equal '25d62f6', @site_data['last_commit']['short_sha']
61
+ assert_equal '25d62f6feeb7190483f81564f4a76c1ec33d5118', @site_data['last_commit']['long_sha']
62
+ assert_equal 'LeBron James', @site_data['last_commit']['author_name']
63
+ assert_equal 'lbj@example.com', @site_data['last_commit']['author_email']
64
+ assert_equal 'Mon Jul 14 02:12:31 2014 -0400', @site_data['last_commit']['author_date']
65
+ assert_equal 'Ivan Tse', @site_data['last_commit']['commit_name']
66
+ assert_equal 'ivan.tse1@gmail.com', @site_data['last_commit']['commit_email']
67
+ assert_equal 'Mon Jul 14 02:12:31 2014 -0400', @site_data['last_commit']['commit_date']
68
+ assert_equal 'Be more friendly', @site_data['last_commit']['message']
69
+ end
70
+ end
71
+
72
+ context 'page data' do
73
+ setup do
74
+ @about_page = @site.pages.select{|p| p.name == 'about.md'}.first
75
+ @page_data = @about_page.data['git']
76
+ end
77
+
78
+ should 'have correct totals count' do
79
+ assert_equal 3, @page_data['total_commits']
80
+ assert_equal 14, @page_data['total_additions']
81
+ assert_equal 5, @page_data['total_subtractions']
82
+ end
83
+
84
+ should 'have correct authors data' do
85
+ assert_equal 2, @page_data['authors'].count
86
+ assert @page_data['authors'].include?({"commits"=>2, "name"=>"Ivan Tse", "email"=>"ivan.tse1@gmail.com"})
87
+ assert @page_data['authors'].include?({"commits"=>1, "name"=>"LeBron James", "email"=>"lbj@example.com"})
88
+ end
89
+
90
+ should 'have correct first commit data' do
91
+ assert_equal '7884565', @page_data['first_commit']['short_sha']
92
+ assert_equal '78845656f899d0bfd86d2806b85b0c54adddd3c8', @page_data['first_commit']['long_sha']
93
+ assert_equal 'Ivan Tse', @page_data['first_commit']['author_name']
94
+ assert_equal 'ivan.tse1@gmail.com', @page_data['first_commit']['author_email']
95
+ assert_equal 'Mon Jul 14 02:01:29 2014 -0400', @page_data['first_commit']['author_date']
96
+ assert_equal 'Ivan Tse', @page_data['first_commit']['commit_name']
97
+ assert_equal 'ivan.tse1@gmail.com', @page_data['first_commit']['commit_email']
98
+ assert_equal 'Mon Jul 14 02:01:29 2014 -0400', @page_data['first_commit']['commit_date']
99
+ assert_equal 'First commit with jekyll scaffold', @page_data['first_commit']['message']
100
+ end
101
+
102
+ should 'have correct last commit data' do
103
+ assert_equal '25d62f6', @page_data['last_commit']['short_sha']
104
+ assert_equal '25d62f6feeb7190483f81564f4a76c1ec33d5118', @page_data['last_commit']['long_sha']
105
+ assert_equal 'LeBron James', @page_data['last_commit']['author_name']
106
+ assert_equal 'lbj@example.com', @page_data['last_commit']['author_email']
107
+ assert_equal 'Mon Jul 14 02:12:31 2014 -0400', @page_data['last_commit']['author_date']
108
+ assert_equal 'Ivan Tse', @page_data['last_commit']['commit_name']
109
+ assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['commit_email']
110
+ assert_equal 'Mon Jul 14 02:12:31 2014 -0400', @page_data['last_commit']['commit_date']
111
+ assert_equal 'Be more friendly', @page_data['last_commit']['message']
112
+ end
113
+ end
114
+
115
+ context 'post data' do
116
+ setup do
117
+ @welcome_post = @site.posts.select{|p| p.name == '2014-07-14-welcome-to-jekyll.markdown'}.first
118
+ @page_data = @welcome_post.data['git']
119
+ end
120
+
121
+ should 'have correct totals count' do
122
+ assert_equal 2, @page_data['total_commits']
123
+ assert_equal 28, @page_data['total_additions']
124
+ assert_equal 0, @page_data['total_subtractions']
125
+ end
126
+
127
+ should 'have correct authors data' do
128
+ assert_equal 1, @page_data['authors'].count
129
+ assert @page_data['authors'].include?({"commits"=>2, "name"=>"Ivan Tse", "email"=>"ivan.tse1@gmail.com"})
130
+ end
131
+
132
+ should 'have correct first commit data' do
133
+ assert_equal '7884565', @page_data['first_commit']['short_sha']
134
+ assert_equal '78845656f899d0bfd86d2806b85b0c54adddd3c8', @page_data['first_commit']['long_sha']
135
+ assert_equal 'Ivan Tse', @page_data['first_commit']['author_name']
136
+ assert_equal 'ivan.tse1@gmail.com', @page_data['first_commit']['author_email']
137
+ assert_equal 'Mon Jul 14 02:01:29 2014 -0400', @page_data['first_commit']['author_date']
138
+ assert_equal 'Ivan Tse', @page_data['first_commit']['commit_name']
139
+ assert_equal 'ivan.tse1@gmail.com', @page_data['first_commit']['commit_email']
140
+ assert_equal 'Mon Jul 14 02:01:29 2014 -0400', @page_data['first_commit']['commit_date']
141
+ assert_equal 'First commit with jekyll scaffold', @page_data['first_commit']['message']
142
+ end
143
+
144
+ should 'have correct last commit data' do
145
+ assert_equal '8365a44', @page_data['last_commit']['short_sha']
146
+ assert_equal '8365a44c640d5c7cafc8788607a274dfd91b89bb', @page_data['last_commit']['long_sha']
147
+ assert_equal 'Ivan Tse', @page_data['last_commit']['author_name']
148
+ assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['author_email']
149
+ assert_equal 'Mon Jul 14 02:10:03 2014 -0400', @page_data['last_commit']['author_date']
150
+ assert_equal 'Ivan Tse', @page_data['last_commit']['commit_name']
151
+ assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['commit_email']
152
+ assert_equal 'Mon Jul 14 02:10:03 2014 -0400', @page_data['last_commit']['commit_date']
153
+ assert_equal 'Edit first post', @page_data['last_commit']['message']
154
+ end
155
+ end
156
+
157
+ end
158
+ end
@@ -0,0 +1 @@
1
+ _site
@@ -0,0 +1,12 @@
1
+ # Site settings
2
+ title: Jekyll Test Site for Jekyll::GitMetadata
3
+ email: ivan.tse1@gmail.com
4
+ description: "This is a test jekyll site with git contents to properly test the Jekyll::GitMetadata generator"
5
+ baseurl: ""
6
+ url: "http://tseivan.com"
7
+ twitter_username: ivan_tse
8
+ github_username: ivantsepp
9
+
10
+ # Build settings
11
+ markdown: kramdown
12
+ permalink: pretty
@@ -0,0 +1,61 @@
1
+ <footer class="site-footer">
2
+
3
+ <div class="wrap">
4
+
5
+ <h2 class="footer-heading">{{ site.title }}</h2>
6
+
7
+ <div class="footer-col-1 column">
8
+ <ul>
9
+ <li>{{ site.title }}</li>
10
+ <li><a href="mailto:{{ site.email }}">{{ site.email }}</a></li>
11
+ </ul>
12
+ </div>
13
+
14
+ <div class="footer-col-2 column">
15
+ <ul>
16
+ {% if site.github_username %}<li>
17
+ <a href="https://github.com/{{ site.github_username }}">
18
+ <span class="icon github">
19
+ <svg version="1.1" class="github-icon-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
20
+ viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
21
+ <path fill-rule="evenodd" clip-rule="evenodd" fill="#C2C2C2" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761
22
+ c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32
23
+ c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472
24
+ c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037
25
+ C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65
26
+ c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261
27
+ c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082
28
+ c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129
29
+ c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/>
30
+ </svg>
31
+ </span>
32
+ <span class="username">{{ site.github_username }}</span>
33
+ </a>
34
+ </li>{% endif %}
35
+ {% if site.twitter_username %}<li>
36
+ <a href="https://twitter.com/{{ site.twitter_username }}">
37
+ <span class="icon twitter">
38
+ <svg version="1.1" class="twitter-icon-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
39
+ viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
40
+ <path fill="#C2C2C2" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809
41
+ c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27
42
+ c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767
43
+ c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206
44
+ C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271
45
+ c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469
46
+ c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/>
47
+ </svg>
48
+ </span>
49
+ <span class="username">{{ site.twitter_username }}</span>
50
+ </a>
51
+ </li>{% endif %}
52
+ </ul>
53
+ </div>
54
+
55
+ <div class="footer-col-3 column">
56
+ <p class="text">{{ site.description }}</p>
57
+ </div>
58
+
59
+ </div>
60
+
61
+ </footer>