jekyll-github-metadata 2.1.1 → 2.2.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: b7d6a9d7c3a9fd754220e85041847e91bbb2e76c
4
- data.tar.gz: c9a791c58406dd4a0d27ea000cef9fae610dd1d5
3
+ metadata.gz: 1f1a95bd041ee492f07be6245ece96955116bf6f
4
+ data.tar.gz: 1d5af48b755711d9919e5837208463515a53128f
5
5
  SHA512:
6
- metadata.gz: 1f146d6c25bc4c245615e11021c8eef409d1f03d561a1c9aa8efc0dbf66f4d31e2c974f8cd69383e550d4a63fe0b7ec566b5b33135b7a93436def4f8cf1f34fd
7
- data.tar.gz: 0069d3c00e5f1dbc64b0fcb07a060c29d3b0c3ff9516831bfd822036da8031574739ca548839914e58600bc3ad1e25f053ab93fa78147395241967332895821e
6
+ metadata.gz: 49ff0399bc319d18a39efdc4a3f269505c134a53005f8b6a1a76ae2edbfda932df18c0ece5f715f3b60169e6b583e20f4c8a42deb8c1f79b51e72b31d41a5091
7
+ data.tar.gz: 16465ff246824299795e55af1d7fbba0cf6f717e858bc5d093aa23f286b4ffe520e02ada15ab3460b62628f4f70d4032b68406f5287b994cc4151078c1a829c2
@@ -4,6 +4,7 @@ module Jekyll
4
4
  module GitHubMetadata
5
5
  class Client
6
6
  InvalidMethodError = Class.new(NoMethodError)
7
+ BadCredentialsError = Class.new(StandardError)
7
8
 
8
9
  # Whitelisted API calls.
9
10
  API_CALLS = Set.new(%w(
@@ -59,10 +60,12 @@ module Jekyll
59
60
 
60
61
  def save_from_errors(default = false)
61
62
  yield @client
63
+ rescue Octokit::Unauthorized
64
+ raise BadCredentialsError, "The GitHub API credentials you provided aren't valid."
62
65
  rescue Faraday::Error::ConnectionFailed, Octokit::TooManyRequests => e
63
66
  Jekyll::GitHubMetadata.log :warn, e.message
64
67
  default
65
- rescue Octokit::NotFound, Octokit::Unauthorized => e
68
+ rescue Octokit::NotFound => e
66
69
  Jekyll::GitHubMetadata.log :error, e.message
67
70
  default
68
71
  end
@@ -71,13 +74,17 @@ module Jekyll
71
74
  "#<#{self.class.name} @client=#{client_inspect}>"
72
75
  end
73
76
 
77
+ def authenticated?
78
+ !@client.access_token.to_s.empty?
79
+ end
80
+
74
81
  private
75
82
 
76
83
  def client_inspect
77
84
  if @client.nil?
78
85
  "nil"
79
86
  else
80
- "#<#{@client.class.name} (#{"un" unless @client.access_token}authenticated)>"
87
+ "#<#{@client.class.name} (#{"un" unless authenticated?}authenticated)>"
81
88
  end
82
89
  end
83
90
 
@@ -13,6 +13,16 @@ module Jekyll
13
13
  super(nil)
14
14
  end
15
15
 
16
+ def to_s
17
+ require "json"
18
+ JSON.pretty_generate to_h
19
+ end
20
+ alias_method :to_str, :to_s
21
+
22
+ def content_methods
23
+ super - %w(to_s to_str)
24
+ end
25
+
16
26
  def keys
17
27
  super.sort
18
28
  end
@@ -34,9 +44,9 @@ module Jekyll
34
44
  end
35
45
 
36
46
  def build_revision
37
- @build_revision ||= (
47
+ @build_revision ||= begin
38
48
  ENV["JEKYLL_BUILD_REVISION"] || `git rev-parse HEAD`.strip
39
- )
49
+ end
40
50
  end
41
51
 
42
52
  def_delegator :repository, :owner_public_repositories, :public_repositories
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module GitHubMetadata
3
- VERSION = "2.1.1".freeze
3
+ VERSION = "2.2.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.1.1
4
+ version: 2.2.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-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
+ - - "!="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.4.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '4.0'
30
+ - - "!="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.4.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: jekyll
29
35
  requirement: !ruby/object:Gem::Requirement