lib/love/author.rb in share_some_love-0.0.5 vs lib/love/author.rb in share_some_love-0.1.1

- old
+ new

@@ -15,16 +15,12 @@ begin search_person = Love.octokit.search_users uri @info = \ if search_person.count > 1 puts '!!! THERE ARE SEVERAL PERSONS WITH THIS NAME IN GITHUB !!!' - puts "Please check right man with his number and we'll continue" - search_person.each_with_index do |person, index| - puts "#{index} - name: #{person.name}; login: #{person.login}; username: #{person.username}" - end + user_num = pick_user(search_person) - user_num = $stdin.gets.chomp.to_i Love.octokit.user search_person[user_num].login else Love.octokit.user search_person.first.login end puts "found #{@info.login}" @@ -35,9 +31,30 @@ end end def add_gem(gem) @gems << gem + end + + private + + def pick_user(users) + if Love.check_author + puts "Please check right man with his number and we'll continue" + else + puts "To check author manually please restart with option -v" + end + + users.each_with_index do |person, index| + puts "#{index} - name: #{person.name}; login: #{person.login}; username: #{person.username}" + end + + if Love.check_author + $stdin.gets.chomp.to_i + else + puts "Taken first" + 0 + end end end end