forked from adarsh/gitsucker
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting classes out into different files
- Loading branch information
Showing
4 changed files
with
35 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
require 'nokogiri' | ||
|
||
class Author | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
|
||
class Repo | ||
attr_accessor :forking_authors | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|