Class: Ticket::Replicator::ReplicatedSummary
- Inherits:
-
Object
- Object
- Ticket::Replicator::ReplicatedSummary
- Defined in:
- lib/ticket/replicator/replicated_summary.rb
Defined Under Namespace
Classes: ParseError
Constant Summary collapse
- TICKET_ID_PREFIX =
"SMAN-"
- TICKET_ID_PREFIX_SEPARATOR =
" | "
- TICKET_ID_PREFIX_REGEX =
/^#{Regexp.escape(TICKET_ID_PREFIX)}(?<source_id>.+?)#{Regexp.escape(TICKET_ID_PREFIX_SEPARATOR)} (?<source_summary>.+)$/x
- MATCH_ANY_CHARACTER_IN_JQL =
"%"
Instance Attribute Summary collapse
-
#source_id ⇒ Object
readonly
Returns the value of attribute source_id.
-
#source_summary ⇒ Object
readonly
Returns the value of attribute source_summary.
Class Method Summary collapse
- .build(source_id, source_summary) ⇒ Object
- .jql_pattern ⇒ Object
- .match?(replicated_summary_string) ⇒ Boolean
- .parse(replicated_summary_string) ⇒ Object
Instance Method Summary collapse
-
#initialize(source_id, source_summary) ⇒ ReplicatedSummary
constructor
A new instance of ReplicatedSummary.
- #to_s ⇒ Object
Constructor Details
#initialize(source_id, source_summary) ⇒ ReplicatedSummary
Returns a new instance of ReplicatedSummary.
50 51 52 53 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 50 def initialize(source_id, source_summary) @source_id = source_id @source_summary = source_summary end |
Instance Attribute Details
#source_id ⇒ Object (readonly)
Returns the value of attribute source_id.
48 49 50 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 48 def source_id @source_id end |
#source_summary ⇒ Object (readonly)
Returns the value of attribute source_summary.
48 49 50 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 48 def source_summary @source_summary end |
Class Method Details
.build(source_id, source_summary) ⇒ Object
17 18 19 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 17 def self.build(source_id, source_summary) new(source_id, source_summary) end |
.jql_pattern ⇒ Object
39 40 41 42 43 44 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 39 def self.jql_pattern [ TICKET_ID_PREFIX, TICKET_ID_PREFIX_SEPARATOR ].join(MATCH_ANY_CHARACTER_IN_JQL) end |
.match?(replicated_summary_string) ⇒ Boolean
21 22 23 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 21 def self.match?(replicated_summary_string) TICKET_ID_PREFIX_REGEX.match(replicated_summary_string) end |
.parse(replicated_summary_string) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 25 def self.parse(replicated_summary_string) match_result = match?(replicated_summary_string) unless match_result raise ParseError, "#{replicated_summary_string.inspect}: missing expected prefix format: " \ "not matching #{TICKET_ID_PREFIX_REGEX.inspect}." end new(match_result[:source_id], match_result[:source_summary]) end |
Instance Method Details
#to_s ⇒ Object
55 56 57 58 59 60 |
# File 'lib/ticket/replicator/replicated_summary.rb', line 55 def to_s [ transformed_summary_prefix, source_summary ].join end |