Module: Capistrano::Committed

Defined in:
lib/capistrano/committed.rb,
lib/capistrano/committed/version.rb,
lib/capistrano/committed/github_api.rb

Defined Under Namespace

Classes: GithubApi

Constant Summary collapse

VERSION =
'0.0.6'

Class Method Summary collapse

Class Method Details

.format_issue_urls(urls, pad = '') ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/capistrano/committed.rb', line 34

def format_issue_urls(urls, pad = '')
  return [] if urls.nil? || urls.empty?
  output = []
  output << format('%s   %s', pad, t('committed.output.issue_links'))
  urls.each do |url|
    output << format('%s   - %s', pad, url)
  end
  output << format('%s', pad)
end

.get_issue_urls(issue_pattern, postprocess, url_pattern, message) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/capistrano/committed.rb', line 8

def get_issue_urls(issue_pattern, postprocess, url_pattern, message)
  check_type __callee__,
             'issue_pattern',
             (issue_pattern.is_a?(String) || issue_pattern.is_a?(Regexp))

  check_type __callee__, 'postprocess', postprocess.is_a?(Array)
  postprocess.each { |method|
    check_type __callee__,
               format('postprocess[:%s]', method.to_s),
               method.is_a?(Symbol)
  }

  check_type __callee__, 'url_pattern', url_pattern.is_a?(String)
  check_type __callee__, 'message', message.is_a?(String)

  matches = message.scan(Regexp.new(issue_pattern))
  return [] unless matches
  matches.map { |match|
    issue = match[0]
    postprocess.each { |method|
      issue = issue.send(method)
    }
    format(url_pattern, issue)
  }
end