8000 Add new attributes to return for users and repositories by kenyonj · Pull Request #158 · jekyll/github-metadata · GitHub
[go: up one dir, main page]

Skip to content

Add new attributes to return for users and repositories #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
kenyonj committed Jan 29, 2019
commit 362b0aefe6101feee504fbc2d9790183f706d4d5
9 changes: 9 additions & 0 deletions lib/jekyll-github-metadata/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def repo_pages_info_opts
:public_gists,
:followers,
:following,
:hireable,
:created_at,
:updated_at,
])
Expand Down Expand Up @@ -237,6 +238,14 @@ def url_without_path
uri.dup.tap { |u| u.path = "" }.to_s
end

def stargazers_count
repo_pages_info["stargazers_count"] || 0
end

def forks_count
repo_pages_info["forks_count"] || 0
end

private

def memoize_value(var_name, value)
Expand Down
8 changes: 8 additions & 0 deletions spec/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
it "respects the source branch" do
expect(repo.git_ref).to eql("master")
end

it "returns the stargazers_count" do
expect(repo.stargazers_count).to eq(22)
end

it "returns the fork count" do
expect(repo.forks_count).to eq(4)
end
end

context "hubot.github.com" do
Expand Down
0