module Gouteur::Message

user-facing messages are here so they don't clutter the code

Public Instance Methods

broken(repo:, task:, output:, error:) click to toggle source
# File lib/gouteur/message.rb, line 47
    def broken(repo:, task:, output:, error:)
      <<~MSG
        👨‍🍳 Zut alors!

        Task `#{task}` failed for `#{repo}` even before inserting the new code of `#{Host.name}`.

        This likely means the task is broken or does not exist.
        #{original_output_part(output)}
        #{original_error_part(error)}
      MSG
    end
broken_after_update(repo:, task:, output:, error:) click to toggle source
# File lib/gouteur/message.rb, line 59
    def broken_after_update(repo:, task:, output:, error:)
      <<~MSG
        👨‍🍳 #{random_word_for_disgusting.capitalize}!

        Task `#{task}` failed for `#{repo}` after inserting the new code of `#{Host.name}`.

        This likely means you ruined it! (Or the task is not idempotent. Or this is a bug in gouteur.)
        #{original_output_part(output)}
        #{original_error_part(error)}
      MSG
    end
incompatible_failure(repo:) click to toggle source
# File lib/gouteur/message.rb, line 81
    def incompatible_failure(repo:)
      <<~MSG
        👨‍🍳 Zut alors!

        The new version number of `#{Host.name}` is incompatible with the version requirements specified by `#{repo}`.

        Incompatible version numbers can be allowed by removing the `locked` flag. This will make gouteur SKIP the tasks in this case.
      MSG
    end
no_dependence(repo:) click to toggle source
# File lib/gouteur/message.rb, line 39
    def no_dependence(repo:)
      <<~MSG
        👨‍🍳 Sacrebleu!

        `#{Host.name}` is not listed in the Gemfile or gemspec of `#{repo}`. Hence it does not make sense to test changes against it.
      MSG
    end
no_repos() click to toggle source
# File lib/gouteur/message.rb, line 23
    def no_repos
      <<~MSG
        👨‍🍳 Quoi?

        Found no repos to test. Pass repo URIs as command line arguments or list them under `repos:` in `#{Dotfile.path}`.
      MSG
    end
no_tasks(repo:) click to toggle source
# File lib/gouteur/message.rb, line 31
    def no_tasks(repo:)
      <<~MSG
        👨‍🍳 Quoi?

        You have defined no tasks to run for `#{repo}`.
      MSG
    end
original_error_part(stderr) click to toggle source
# File lib/gouteur/message.rb, line 91
def original_error_part(stderr)
  msg = strip(stderr)
  msg.empty? ? '' : "\n👇 The original error was:\n\n#{msg}"
end
original_output_part(stdout) click to toggle source
# File lib/gouteur/message.rb, line 96
def original_output_part(stdout)
  msg = strip(stdout)
  msg.empty? ? '' : "\n👇 The original output was:\n\n#{msg}"
end
random_word_for_disgusting() click to toggle source
# File lib/gouteur/message.rb, line 109
def random_word_for_disgusting
  %w[dégoûtant immangeable répugnant].sample
end
random_word_for_tasty() click to toggle source
# File lib/gouteur/message.rb, line 105
def random_word_for_tasty
  %w[délectable délicieux savoureux succulent].sample
end
shell_error(args:, pwd:, stderr:) click to toggle source
# File lib/gouteur/message.rb, line 6
    def shell_error(args:, pwd:, stderr:)
      <<~MSG
        👨‍🍳 Oh non!

        The command `$ #{args.join(' ')}` failed in `#{pwd}`.
        #{original_error_part(stderr)}
      MSG
    end
skipped_incompatible(repo:) click to toggle source
# File lib/gouteur/message.rb, line 71
    def skipped_incompatible(repo:)
      <<~MSG
        👨‍🍳 Attention!

        The new version number of `#{Host.name}` is incompatible with the version requirements specified by `#{repo}`.

        Releasing incompatible versions is considered OK by default, so tasks will be SKIPPED in this case. If you want gouteur to FAIL in this case, set the `locked` flag.
      MSG
    end
strip(string) click to toggle source
# File lib/gouteur/message.rb, line 101
def strip(string)
  string.to_s.gsub(/\A\s+|\s+\z/, '')
end
success(repo:) click to toggle source
# File lib/gouteur/message.rb, line 15
    def success(repo:)
      <<~MSG
        👨‍🍳 #{random_word_for_tasty.capitalize}!

        Your changes to `#{Host.name}` are fine for `#{repo}`. All tasks succeeded.
      MSG
    end