Skip to content

Commit eac17b6

Browse files
committed
Merge pull request #74 from seuros/github_api
Deprecating Github class in favor of Github api gem.
2 parents 364b24f + df1e922 commit eac17b6

File tree

9 files changed

+14
-9
lines changed

9 files changed

+14
-9
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ gem 'simple_form'
133133
gem 'tweet-button'
134134
gem 'mail_view'
135135
gem 'local_time'
136+
gem 'github-api'
136137

137138
# Mongo
138139
gem 'mongoid'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ GEM
271271
multi_json (~> 1.0)
272272
net-http-persistent (>= 2.7)
273273
net-http-pipeline
274+
github-api (0.0.1)
275+
httparty
274276
github-markdown (0.6.5)
275277
grackle (0.3.0)
276278
json
@@ -740,6 +742,7 @@ DEPENDENCIES
740742
fukuzatsu
741743
fuubar (= 2.0.0.rc1)
742744
geocoder
745+
github-api
743746
github-markdown
744747
grackle
745748
guard-rspec

app/models/badges/ashcat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def award?
1919
end
2020

2121
def self.perform
22-
Github.new.repo_contributors("rails", "rails").each do |contributor|
22+
GithubOld.new.repo_contributors("rails", "rails").each do |contributor|
2323
login = contributor[:login]
2424
add_contributor(login, contributor[:contributions])
2525
end

app/models/badges/entrepreneur.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def self.perform
2323
repos.each do |repo|
2424
owner, name = repo.split('/')[-2..-1]
2525

26-
Github.new.repo_contributors(owner, name).each do |contributor|
26+
GithubOld.new.repo_contributors(owner, name).each do |contributor|
2727
login = contributor[:login]
2828
add_contributor(repo, login, contributor[:contributions])
2929
end

app/models/github.rb renamed to app/models/github_old.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
class Github
1+
#@ deprecated
2+
class GithubOld
23
@@token = nil
34
GITHUB_ROOT = "https://github.com"
45
API_ROOT = 'https://api.github.com/'

app/models/github_profile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def convert_repo_into_fact(repo, orgrepo = false)
7070
end
7171

7272
def refresh!(client=nil, since)
73-
client ||= Github.new
73+
client ||= GithubOld.new
7474
username = self.login
7575

7676
profile = client.profile(username, since)

app/models/github_repo.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def for_owner_and_name(owner, name, client=nil, prefetched={})
3333
end
3434

3535
def refresh!(client=nil, repo={})
36-
client ||= Github.new
36+
client ||= GithubOld.new
3737
owner, name = self.owner.login, self.name
3838

3939
repo = client.repo(owner, name) if repo.empty?

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ def build_repo_followed_activity!(refresh=false)
939939
REDIS.zremrangebyrank(followed_repo_key, 0, Time.now.to_i) if refresh
940940
epoch_now = Time.now.to_i
941941
first_time = refresh || REDIS.zcount(followed_repo_key, 0, epoch_now) <= 0
942-
links = Github.new.activities_for(self.github, (first_time ? 20 : 1))
942+
links = GithubOld.new.activities_for(self.github, (first_time ? 20 : 1))
943943
links.each do |link|
944944
link[:user_id] = self.id
945945
REDIS.zadd(followed_repo_key, link[:date].to_i, link.to_json)

spec/models/github_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RSpec.describe Github, type: :model, functional: true, skip: ENV['TRAVIS'] do
2-
let(:github) { Github.new }
2+
let(:github) { GithubOld.new }
33

44
it 'can get profile' do
55
expect(github.profile('mdeiters')[:name]).to eq('Matthew Deiters')
@@ -47,12 +47,12 @@
4747
end
4848

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

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

0 commit comments

Comments
 (0)