Class: Hookers::Changelog::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/hookers/changelog/parser.rb

Constant Summary collapse

MATCHERS =
[:service_now, :bugzilla, :pivotal_tracker]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Parser

Returns a new instance of Parser.



12
13
14
# File 'lib/hookers/changelog/parser.rb', line 12

def initialize(project)
  self.project = project
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



10
11
12
# File 'lib/hookers/changelog/parser.rb', line 10

def message
  @message
end

#projectObject

Returns the value of attribute project.



10
11
12
# File 'lib/hookers/changelog/parser.rb', line 10

def project
  @project
end

Instance Method Details

#get_matcher(name) ⇒ Object



16
17
18
19
# File 'lib/hookers/changelog/parser.rb', line 16

def get_matcher(name)
  Hookers::Changelog::Matchers.const_get(
    "#{name.to_s.capitalize.gsub(/(_.)/) { |e| e[1].upcase }}Matcher")
end

#parse(line) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hookers/changelog/parser.rb', line 21

def parse(line)
  id, message = line.split(" ", 2)
  affects = []
  commit = Commit.new(project, id, message)

  matchers = MATCHERS.each do |m|
    affects += get_matcher(m).scan(commit).map(&:to_affected)
  end

  affects
end