jekyll-github-metadata 1.10.0 → 1.11.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: f3e72823f82c2827bf6da1ec2c3b0d18738afe58
4
- data.tar.gz: fd512a9002386eeeaf838bb6126be9b6cd10dd89
3
+ metadata.gz: cfca06588f4d2c2769492d9ffa8d441925de0d39
4
+ data.tar.gz: c8a940aa8c5346259cd9c587260f994a2786f0d7
5
5
  SHA512:
6
- metadata.gz: 5cd472d10371cb3226d7d49a6f557bc2ec551d0433e606dc4a54ce6ccb2659b5c74c7316f72897e3521b438bcc9079a39ec488bd1a771c7b44e0ca9822f1f815
7
- data.tar.gz: 4312ed0311b7b1b2fcd686dee1419e547335d8d38452dc81011ca9c950ff816af462bedd20152c178daf4406d219dcdd910b0452743707bbd58c2fb4e628197e
6
+ metadata.gz: 6db4dbfc1fcd303b4f4d843117756a9286cb8d920541f4e685dba9c2f4271324ab36f6e7c7276a7b6b878e84fbf91b51f46537af92454bb883dddf59f3018483
7
+ data.tar.gz: 2265206c894d2f4579ca527990dbede34a5f9ca299103583e29e5007f3d9dd6bc12821df2d783738e9857af7285c988f80e5e437dfb446999f3bfe37505f4550
@@ -31,22 +31,43 @@ module Jekyll
31
31
  def git_remote_url
32
32
  `git remote --verbose`.split("\n").grep(%r{\Aorigin\t}).map do |remote|
33
33
  remote.sub(/\Aorigin\t(.*) \([a-z]+\)/, "\\1")
34
- end.uniq.first
34
+ end.uniq.first || ""
35
35
  end
36
36
 
37
- def git_nwo
37
+ def nwo_from_git_origin_remote
38
38
  return unless Jekyll.env == "development"
39
39
  matches = git_remote_url.match %r{github.com(:|/)([\w-]+)/([\w-]+)}
40
40
  matches[2..3].join("/") if matches
41
41
  end
42
42
 
43
+ def nwo_from_env
44
+ ENV['PAGES_REPO_NWO']
45
+ end
46
+
47
+ def nwo_from_config(site)
48
+ repo = site.config['repository']
49
+ repo if repo && repo.is_a?(String) && repo.include?('/')
50
+ end
51
+
52
+ # Public: fetches the repository name with owner to fetch metadata for.
53
+ # In order of precedence, this method uses:
54
+ # 1. the environment variable $PAGES_REPO_NWO
55
+ # 2. 'repository' variable in the site config
56
+ # 3. the 'origin' git remote's URL
57
+ #
58
+ # site - the Jekyll::Site being processed
59
+ #
60
+ # Return the name with owner (e.g. 'parkr/my-repo') or raises an
61
+ # error if one cannot be found.
43
62
  def nwo(site)
44
- ENV['PAGES_REPO_NWO'] || \
45
- site.config['repository'] || \
46
- git_nwo || \
63
+ nwo_from_env || \
64
+ nwo_from_config(site) || \
65
+ nwo_from_git_origin_remote || \
47
66
  proc {
48
- raise GitHubMetadata::NoRepositoryError, "No repo name found. "
49
- "Specify using PAGES_REPO_NWO or 'repository' in your configuration."
67
+ raise GitHubMetadata::NoRepositoryError, "No repo name found. " \
68
+ "Specify using PAGES_REPO_NWO environment variables, " \
69
+ "'repository' in your configuration, or set up an 'origin' " \
70
+ "git remote pointing to your github.com repository."
50
71
  }.call
51
72
  end
52
73
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module GitHubMetadata
3
- VERSION = '1.10.0'
3
+ VERSION = '1.11.0'
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: 1.10.0
4
+ version: 1.11.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: 2016-03-25 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit