Sha256: 7dbcbb82c46f983222ad90204d61703a7972b9e8a609b908f27a69e29f5c222e

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

module Ghit
  module Stats

    class Contributors
      class << self
        def get!
          new.get
        end
      end

      def initialize
        @globals = Ghit::Globals.new
        @stats   = Github::Client::Repos::Statistics.new
      end

      def get
        contributors = fetch_contributors
        
        print_output_heading
        contributors.each do |c|
          print_contributor_data c
        end
        print_fourty_dashes
      end

      private

      def fetch_contributors
        @stats.contributors(user: @globals.author, repo: @globals.repository).body
      end

      def print_output_heading
        puts "List of contributors to this repository:"
        print_fourty_dashes 
        puts "Username\t\tProfile URL"
        print_fourty_dashes   
      end

      def print_fourty_dashes
        puts "-" * 40
      end

      def print_contributor_data contrib
        if contrib.respond_to? :author
          puts "#{contrib.author.login}\t\t#{contrib.author.html_url}"
        else
          puts "#{contrib.login}\t\t#{contrib.html_url}"
        end
      end

    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ghit-0.2.4 lib/ghit/stats/contributors.rb
ghit-0.2.3 lib/ghit/stats/contributors.rb
ghit-0.2.2 lib/ghit/stats/contributors.rb
ghit-0.2.1 lib/ghit/stats/contributors.rb
ghit-0.2.0 lib/ghit/stats/contributors.rb