Class: PactBroker::Domain::Pact
- Inherits:
-
Object
- Object
- PactBroker::Domain::Pact
- Defined in:
- lib/pact_broker/domain/pact.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #consumer ⇒ Object
-
#consumer_version ⇒ Object
The ID is the pact_publication ID.
- #consumer_version_branch_names ⇒ Object
-
#consumer_version_number ⇒ Object
The ID is the pact_publication ID.
- #consumer_version_tag_names ⇒ Object
-
#created_at ⇒ Object
The ID is the pact_publication ID.
-
#head_tag_names ⇒ Object
The ID is the pact_publication ID.
-
#id ⇒ Object
The ID is the pact_publication ID.
-
#json_content ⇒ Object
The ID is the pact_publication ID.
- #latest_verification ⇒ Object
-
#pact_version_sha ⇒ Object
The ID is the pact_publication ID.
-
#provider ⇒ Object
The ID is the pact_publication ID.
-
#revision_number ⇒ Object
The ID is the pact_publication ID.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #consumer_name ⇒ Object
- #content_hash ⇒ Object
- #content_object ⇒ Object
-
#initialize(attributes = {}) ⇒ Pact
constructor
A new instance of Pact.
- #name ⇒ Object
- #pact_publication_id ⇒ Object
- #pending_for_any_provider_branch? ⇒ Boolean
-
#pending_for_provider_branch?(branch_name) ⇒ Boolean
Boolean whether or not the pact is in pending state (ie. the build should not fail if the verification fails).
- #provider_name ⇒ Object
- #select_pending_provider_version_tags(provider_version_tags) ⇒ Object
- #to_json(_options = {}) ⇒ Object
- #to_s ⇒ Object
- #version_and_updated_date ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Pact
Returns a new instance of Pact.
31 32 33 34 35 36 37 38 |
# File 'lib/pact_broker/domain/pact.rb', line 31 def initialize attributes = {} @latest_verification = UnsetAttribute.new @consumer_version_tag_names = UnsetAttribute.new @consumer_version_branch_names = UnsetAttribute.new attributes.each_pair do | key, value | self.send(key.to_s + "=", value) end end |
Instance Attribute Details
#consumer ⇒ Object
48 49 50 |
# File 'lib/pact_broker/domain/pact.rb', line 48 def consumer @consumer || consumer_version.pacticipant end |
#consumer_version ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def consumer_version @consumer_version end |
#consumer_version_branch_names ⇒ Object
56 57 58 |
# File 'lib/pact_broker/domain/pact.rb', line 56 def consumer_version_branch_names get_attribute_if_set :consumer_version_branch_names end |
#consumer_version_number ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def consumer_version_number @consumer_version_number end |
#consumer_version_tag_names ⇒ Object
52 53 54 |
# File 'lib/pact_broker/domain/pact.rb', line 52 def consumer_version_tag_names get_attribute_if_set :consumer_version_tag_names end |
#created_at ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def created_at @created_at end |
#head_tag_names ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def head_tag_names @head_tag_names end |
#id ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def id @id end |
#json_content ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def json_content @json_content end |
#latest_verification ⇒ Object
60 61 62 |
# File 'lib/pact_broker/domain/pact.rb', line 60 def latest_verification get_attribute_if_set :latest_verification end |
#pact_version_sha ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def pact_version_sha @pact_version_sha end |
#provider ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def provider @provider end |
#revision_number ⇒ Object
The ID is the pact_publication ID
16 17 18 |
# File 'lib/pact_broker/domain/pact.rb', line 16 def revision_number @revision_number end |
Instance Method Details
#<=>(other) ⇒ Object
112 113 114 115 116 |
# File 'lib/pact_broker/domain/pact.rb', line 112 def <=> other self_fields = [consumer_name.downcase, provider_name.downcase, consumer_version.order || 0] other_fields = [other.consumer_name.downcase, other.provider_name.downcase, other.consumer_version.order || 0] self_fields <=> other_fields end |
#consumer_name ⇒ Object
40 41 42 |
# File 'lib/pact_broker/domain/pact.rb', line 40 def consumer_name consumer.name end |
#content_hash ⇒ Object
80 81 82 |
# File 'lib/pact_broker/domain/pact.rb', line 80 def content_hash JSON.parse(json_content, PACT_PARSING_OPTIONS) end |
#content_object ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/pact_broker/domain/pact.rb', line 84 def content_object @content_object ||= begin PactBroker::Pacts::Content.from_json(json_content) rescue PactBroker::Pacts::Content.new end end |
#name ⇒ Object
72 73 74 |
# File 'lib/pact_broker/domain/pact.rb', line 72 def name "Pact between #{consumer.name} (#{consumer_version_number}) and #{provider.name}" end |
#pact_publication_id ⇒ Object
92 93 94 |
# File 'lib/pact_broker/domain/pact.rb', line 92 def pact_publication_id id end |
#pending_for_any_provider_branch? ⇒ Boolean
108 109 110 |
# File 'lib/pact_broker/domain/pact.rb', line 108 def pending_for_any_provider_branch? !pact_version.verified_successfully_by_any_provider_version? end |
#pending_for_provider_branch?(branch_name) ⇒ Boolean
Returns Boolean whether or not the pact is in pending state (ie. the build should not fail if the verification fails).
104 105 106 |
# File 'lib/pact_broker/domain/pact.rb', line 104 def pending_for_provider_branch?(branch_name) pact_version.pending_for_provider_branch?(branch_name) end |
#provider_name ⇒ Object
44 45 46 |
# File 'lib/pact_broker/domain/pact.rb', line 44 def provider_name provider.name end |
#select_pending_provider_version_tags(provider_version_tags) ⇒ Object
96 97 98 99 100 |
# File 'lib/pact_broker/domain/pact.rb', line 96 def () = db_model.pact_version.() = db_model.pact_version.() - - end |
#to_json(_options = {}) ⇒ Object
68 69 70 |
# File 'lib/pact_broker/domain/pact.rb', line 68 def to_json = {} json_content end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/pact_broker/domain/pact.rb', line 64 def to_s "Pact: consumer=#{consumer.name} provider=#{provider.name}" end |
#version_and_updated_date ⇒ Object
76 77 78 |
# File 'lib/pact_broker/domain/pact.rb', line 76 def version_and_updated_date "Version #{consumer_version_number} - #{created_at.to_time.localtime.strftime("%d/%m/%Y")}" end |