Skip to content

Commit

Permalink
Splitting classes out into different files
Browse files Browse the repository at this point in the history
  • Loading branch information
adarsh committed Apr 30, 2012
1 parent cdc3675 commit 4e1ca63
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
20 changes: 5 additions & 15 deletions gitsucker.rb
@@ -1,26 +1,16 @@
#!/usr/bin/env ruby
require './lib/author'
require './lib/repo'
require 'open-uri'
require 'json'
require './lib/author'
require './lib/repo'
require './lib/table'

ORIGINAL_REPO_VALUE = 3
RUBY_REPO_VALUE = 2
JS_REPO_VALUE = 2
FORKED_REPO_VALUE = 1

ARGV.each do |input|
begin
puts 'Fetching data...'
puts '%-20s %-10s %-10s %-10s %-10s %-10s %-10s' % Author.stat_types

print '='*80
puts

Repo.new(input).get_forking_authors.each do |author|
puts '%-20s %-10s %-10s %-10s %-10s %-10s %-10s' % author.stats
end
rescue
puts 'Repo not found.'
end
table = Table.new(input)
table.output_results
end
1 change: 0 additions & 1 deletion lib/author.rb
@@ -1,4 +1,3 @@
#!/usr/bin/env ruby
require 'nokogiri'

class Author
Expand Down
2 changes: 0 additions & 2 deletions lib/repo.rb
@@ -1,5 +1,3 @@
#!/usr/bin/env ruby

class Repo
attr_accessor :forking_authors

Expand Down
30 changes: 30 additions & 0 deletions lib/table.rb
@@ -0,0 +1,30 @@
class Table
def initialize(input)
@input = input
end

def output_results
display_header

begin
Repo.new(@input).get_forking_authors.each do |author|
puts column_spacing % author.stats
end
rescue
puts 'Repo not found.'
end
end

private

def column_spacing
'%-20s %-10s %-10s %-10s %-10s %-10s %-10s'
end

def display_header
puts column_spacing % Author.stat_types
print '='*80
puts
end
end

0 comments on commit 4e1ca63

Please sign in to comment.