Permalink
Browse files

move class files to lib directory

  • Loading branch information...
oblakeerickson committed Jan 25, 2014
1 parent 9c145de commit d4e762443a1a96ee804ee28cc4247065f6377172

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,5 +1,4 @@
class User < ActiveRecord::Base
include ConnectionHelper
has_many :contributions
validates :github_id, presence: true, uniqueness: true
validates :username, presence: true, uniqueness: true
@@ -25,5 +25,6 @@ class Application < Rails::Application
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
I18n.enforce_available_locales = true
config.autoload_paths += %W(#{config.root}/lib)
end
end
@@ -0,0 +1,37 @@
class Connection
def initialize
username = get_username
password = get_password
@client = Octokit::Client.new :login => username, :password => password
end
def username
@client.login
end

def user(username)
@client.user username
end

def rate_limit
@client.user 'oblakeerickson'
response = @client.last_response
@rate_limit = response.headers[:'x-ratelimit-remaining'].to_i
end

def user_list(since)
@list = @client.all_users :since => since
end

def last_user(list)
list.last.id
end

private

def get_username
LongestStreak1::Application.config.github_username
end
def get_password
LongestStreak1::Application.config.github_password
end
end
@@ -0,0 +1,24 @@
class GithubUser
def initialize(user)
@id = user.id
@login = user.login
#contributions = Contributions.new(@login)
#@streak = contributions.longest_streak
end
def id
@id
end
def login
@login
end
# def streak
# @streak
# end
def print
#puts "id: #{id} | login: #{login} | streak: #{streak}"
puts "id: #{id} | login: #{login}"
end
def save
#DB.run("insert into user (id, login, longest_streak) values('#{id}', '#{login}', '#{streak}')")
end
end
@@ -2,11 +2,11 @@ namespace :users do
desc "Fetch users from GitHub"
task populate: :environment do
user = User.new
connection = ConnectionHelper::Connection.new
connection = Connection.new
puts connection.username
list = connection.user_list(0)
list.each do |u|
my_user = GithubUserHelper::GithubUser.new(u)
my_user = GithubUser.new(u)
my_user.print
end
end

0 comments on commit d4e7624

Please sign in to comment.