Class: Gitlab::Dangerfiles::Changes

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/gitlab/dangerfiles/changes.rb

Instance Method Summary collapse

Instance Method Details

#addedGitlab::Dangerfiles::Changes

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



20
21
22
# File 'lib/gitlab/dangerfiles/changes.rb', line 20

def added
  select_by_change_type(:added)
end

#by_category(category) ⇒ Gitlab::Dangerfiles::Changes

Returns changes for the given category.

Parameters:

  • category (Symbol)

    a category of change.

Returns:



54
55
56
# File 'lib/gitlab/dangerfiles/changes.rb', line 54

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

#categoriesArray<Symbol>

Returns an array of the unique categories of changes.

Returns:

  • (Array<Symbol>)

    an array of the unique categories of changes.



59
60
61
# File 'lib/gitlab/dangerfiles/changes.rb', line 59

def categories
  map(&:category).uniq
end

#deletedGitlab::Dangerfiles::Changes

Returns the changes for the deleted files.

Returns:



30
31
32
# File 'lib/gitlab/dangerfiles/changes.rb', line 30

def deleted
  select_by_change_type(:deleted)
end

#filesArray<String>

Returns an array of the changed files.

Returns:

  • (Array<String>)

    an array of the changed files.



64
65
66
# File 'lib/gitlab/dangerfiles/changes.rb', line 64

def files
  map(&:file).uniq
end

#has_category?(category) ⇒ Boolean

Returns whether there are any change for the given category.

Parameters:

  • category (Symbol)

    A category of change.

Returns:

  • (Boolean)

    whether there are any change for the given category.



47
48
49
# File 'lib/gitlab/dangerfiles/changes.rb', line 47

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

#modifiedGitlab::Dangerfiles::Changes

Returns the changes for the modified files.

Returns:



25
26
27
# File 'lib/gitlab/dangerfiles/changes.rb', line 25

def modified
  select_by_change_type(:modified)
end

#renamed_afterGitlab::Dangerfiles::Changes

Returns the changes for the renamed files (after the rename).

Returns:



40
41
42
# File 'lib/gitlab/dangerfiles/changes.rb', line 40

def renamed_after
  select_by_change_type(:renamed_after)
end

#renamed_beforeGitlab::Dangerfiles::Changes

Returns the changes for the renamed files (before the rename).

Returns:



35
36
37
# File 'lib/gitlab/dangerfiles/changes.rb', line 35

def renamed_before
  select_by_change_type(:renamed_before)
end