Sha256: beddcd2e615d6b5c2aaf446b52f6b1cee9e33fd1a1972ec91ab9a8ce7f4cf92f

Contents?: true

Size: 686 Bytes

Versions: 5

Compression:

Stored size: 686 Bytes

Contents

# 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jive-0.4.4 lib/jive/pull_request.rb
jive-0.4.3 lib/jive/pull_request.rb
jive-0.4.2 lib/jive/pull_request.rb
jive-0.4.1 lib/jive/pull_request.rb
jive-0.4.0 lib/jive/pull_request.rb