Class: PimpMyChangelog::Pimper

Inherits:
Object
  • Object
show all
Defined in:
lib/pimpmychangelog/pimper.rb

Constant Summary collapse

SEPARATOR =
"<!--- The following link definition list is generated by PimpMyChangelog --->"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, project, changelog) ⇒ Pimper

Returns a new instance of Pimper.

Parameters:

  • user (String)

    Github user of this changelog

  • project (String)

    Github project of this changelog

  • changelog (String)

    The changelog



11
12
13
14
15
# File 'lib/pimpmychangelog/pimper.rb', line 11

def initialize(user, project, changelog)
  @user = user
  @project = project
  @changelog = changelog
end

Instance Attribute Details

#changelogObject (readonly)

Returns the value of attribute changelog.



6
7
8
# File 'lib/pimpmychangelog/pimper.rb', line 6

def changelog
  @changelog
end

#projectObject (readonly)

Returns the value of attribute project.



6
7
8
# File 'lib/pimpmychangelog/pimper.rb', line 6

def project
  @project
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/pimpmychangelog/pimper.rb', line 6

def user
  @user
end

Instance Method Details

#better_changelogString

Returns The changelog with contributors and issues as link.

Returns:

  • (String)

    The changelog with contributors and issues as link



18
19
20
21
22
23
24
25
26
27
# File 'lib/pimpmychangelog/pimper.rb', line 18

def better_changelog
  parsed_changelog = Parser.new(changelog)

  # If the file doesn't have an extra newline at the end the separator gets rendered
  # as part of the changelog. So add an extra newline in that case.
  extra_newline_if_required = parsed_changelog.content.match(/\n\n\Z/) ? "" : "\n"

  linkify_changelog(parsed_changelog.content) + extra_newline_if_required +
    links_definitions(parsed_changelog.issues, parsed_changelog.contributors)
end