Sha256: 735621496da9034775a5e9e64db40778a235a06ce37ece1af79d70f7b3fe998d

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

module VCLog

  # The Change class models an entry in a change log.
  #
  class ChangePoint

    # Type of change, as assigned by hueristics.
    attr_accessor :type

    # The priority level of this change, as assigned by hueristics.
    # This can be `nil`, as Heuristics will always make sure a
    # commit has an inteer level before going out to template.
    attr_accessor :level

    # The descriptive label of this change, as assigned by hueristics.
    attr_accessor :label

    # ANSI color to apply. Actually this can be a list
    # of any support ansi gem terms, but usually it's 
    # just the color term, such as `:red`.
    attr_accessor :color

    #
    def initialize(change, message)
      @change  = change
      @message = message.strip

      @label = nil
      @level = nil
    end

    # Change from which point is derived.
    attr :change

    # The point's message.
    attr_accessor :message
    alias_method :msg,  :message
    alias_method :msg=, :message=

    # Delegate missing methods to +change+.
    def method_missing(s,*a,&b)
      if @change.respond_to?(s)
        @change.send(s,*a,&b)
      else
p caller
        super(s,*a,&b)
      end
    end

    # Change points do not have sub-points.
    def points
      []
    end

    # Apply heuristic rules to change.
    def apply_heuristics(heuristics)
      heuristics.apply(self)
    end

    #
    def to_h
      { 'author'   => change.author,
        'date'     => change.date,
        'id'       => change.id,
        'message'  => message,
        'type'     => type
      }
    end

    #
    def to_s(*)
      message
    end

  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rubycut-vclog-1.9.5.1 lib/vclog/change_point.rb
rubycut-vclog-1.9.5 lib/vclog/change_point.rb
rubycut-vclog-1.9.4 lib/vclog/change_point.rb
vclog-1.9.2 lib/vclog/change_point.rb
vclog-1.9.1 lib/vclog/change_point.rb
vclog-1.9.0 lib/vclog/change_point.rb