Module: Danger::Changelog::Config

Defined in:
lib/changelog/config.rb

Constant Summary collapse

ATTRIBUTES =
%i[
  placeholder_line
  filename
  format
  ignore_files
].freeze
ACCESSORS =
ATTRIBUTES.map { |name| "#{name}=".to_sym }
DELEGATORS =
ATTRIBUTES + ACCESSORS

Class Method Summary collapse

Class Method Details

.format=(value) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
# File 'lib/changelog/config.rb', line 32

def format=(value)
  raise ArgumentError, "Invalid format: #{value}" unless Danger::Changelog::Parsers.valid?(value)

  @format = value
end

.ignore_files=(value) ⇒ Object



42
43
44
# File 'lib/changelog/config.rb', line 42

def ignore_files=(value)
  @ignore_files = Array(value)
end

.parserObject



46
47
48
# File 'lib/changelog/config.rb', line 46

def parser
  Danger::Changelog::Parsers.lookup(format)
end

.placeholder_line=(value) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/changelog/config.rb', line 21

def placeholder_line=(value)
  if value
    new_value = value
    new_value = "* #{new_value}" unless new_value.start_with?('* ')
    new_value = "#{new_value}\n" unless new_value.end_with?("\n")
    @placeholder_line = new_value
  else
    @placeholder_line = nil
  end
end

.placeholder_line?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/changelog/config.rb', line 38

def placeholder_line?
  !@placeholder_line.nil?
end

.resetObject



50
51
52
53
54
55
# File 'lib/changelog/config.rb', line 50

def reset
  self.placeholder_line = "* Your contribution here.\n"
  self.filename = 'CHANGELOG.md'
  self.format = Danger::Changelog::Parsers.default_format
  self.ignore_files = ['README.md']
end