Class: DevTools::PRlist::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/pr_list/pull_requests.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue) ⇒ PullRequest

Returns a new instance of PullRequest.



16
17
18
# File 'lib/pr_list/pull_requests.rb', line 16

def initialize(issue)
  @issue ||= issue
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



8
9
10
# File 'lib/pr_list/pull_requests.rb', line 8

def method_missing(method_sym, *arguments, &block)
  @issue.respond_to?(method_sym) ? @issue.send(method_sym, *arguments, &block) : super
end

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



6
7
8
# File 'lib/pr_list/pull_requests.rb', line 6

def issue
  @issue
end

Instance Method Details

#dateObject



20
21
22
# File 'lib/pr_list/pull_requests.rb', line 20

def date
  @issue.created_at
end

#has_label?(filter_by) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/pr_list/pull_requests.rb', line 24

def has_label?(filter_by)
  labels.any? { |label| [filter_by].flatten.map{ |l| l.downcase.strip }.include?(label.downcase.strip) }
end

#labelsObject



28
29
30
# File 'lib/pr_list/pull_requests.rb', line 28

def labels
  @issue.labels.map { |l| l.name }
end

#repo(opt = {}) ⇒ Object



32
33
34
35
36
# File 'lib/pr_list/pull_requests.rb', line 32

def repo(opt = {})
  opt[:short] = false unless opt.has_key?(:short)

  /repos\/(\w*\/?(.*))$/.match(@issue.repository_url)[opt[:short] ? 2 : 1]
end

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

Returns:

  • (Boolean)


12
13
14
# File 'lib/pr_list/pull_requests.rb', line 12

def respond_to_missing?(method_name, include_private = false)
  @issue.respond_to?(method_name.to_sym) || super
end