Class: Capistrano::Slacky::Facade::Changelog

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/slacky/facade/changelog.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(previous:, current:) ⇒ Changelog

Returns a new instance of Changelog.



14
15
16
17
18
19
# File 'lib/capistrano/slacky/facade/changelog.rb', line 14

def initialize(previous:, current:)
  @difference = ::Capistrano::Slacky::Command::Diff.call(
    previous: previous,
    current: current
  )
end

Class Method Details

.for(env:) ⇒ Object



7
8
9
10
11
12
# File 'lib/capistrano/slacky/facade/changelog.rb', line 7

def self.for(env:)
  new(
    previous: env.fetch(:previous_revision),
    current: env.fetch(:current_revision)
  ).call
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/capistrano/slacky/facade/changelog.rb', line 21

def call
  if difference.empty?
    return ::Capistrano::Slacky::Block::Context.new(
      ::I18n.t("slacky.nothing_has_changed_since_the_previous_release", scope: "capistrano")
    )
  end

  difference.map do |message|
    ::Capistrano::Slacky::Block::Context.new(
      *message.to_a
    )
  end
end