File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed
lib/jekyll-github-metadata Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,11 @@ def owner_public_repositories
8000
div>
118
118
:accept => "application/vnd.github.mercy-preview+json" ,
119
119
}
120
120
memoize_value :@owner_public_repositories , Value . new ( "owner_public_repositories" , proc do |c |
121
- c . list_repos ( owner , options ) . each { |r | r [ :releases ] = c . releases ( r [ :full_name ] ) }
121
+ c . list_repos ( owner , options ) . map do |r |
122
+ r [ :releases ] = Value . new ( "owner_public_repositories_releases" , proc { c . releases ( r [ :full_name ] ) } )
123
+ r [ :contributors ] = Value . new ( "owner_public_repositories_contributors" , proc { c . contributors ( r [ :full_name ] ) } )
124
+ r
125
+ end
122
126
end )
123
127
end
124
128
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ module Sanitizer
16
16
# resource - an Object
17
17
#
18
18
# Returns the sanitized resource.
19
- # rubocop:disable Metrics/CyclomaticComplexity
19
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
20
20
def sanitize ( resource )
21
21
case resource
22
22
when Array
@@ -31,6 +31,8 @@ def sanitize(resource)
31
31
nil
32
32
when String
33
33
resource
34
+ when Value
35
+ resource . render
34
36
else
35
37
if resource . respond_to? ( :to_hash )
36
38
sanitize_resource ( resource )
@@ -39,7 +41,7 @@ def sanitize(resource)
39
41
end
40
42
end
41
43
end
42
- # rubocop:enable Metrics/CyclomaticComplexity
44
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
43
45
44
46
# Sanitize the Sawyer Resource or Hash
45
47
# Note: the object must respond to :to_hash for this to work.
Original file line number Diff line number Diff line change 42
42
expect ( subject [ "public_repositories" ] . first [ "releases" ] . first [ "target_commitish" ] ) . to eql ( "master" )
43
43
end
44
44
45
+ it "contains the correct public_repositories.contributors" do
46
+ expect ( subject ) . to have_key ( "public_repositories" )
47
+ expect ( subject [ "public_repositories" ] . first ) . to have_key ( "contributors" )
48
+ expect ( subject [ "public_repositories" ] . first [ "contributors" ] . size ) . to eql ( 1 )
49
+ expect ( subject [ "public_repositories" ] . first [ "contributors" ] . first [ "login" ] ) . to eql ( "parkr" )
50
+ end
51
+
45
52
it "calls all the stubs" do
46
53
stubs . each do |stub |
47
54
expect ( stub ) . to have_been_requested
Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ def stub_all_api_requests
22
22
} . map { |path , file | stub_api ( path , file ) }
23
23
24
24
owner_repos = JSON . parse ( webmock_data ( "owner_repos" ) )
25
- owner_repos . each { |r | stubs << stub_api ( "/repos/#{ r [ "full_name" ] } /releases?per_page=100" , "repo_releases" ) }
25
+ owner_repos . each do |r |
26
+ stubs << stub_api ( "/repos/#{ r [ "full_name" ] } /releases?per_page=100" , "repo_releases" )
27
+ stubs << stub_api ( "/repos/#{ r [ "full_name" ] } /contributors?per_page=100" , "repo_contributors" )
28
+ end
26
29
27
30
stubs
28
31
end
You can’t perform that action at this time.
0 commit comments