Skip to content

Commit

Permalink
Added scoring and output sort by score
Browse files Browse the repository at this point in the history
  • Loading branch information
adarsh committed Apr 25, 2012
1 parent 8b7c4ff commit e9a9fff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
10 changes: 5 additions & 5 deletions features/step_definitions/gitsucker_steps.rb
Expand Up @@ -8,9 +8,9 @@
end

Then /^I should get the appropriate output$/ do
@output.should include("Username/projects/original/forked/ruby/js/score")
@output.should include("garethrees, 33, 24, 9, 18, 3, 999")
@output.should include("caozhzh, 9, 5, 4, 7, 0, 999")
@output.should include("mbleigh, 64, 36, 28, 51, 5, 999")
@output.should include("donhill, 14, 1, 13, 6, 0, 999")
@output.should include("Username/projects/original/forked/ruby/js/score!")
@output.should include("mbleigh, 64, 36, 28, 51, 5, 28!")
@output.should include("donhill, 14, 1, 13, 6, 0, 13!")
@output.should include("garethrees, 33, 24, 9, 18, 3, 9!")
@output.should include("caozhzh, 9, 5, 4, 7, 0, 4!")
end
19 changes: 15 additions & 4 deletions gitsucker.rb
Expand Up @@ -50,6 +50,8 @@ def get_forking_authors(repo, author)
author_hash = score_author(author_hash)
@forking_authors << author_hash
end

sort_authors
end

private
Expand Down Expand Up @@ -99,24 +101,33 @@ def ruby_repo_count(page)
end

def score_author(author)
author[:score] = "999"
score = author[:originals] * 3
score = author[:ruby] * 2
score = author[:js] * 2
score = author[:forked] * 1

author[:score] = score
author
end

def sort_authors
@forking_authors = @forking_authors.sort_by { |hsh| -hsh[:score] }
end
end

# Command-Line Parsing
ARGV.each do |input|
repo = GithubRepo.new(input)
puts "Username/projects/original/forked/ruby/js/score"
puts "Username/projects/original/forked/ruby/js/score!"

repo.fork_authors.each do |forking_author|

forking_author.each do |key, value|
print value.to_s
if key == :score
puts
puts '!'
else
print ", "
print ', '
end
end
end
Expand Down

0 comments on commit e9a9fff

Please sign in to comment.