Sha256: e803e97f8a8de9f1856bbf9b54141560af8e94520c3fb94e91f5cec546e7d617

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'pr_log/command'

module PrLog
  # Top level workflow of the fetch command
  class FetchCommand < Command
    def perform
      emit(:fetching, project.milestone, project.github_repository_name)
      pull_requests = new_pull_requests

      emit(:inserting, pull_requests, config.changelog_file)
      insert_pull_requests(pull_requests)
    end

    private

    def new_pull_requests
      pull_requests = project.pull_requests_for_current_milestone

      excluded_issue_numbers = project.issue_numbers_mentioned_in_changelog

      pull_requests.reject do |pull_request|
        excluded_issue_numbers.include?(pull_request[:number])
      end
    end

    def insert_pull_requests(pull_requests)
      entries = formatter(pull_requests).entries
      injector.insert_after(config.insert_after, entries)
    end

    def formatter(pull_requests)
      Formatter.new(pull_requests,
                    config.entry_template,
                    config.label_prefixes)
    end

    def injector
      Injector.new(config.changelog_file)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pr_log-0.3.0 lib/pr_log/fetch_command.rb
pr_log-0.2.0 lib/pr_log/fetch_command.rb
pr_log-0.1.0 lib/pr_log/fetch_command.rb