Class: PairSee::LogLine
- Inherits:
-
Object
- Object
- PairSee::LogLine
- Defined in:
- lib/pair_see/log_line.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #authored_by?(*people) ⇒ Boolean
- #card_name(card_prefix) ⇒ Object
- #card_number(card_prefix) ⇒ Object
- #contains_card?(card_prefix) ⇒ Boolean
- #contains_card_name?(card_name) ⇒ Boolean
- #date ⇒ Object
-
#initialize(line) ⇒ LogLine
constructor
A new instance of LogLine.
- #merge_commit? ⇒ Boolean
- #not_by_pair?(devs) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(line) ⇒ LogLine
Returns a new instance of LogLine.
6 7 8 |
# File 'lib/pair_see/log_line.rb', line 6 def initialize(line) @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
4 5 6 |
# File 'lib/pair_see/log_line.rb', line 4 def line @line end |
Instance Method Details
#authored_by?(*people) ⇒ Boolean
10 11 12 13 14 |
# File 'lib/pair_see/log_line.rb', line 10 def (*people) people.empty? ? false : people.all? do |person| /(^|\s+|\W)#{person}(\s+|$|\W)/i =~ line end end |
#card_name(card_prefix) ⇒ Object
26 27 28 29 30 |
# File 'lib/pair_see/log_line.rb', line 26 def card_name(card_prefix) regex = /(#{card_prefix}\d+)/ matcher = line.match(regex) matcher.nil? ? nil : (line.match regex)[1] end |
#card_number(card_prefix) ⇒ Object
32 33 34 35 |
# File 'lib/pair_see/log_line.rb', line 32 def card_number(card_prefix) card_num = card_name(card_prefix) card_num ? card_num.gsub(card_prefix, '') : nil end |
#contains_card?(card_prefix) ⇒ Boolean
16 17 18 |
# File 'lib/pair_see/log_line.rb', line 16 def contains_card?(card_prefix) line.match(card_prefix) end |
#contains_card_name?(card_name) ⇒ Boolean
20 21 22 23 24 |
# File 'lib/pair_see/log_line.rb', line 20 def contains_card_name?(card_name) git_regex = /#{card_name}[\]\s\[,:]/ git_matcher = line.match(git_regex) !git_matcher.nil? end |
#date ⇒ Object
41 42 43 44 45 46 |
# File 'lib/pair_see/log_line.rb', line 41 def date regex = /(\d{4}-\d{2}-\d{2})/ matcher = line.match(regex) part_to_parse = matcher.nil? ? '' : (line.match regex)[1] Date.parse(part_to_parse) end |
#merge_commit? ⇒ Boolean
37 38 39 |
# File 'lib/pair_see/log_line.rb', line 37 def merge_commit? line.match('Merge remote-tracking branch') || line.match('Merge branch') end |
#not_by_pair?(devs) ⇒ Boolean
48 49 50 |
# File 'lib/pair_see/log_line.rb', line 48 def not_by_pair?(devs) devs.any? { |dev| (dev) || merge_commit? } end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/pair_see/log_line.rb', line 52 def to_s line end |