class Changelog::Notifier::Entrypoints::Capistrano
Tries to publish the version's release note after a successful Capistrano
deployment.
Public Class Methods
new(instance)
click to toggle source
# File lib/changelog/notifier/entrypoints/capistrano.rb, line 11 def initialize(instance) @capistrano = instance end
run!(instance)
click to toggle source
# File lib/changelog/notifier/entrypoints/capistrano.rb, line 22 def self.run!(instance) entrypoint = Changelog::Notifier::Entrypoints::Capistrano.new(instance) entrypoint.publish_release_note end
Public Instance Methods
publish_release_note()
click to toggle source
# File lib/changelog/notifier/entrypoints/capistrano.rb, line 15 def publish_release_note ensure_release_has_changelog_file && fetch_version_from_git_tags_and_commit_author && parse_changelog_file && run_through_adapters end
Private Instance Methods
ensure_release_has_changelog_file()
click to toggle source
# File lib/changelog/notifier/entrypoints/capistrano.rb, line 29 def ensure_release_has_changelog_file return true if File.file?('CHANGELOG.md') @capistrano.warn 'You repository has no CHANGELOG.md file. ' \ 'Skipping sending release note.' false end
parse_changelog_file()
click to toggle source
# File lib/changelog/notifier/entrypoints/capistrano.rb, line 76 def parse_changelog_file parser = Changelog::Notifier::Parsers::Markdown.new( File.read('CHANGELOG.md') ) @release_note_hash = parser.extract(@version) @release_note_hash[:author] = @author @release_note_hash[:application] = @capistrano.fetch( :application, 'the application' ) true rescue ArgumentError => error @capistrano.error "Parsing CHANGELOG.md failed: #{error.message}. " \ 'Skipping sending release note.' rescue Changelog::Notifier::ReleaseNoteNotFound @capistrano.error 'Parsing CHANGELOG.md failed: Missing release ' \ "note for version #{@version}." \ 'Skipping sending release note.' end
run_through_adapters()
click to toggle source
# File lib/changelog/notifier/entrypoints/capistrano.rb, line 99 def run_through_adapters [ Changelog::Notifier::Adapters::ActiveRecord, Changelog::Notifier::Adapters::Slack ].each do |adapter_class| adapter = adapter_class.new(@capistrano) next unless adapter.configured? adapter.publish!(@release_note_hash, @version) end rescue StandardError => error @capistrano.error error.message end