jekyll-github-metadata 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 830071ee9a66ef5338b02ddd4ae31f46a6f2aa4b
4
- data.tar.gz: b83c56cd709c8712f771bcd6862a8a5ae24db5ee
3
+ metadata.gz: 7347cc8b75350a9f119bb515764484beadbf3b58
4
+ data.tar.gz: 356deee3da8394780051ac14bb82dbc5bf49a779
5
5
  SHA512:
6
- metadata.gz: 8471a7b1c99806e85dc7519b66bba105ecee56ebb1b48f86f15dccc9173bf94fd821979b23dd8522ec13da816638a8dac03df86a855a6deb085f9ba96d58e464
7
- data.tar.gz: 71ea515b6d692b376697488619778c3831ff343d6fa63f7a1dfb8408415fca6a158eb5ec38688756eb47301c507a31d4f768ac044817bcfdb41e28b1717f9fec
6
+ metadata.gz: 06d307897672e83283576796321325ceeb3f7ce524205bc11974c01c7b8422bc7d346640a765c3a1f4f2c0b8ea38f162784581c1a4b6a95576cc8e05664bd0ea
7
+ data.tar.gz: 39484711ab95934eb2de95fde1408e9c79ab7b83ead4ded42d4016910cf3d80ad9eb674cfec4243eec092f5c3fc6b7392ade498a879e35677c00d9bc6ad27b6b
@@ -30,7 +30,7 @@ module Jekyll
30
30
  autoload :VERSION, "jekyll-github-metadata/version"
31
31
 
32
32
  if Jekyll.const_defined? :Site
33
- require_relative "jekyll-github-metadata/ghp_metadata_generator"
33
+ require_relative "jekyll-github-metadata/site_github_munger"
34
34
  end
35
35
 
36
36
  class << self
@@ -99,7 +99,7 @@ module Jekyll
99
99
  end
100
100
 
101
101
  def nwo_from_git_origin_remote
102
- return unless Jekyll.env == "development"
102
+ return unless Jekyll.env == "development" || Jekyll.env == "test"
103
103
  matches = git_remote_url.chomp(".git").match %r!github.com(:|/)([\w-]+)/([\w\.-]+)!
104
104
  matches[2..3].join("/") if matches
105
105
  end
@@ -10,7 +10,8 @@ module Jekyll
10
10
  "PAGES_PAGES_HOSTNAME" => "github.io".freeze,
11
11
  "SSL" => "false".freeze,
12
12
  "SUBDOMAIN_ISOLATION" => "false".freeze,
13
- "PAGES_PREVIEW_HTML_URL" => nil
13
+ "PAGES_PREVIEW_HTML_URL" => nil,
14
+ "PAGE_BUILD_ID" => nil,
14
15
  }.freeze
15
16
 
16
17
  # Whether the GitHub instance supports HTTPS
@@ -75,6 +76,16 @@ module Jekyll
75
76
  trim_last_slash env_var("PAGES_PAGES_HOSTNAME", intermediate_default)
76
77
  end
77
78
 
79
+ def page_build?
80
+ !env_var("PAGE_BUILD_ID").to_s.empty?
81
+ end
82
+
83
+ def configuration
84
+ (methods - Object.methods - [:configuration]).sort.each_with_object({}) do |meth, memo|
85
+ memo[meth.to_s] = public_send(meth)
86
+ end
87
+ end
88
+
78
89
  private
79
90
  def env_var(key, intermediate_default = nil)
80
91
  !ENV[key].to_s.empty? ? ENV[key] : (intermediate_default || DEFAULTS[key])
@@ -3,17 +3,19 @@ require "uri"
3
3
 
4
4
  module Jekyll
5
5
  module GitHubMetadata
6
- class GHPMetadataGenerator < Jekyll::Generator
7
- safe true
8
-
6
+ class SiteGitHubMunger
9
7
  attr_reader :site
10
8
 
11
- def generate(site)
12
- Jekyll::GitHubMetadata.log :debug, "Initializing..."
9
+ def initialize(site)
13
10
  @site = site
11
+ end
12
+
13
+ def munge!
14
+ Jekyll::GitHubMetadata.log :debug, "Initializing..."
15
+
16
+ # This is the good stuff.
14
17
  site.config["github"] = github_namespace
15
- set_url_and_baseurl_fallbacks!
16
- @site = nil
18
+ add_url_and_baseurl_fallbacks!
17
19
  end
18
20
 
19
21
  private
@@ -22,8 +24,8 @@ module Jekyll
22
24
  case site.config["github"]
23
25
  when nil
24
26
  drop
25
- when Hash, Liquid::Drop
26
- Jekyll::Utils.deep_merge_hashes(drop, site.config["github"])
27
+ when Hash
28
+ Jekyll::Utils.deep_merge_hashes(site.config["github"], drop)
27
29
  else
28
30
  site.config["github"]
29
31
  end
@@ -33,9 +35,9 @@ module Jekyll
33
35
  @drop ||= MetadataDrop.new(site)
34
36
  end
35
37
 
36
- # Set `site.url` and `site.baseurl` if unset and in production mode.
37
- def set_url_and_baseurl_fallbacks!
38
- return unless Jekyll.env == "production"
38
+ # Set `site.url` and `site.baseurl` if unset.
39
+ def add_url_and_baseurl_fallbacks!
40
+ return unless Jekyll.env == "production" || Pages.page_build?
39
41
 
40
42
  repo = drop.send(:repository)
41
43
  site.config["url"] ||= repo.url_without_path
@@ -46,3 +48,7 @@ module Jekyll
46
48
  end
47
49
  end
48
50
  end
51
+
52
+ Jekyll::Hooks.register :site, :after_init do |site|
53
+ Jekyll::GitHubMetadata::SiteGitHubMunger.new(site).munge! unless Jekyll.env == "test"
54
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module GitHubMetadata
3
- VERSION = "2.3.1".freeze
3
+ VERSION = "2.4.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-github-metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-18 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -123,12 +123,12 @@ extra_rdoc_files: []
123
123
  files:
124
124
  - lib/jekyll-github-metadata.rb
125
125
  - lib/jekyll-github-metadata/client.rb
126
- - lib/jekyll-github-metadata/ghp_metadata_generator.rb
127
126
  - lib/jekyll-github-metadata/metadata_drop.rb
128
127
  - lib/jekyll-github-metadata/pages.rb
129
128
  - lib/jekyll-github-metadata/repository.rb
130
129
  - lib/jekyll-github-metadata/repository_compat.rb
131
130
  - lib/jekyll-github-metadata/sanitizer.rb
131
+ - lib/jekyll-github-metadata/site_github_munger.rb
132
132
  - lib/jekyll-github-metadata/value.rb
133
133
  - lib/jekyll-github-metadata/version.rb
134
134
  homepage: https://github.com/parkr/github-metadata
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.5.2
154
+ rubygems_version: 2.6.11
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: The site.github namespace