jekyll-github-metadata 1.3.0 → 1.4.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 +4 -4
- data/lib/jekyll-github-metadata/client.rb +43 -6
- data/lib/jekyll-github-metadata/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a689abbad33da0acae73946e5e8790eeb0585c71
|
4
|
+
data.tar.gz: 807013e4558fb9a3c6d2fcc60478fd3ab6ca0985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25517ea5ed48b870431aad55683740bf52ad4b98815bad34c927ee3d3835ba398cf4bc5d3123608f9c9e2d5e2c33bff7ab45024b89847d04c2e77af427551eca
|
7
|
+
data.tar.gz: e73e4b85cb22f22bcbab6aea00b97ab2507e1f11beaf97187d31c49a6283108873290e627f3e36f944ca0bd077904a34f925f85b8bc4a4a1746aa663493b46c7
|
@@ -1,6 +1,20 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module GitHubMetadata
|
3
3
|
class Client
|
4
|
+
InvalidMethodError = Class.new(NoMethodError)
|
5
|
+
|
6
|
+
# Whitelisted API calls.
|
7
|
+
API_CALLS = %w{
|
8
|
+
repository
|
9
|
+
organization
|
10
|
+
repository?
|
11
|
+
pages
|
12
|
+
contributors
|
13
|
+
releases
|
14
|
+
list_repos
|
15
|
+
organization_public_members
|
16
|
+
}.freeze
|
17
|
+
|
4
18
|
def initialize(options = nil)
|
5
19
|
@client = build_octokit_client(options)
|
6
20
|
end
|
@@ -20,14 +34,25 @@ module Jekyll
|
|
20
34
|
Octokit::Client.new({:auto_paginate => true}.merge(options))
|
21
35
|
end
|
22
36
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
37
|
+
def accepts_client_method?(method_name)
|
38
|
+
API_CALLS.include?(method_name.to_s) && @client.respond_to?(method_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def respond_to?(method_name, include_private = false)
|
42
|
+
accepts_client_method?(method_name) || super
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(method_name, *args, &block)
|
46
|
+
method = method_name.to_s
|
47
|
+
if accepts_client_method?(method_name)
|
48
|
+
instance_var_name = method.sub('?', '_')
|
49
|
+
Jekyll.logger.debug "GitHub Metadata:", "Calling @client.#{method}(#{args.map(&:inspect).join(", ")})"
|
27
50
|
instance_variable_get(:"@#{instance_var_name}") ||
|
28
|
-
instance_variable_set(:"@#{instance_var_name}", save_from_errors { @client.
|
51
|
+
instance_variable_set(:"@#{instance_var_name}", save_from_errors { @client.public_send(method_name, *args, &block) })
|
52
|
+
elsif @client.respond_to?(method_name)
|
53
|
+
raise InvalidMethodError, "#{method_name} is not whitelisted on #{inspect}"
|
29
54
|
else
|
30
|
-
super
|
55
|
+
super
|
31
56
|
end
|
32
57
|
end
|
33
58
|
|
@@ -44,8 +69,20 @@ module Jekyll
|
|
44
69
|
default
|
45
70
|
end
|
46
71
|
|
72
|
+
def inspect
|
73
|
+
"#<#{self.class.name} @client=#{client_inspect}>"
|
74
|
+
end
|
75
|
+
|
47
76
|
private
|
48
77
|
|
78
|
+
def client_inspect
|
79
|
+
if @client.nil?
|
80
|
+
"nil"
|
81
|
+
else
|
82
|
+
"#<#{@client.class.name} (#{"un" unless @client.access_token}authenticated)>"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
49
86
|
def pluck_auth_method
|
50
87
|
if ENV['JEKYLL_GITHUB_TOKEN'] || Octokit.access_token
|
51
88
|
{ :access_token => ENV['JEKYLL_GITHUB_TOKEN'] || Octokit.access_token }
|
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.
|
4
|
+
version: 1.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: 2016-02-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|