class Gitlab::Dangerfiles::Changes

Public Instance Methods

added() click to toggle source

Return an Gitlab::Dangerfiles::Changes object with only the changes for the added files.

@return [Gitlab::Dangerfiles::Changes]

# File lib/gitlab/dangerfiles/changes.rb, line 20
def added
  select_by_change_type(:added)
end
by_category(category) click to toggle source

@param category [Symbol] a category of change.

@return [Gitlab::Dangerfiles::Changes] changes for the given category.

# File lib/gitlab/dangerfiles/changes.rb, line 54
def by_category(category)
  Changes.new(select { |change| change.category == category })
end
categories() click to toggle source

@return [Array<Symbol>] an array of the unique categories of changes.

# File lib/gitlab/dangerfiles/changes.rb, line 59
def categories
  map(&:category).uniq
end
deleted() click to toggle source

@return [Gitlab::Dangerfiles::Changes] the changes for the deleted files.

# File lib/gitlab/dangerfiles/changes.rb, line 30
def deleted
  select_by_change_type(:deleted)
end
files() click to toggle source

@return [Array<String>] an array of the changed files.

# File lib/gitlab/dangerfiles/changes.rb, line 64
def files
  map(&:file)
end
has_category?(category) click to toggle source

@param category [Symbol] A category of change.

@return [Boolean] whether there are any change for the given category.

# File lib/gitlab/dangerfiles/changes.rb, line 47
def has_category?(category)
  any? { |change| change.category == category }
end
modified() click to toggle source

@return [Gitlab::Dangerfiles::Changes] the changes for the modified files.

# File lib/gitlab/dangerfiles/changes.rb, line 25
def modified
  select_by_change_type(:modified)
end
renamed_after() click to toggle source

@return [Gitlab::Dangerfiles::Changes] the changes for the renamed files (after the rename).

# File lib/gitlab/dangerfiles/changes.rb, line 40
def renamed_after
  select_by_change_type(:renamed_after)
end
renamed_before() click to toggle source

@return [Gitlab::Dangerfiles::Changes] the changes for the renamed files (before the rename).

# File lib/gitlab/dangerfiles/changes.rb, line 35
def renamed_before
  select_by_change_type(:renamed_before)
end

Private Instance Methods

select_by_change_type(change_type) click to toggle source
# File lib/gitlab/dangerfiles/changes.rb, line 70
def select_by_change_type(change_type)
  Changes.new(select { |change| change.change_type == change_type })
end