Sha256: 3ccf2243eab9f2a9a59b06e65707dd4a7bb418d9c83afedc3a6f808dc8a4a251

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require_relative "title_linting"

module Gitlab
  module Dangerfiles
    Change = Struct.new(:file, :change_type, :category)

    class Changes < ::SimpleDelegator
      def added
        select_by_change_type(:added)
      end

      def modified
        select_by_change_type(:modified)
      end

      def deleted
        select_by_change_type(:deleted)
      end

      def renamed_before
        select_by_change_type(:renamed_before)
      end

      def renamed_after
        select_by_change_type(:renamed_after)
      end

      def has_category?(category)
        any? { |change| change.category == category }
      end

      def by_category(category)
        Changes.new(select { |change| change.category == category })
      end

      def categories
        map(&:category).uniq
      end

      def files
        map(&:file)
      end

      private

      def select_by_change_type(change_type)
        Changes.new(select { |change| change.change_type == change_type })
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gitlab-dangerfiles-1.1.1 lib/gitlab/dangerfiles/changes.rb
gitlab-dangerfiles-1.1.0 lib/gitlab/dangerfiles/changes.rb
gitlab-dangerfiles-1.0.0 lib/gitlab/dangerfiles/changes.rb
gitlab-dangerfiles-0.9.0 lib/gitlab/dangerfiles/changes.rb
gitlab-dangerfiles-0.8.1 lib/gitlab/dangerfiles/changes.rb
gitlab-dangerfiles-0.8.0 lib/gitlab/dangerfiles/changes.rb
gitlab-dangerfiles-0.7.0 lib/gitlab/dangerfiles/changes.rb