Skip to content

Deprecating Github class in favor of Github api gem. #74

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 1 commit into from
Jul 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ gem 'simple_form'
gem 'tweet-button'
gem 'mail_view'
gem 'local_time'
gem 'github-api'

# Mongo
gem 'mongoid'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ GEM
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-pipeline
github-api (0.0.1)
httparty
github-markdown (0.6.5)
grackle (0.3.0)
json
Expand Down Expand Up @@ -740,6 +742,7 @@ DEPENDENCIES
fukuzatsu
fuubar (= 2.0.0.rc1)
geocoder
github-api
github-markdown
grackle
guard-rspec
Expand Down
2 changes: 1 addition & 1 deletion app/models/badges/ashcat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def award?
end

def self.perform
Github.new.repo_contributors("rails", "rails").each do |contributor|
GithubOld.new.repo_contributors("rails", "rails").each do |contributor|
login = contributor[:login]
add_contributor(login, contributor[:contributions])
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/badges/entrepreneur.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.perform
repos.each do |repo|
owner, name = repo.split('/')[-2..-1]

Github.new.repo_contributors(owner, name).each do |contributor|
GithubOld.new.repo_contributors(owner, name).each do |contributor|
login = contributor[:login]
add_contributor(repo, login, contributor[:contributions])
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/github.rb → app/models/github_old.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Github
#@ deprecated
class GithubOld
@@token = nil
GITHUB_ROOT = "https://github.com"
API_ROOT = 'https://api.github.com/'
Expand Down
2 changes: 1 addition & 1 deletion app/models/github_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def convert_repo_into_fact(repo, orgrepo = false)
end

def refresh!(client=nil, since)
client ||= Github.new
client ||= GithubOld.new
username = self.login

profile = client.profile(username, since)
Expand Down
2 changes: 1 addition & 1 deletion app/models/github_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def for_owner_and_name(owner, name, client=nil, prefetched={})
end

def refresh!(client=nil, repo={})
client ||= Github.new
client ||= GithubOld.new
owner, name = self.owner.login, self.name

repo = client.repo(owner, name) if repo.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ def build_repo_followed_activity!(refresh=false)
REDIS.zremrangebyrank(followed_repo_key, 0, Time.now.to_i) if refresh
epoch_now = Time.now.to_i
first_time = refresh || REDIS.zcount(followed_repo_key, 0, epoch_now) <= 0
links = Github.new.activities_for(self.github, (first_time ? 20 : 1))
links = GithubOld.new.activities_for(self.github, (first_time ? 20 : 1))
links.each do |link|
link[:user_id] = self.id
REDIS.zadd(followed_repo_key, link[:date].to_i, link.to_json)
Expand Down
6 changes: 3 additions & 3 deletions spec/models/github_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe Github, type: :model, functional: true, skip: ENV['TRAVIS'] do
let(:github) { Github.new }
let(:github) { GithubOld.new }

it 'can get profile' do
expect(github.profile('mdeiters')[:name]).to eq('Matthew Deiters')
Expand Down Expand Up @@ -47,12 +47,12 @@
end

it 'should scope requests by user' do
daniel = Github.new(daniel_h = '697b68755f419b475299873164e3c60fca21ae58')
daniel = GithubOld.new(daniel_h = '697b68755f419b475299873164e3c60fca21ae58')
expect(daniel.profile['login']).to eq('flyingmachine')
end

it 'should scope requests by user but allow override' do
daniel = Github.new(daniel_h = '697b68755f419b475299873164e3c60fca21ae58')
daniel = GithubOld.new(daniel_h = '697b68755f419b475299873164e3c60fca21ae58')
expect(daniel.profile['login']).not_to eq(daniel.profile('bguthrie')['login'])
end
end