8000 Merge pull request #158 from kenyonj/jk-add-repo-stars-forks-hireable · jekyll/github-metadata@f6308d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit f6308d0

Browse files
authored
Merge pull request #158 from kenyonj/jk-add-repo-stars-forks-hireable
Add new attributes to return for users and repositories
2 parents 6e08726 + 8b62111 commit f6308d0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/jekyll-github-metadata/repository.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def repo_pages_info_opts
105105
:public_gists,
106106
:followers,
107107
:following,
108+
:hireable,
108109
:created_at,
109110
:updated_at,
110111
])
@@ -237,6 +238,14 @@ def url_without_path
237238
uri.dup.tap { |u| u.path = "" }.to_s
238239
end
239240

241+
def stargazers_count
242+
repo_pages_info["stargazers_count"] || 0
243+
end
244+
245+
def forks_count
246+
repo_pages_info["forks_count"] || 0
247+
end
248+
240249
private
241250

242251
def memoize_value(var_name, value)

spec/repository_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@
4141
end
4242
end
4343

44+
context "repository information" do
45+
let(:nwo) { "jekyll/jekyll" }
46+
let!(:stub) do
47+
stub_api(
48+
"/repos/#{nwo}/pages",
49+
"repo",
50+
"Accept" => "application/vnd.github.v3+json"
51+
)
52+
end
53+
54+
it "returns the stargazers_count" do
55+
expect(repo.stargazers_count).to eq(22)
56+
end
57+
58+
it "returns the fork count" do
59+
expect(repo.forks_count).to eq(4)
60+
end
61+
end
62+
4463
context "hubot.github.com" do
4564
let(:nwo) { "github/hubot.github.com" }
4665
let!(:stub) { stub_api("/repos/#{nwo}/pages", "hubot_repo_pages") }

0 commit comments

Comments
 (0)
0