Sha256: 2577ebe595cbbc63f3234c8688a6bca3bf8ba0f0d888981d51295cd37d085b06

Contents?: true

Size: 1022 Bytes

Versions: 14

Compression:

Stored size: 1022 Bytes

Contents

# -*- encoding : utf-8 -*-
module GitStats
  module GitData
    class CommandParser
      def parse(command, result)
        cmd, params = command.scan(/git (.*) (.*)/).first.map(&:split).flatten
        send("parse_#{cmd.underscore}", result, params)
      end

      def parse_shortlog(result, params)
        result.lines.map do |line|
          commits, name, email = line.scan(/(.*)\t(.*)<(.*)>/).first.map(&:strip)
          {commits: commits.to_i, name: name, email: email}
        end
      end

      def parse_ls_tree(result, params)
        result.lines.map do |line|
          mode, type, sha, filename = line.scan(/(.*) (.*) (.*)\t(.*)/).first.map(&:strip)
          {mode: mode, type: type, sha: sha, filename: filename}
        end
      end

      def parse_rev_list(result, params)
        result.lines.map do |line|
          sha, stamp, date, author_email = line.split('|').map(&:strip)
          {sha: sha, stamp: stamp, date: date, author_email: author_email}
        end
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
git_stats-1.0.13 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.12 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.11 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.10 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.9 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.8 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.7 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.6 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.5 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.4 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.3 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.2 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.1 lib/git_stats/git_data/command_parser.rb
git_stats-1.0.0 lib/git_stats/git_data/command_parser.rb