Class: Git::Pr::Release::PullRequest

Inherits:
Object
  • Object
show all
Extended by:
Util
Includes:
Util
Defined in:
lib/git/pr/release/pull_request.rb

Constant Summary

Constants included from Util

Util::DEFAULT_PR_TEMPLATE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

build_pr_title_and_body, dump_result_as_json, git, git_config, git_config_set, host_and_repository_and_scheme, merge_pr_body, obtain_token!, request_authorization, say

Constructor Details

#initialize(pr) ⇒ PullRequest



9
10
11
# File 'lib/git/pr/release/pull_request.rb', line 9

def initialize(pr)
  @pr = pr
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



44
45
46
# File 'lib/git/pr/release/pull_request.rb', line 44

def method_missing(name, *args, &block)
  @pr.public_send name, *args, &block
end

Instance Attribute Details

#prObject (readonly)

Returns the value of attribute pr.



7
8
9
# File 'lib/git/pr/release/pull_request.rb', line 7

def pr
  @pr
end

Class Method Details

.mention_typeObject



40
41
42
# File 'lib/git/pr/release/pull_request.rb', line 40

def self.mention_type
  @mention_type ||= (ENV.fetch('GIT_PR_RELEASE_MENTION') { git_config('mention') } || 'default')
end

Instance Method Details



21
22
23
# File 'lib/git/pr/release/pull_request.rb', line 21

def html_link
  pr.rels[:html].href
end

#mentionObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/git/pr/release/pull_request.rb', line 29

def mention
  mention = case PullRequest.mention_type
            when 'author'
              pr.user ? "@#{pr.user.}" : nil
            else
              pr.assignee ? "@#{pr.assignee.}" : pr.user ? "@#{pr.user.}" : nil
            end

  mention ? " #{mention}" : ""
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean



48
49
50
# File 'lib/git/pr/release/pull_request.rb', line 48

def respond_to_missing?(name, include_private = false)
  @pr.respond_to?(name, include_private)
end

#to_checklist_item(print_title = false) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/git/pr/release/pull_request.rb', line 13

def to_checklist_item(print_title = false)
  if print_title
    "- [ ] ##{pr.number} #{pr.title}" + mention
  else
    "- [ ] ##{pr.number}" + mention
  end
end

#to_hashObject



25
26
27
# File 'lib/git/pr/release/pull_request.rb', line 25

def to_hash
  { :data => @pr.to_hash }
end