# frozen_string_literal: true module Jive class PullRequest attr_reader :dir, :uri def initialize(url) @uri = URI.parse(url) @dir = Pathname(Dir.home).join(".jive").join(uri.host).join(uri.path[1..-1]) 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_template.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