Sha256: a2e043d535bdc9219fc55c1109c035440aa65f5d5b92cd8d86f5c243d911075a

Contents?: true

Size: 642 Bytes

Versions: 3

Compression:

Stored size: 642 Bytes

Contents

# 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jive-0.7.0 lib/jive/pull_request.rb
jive-0.6.0 lib/jive/pull_request.rb
jive-0.5.0 lib/jive/pull_request.rb