Sha256: 2cb6c3804ecf1e7e488bb2f8fa1eb97f64786d8af8b2e77a4e5aa5f64d1af970

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

require_relative "message_formatter"
module GitFonky
  class Reporter
    attr_reader :formatter, :repo_name, :repo_branch

    def initialize(repo_name, repo_branch, formatter = MessageFormatter)
      @repo_name = repo_name
      @repo_branch = repo_branch
      @formatter = formatter.new
    end

    def announce(action, direction = "from", remote = "upstream")
      STDERR.puts "-----> #{action} #{direction} #{remote} #{repo_branch}"
    end

    def announce_sync_success
      puts "-----> Successfully synced #{repo_name} | #{repo_branch} branch"
    end

    def announce_sync_attempt
      msg = "Attempting to sync -> #{repo_name} | #{repo_branch} branch "
      formatter.message_with_border(msg: msg, border_char: "=", warn: false)
    end

    def invalid_branch_msg
      msg = "You are not on the main/master branch. Please checkout the main/master branch and try again."
      sub_msg = "-----> skipping #{repo_name} | #{repo_branch} branch <-----"
      formatter.message_with_border(msg: msg, sub_msg: sub_msg)
    end

    def failed_fetch_msg
      msg = "-----> Failed to fetch from upstream #{repo_branch}. Moving on to next repo. <-----"
      formatter.message_with_border(msg: msg)
    end

    def failed_pull_msg
      msg = "-----> Failed to pull from upstream #{repo_branch}. Moving on to next repo. <-----"
      formatter.message_with_border(msg: msg)
    end

    def failed_push_msg
      msg = "-----> Failed to push to origin #{repo_branch}. Moving on to next repo. <-----"
      formatter.message_with_border(msg: msg)
    end

    def failed_sync_msg
      msg = "-----> Failed to sync #{repo_name} | #{repo_branch}. Moving on to next repo. <-----"
      formatter.message_with_border(msg: msg)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_fonky-0.6.0 lib/git_fonky/reporter.rb