Sha256: 777efbf0510d835750eca10d06665dede80805f44b80434d5a4b3fba0f92f44d

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

require 'time'

module SCM
  module Commits
    #
    # Base-class for other SCM Commit classes.
    #
    class Commit

      # The commit hash or revision number
      attr_reader :commit

      # The date of the commit
      attr_reader :date

      # The author of the commit
      attr_reader :author

      # The summary of the commit
      attr_reader :summary

      # The full commit message of the commit
      attr_reader :message

      # The files changed by the commit
      attr_reader :files

      #
      # Creates a new commit object.
      #
      # @param [String, Integer] commit
      #   The commit hash or revision number.
      #
      # @param [Time] date
      #   The date of the commit.
      #
      # @param [String] author
      #   The author of the commit.
      #
      # @param [String] summary
      #   The summary of the commit.
      #
      # @param [String] message
      #   The full commit message of the commit.
      #
      # @param [String] files
      #   The files changed in the commit.
      #
      def initialize(commit,date,author,summary,message,files=[])
        @commit  = commit
        @date    = date
        @author  = author
        @summary = summary
        @message = message
        @files   = files
      end

      #
      # Inspects the commit.
      #
      # @return [String]
      #   The inspected commit.
      #
      def inspect
        "#<#{self.class}: #{@commit}>"
      end

      #
      # Converts the commit to a String.
      #
      # @return [String]
      #   The commit hash or revision.
      #
      def to_s
        @commit.to_s
      end

      #
      # Coerces the commit into an Array.
      #
      # @return [Array<commit, date, author, summary>]
      #   The commit components.
      #
      def to_ary
        [@commit, @date, @author, @summary]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scm-0.1.0.pre2 lib/scm/commits/commit.rb