Skip to content

Commit 362b0ae

Browse files
committed
Add new attributes to return for users and repos
This commit: - Adds `hireable` to the whitelisted attributes available on the `owner` hash. - Adds decorator methods for `stargazers_count` and `forks_count` to the `Repository` object. Why? - This will allow users of this gem to access more useful information from users and repositories.
1 parent 6e08726 commit 362b0ae

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939
it "respects the source branch" do
4040
expect(repo.git_ref).to eql("master")
4141
end
42+
43+
it "returns the stargazers_count" do
44+
expect(repo.stargazers_count).to eq(22)
45+
end
46+
47+
it "returns the fork count" do
48+
expect(repo.forks_count).to eq(4)
49+
end
4250
end
4351

4452
context "hubot.github.com" do

0 commit comments

Comments
 (0)