# frozen_string_literal: true module Jive class PullRequest attr_reader :dir, :uri def initialize(repo: Repo.current) @dir = Jive.home.join(repo.uri.host).join(repo.branch) Jive.shell.execute([:mkdir, "-p", @dir]) unless @dir.exist? end def edit(editor) Jive.shell.execute([editor, readme.to_s]) end private def template Jive.root.join("lib/jive/templates/pull_request.md") end def readme @readme ||= begin dir.join("README.md").tap do |readme| readme.write(template.read) unless readme.exist? end end end end end