Class: PactBroker::Domain::Pact

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/domain/pact.rb

Direct Known Subclasses

Pacts::PlaceholderPact

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Pact

Returns a new instance of Pact.



29
30
31
32
33
34
# File 'lib/pact_broker/domain/pact.rb', line 29

def initialize attributes = {}
  @latest_verification = UnsetAttribute.new
  attributes.each_pair do | key, value |
    self.send(key.to_s + "=", value)
  end
end

Instance Attribute Details

#consumerObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def consumer
  @consumer
end

#consumer_versionObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def consumer_version
  @consumer_version
end

#consumer_version_numberObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def consumer_version_number
  @consumer_version_number
end

#created_atObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def created_at
  @created_at
end

#head_tag_namesObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def head_tag_names
  @head_tag_names
end

#idObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def id
  @id
end

#json_contentObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def json_content
  @json_content
end

#latest_verificationObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def latest_verification
  @latest_verification
end

#pact_version_shaObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def pact_version_sha
  @pact_version_sha
end

#providerObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def provider
  @provider
end

#revision_numberObject

The ID is the pact_publication ID



17
18
19
# File 'lib/pact_broker/domain/pact.rb', line 17

def revision_number
  @revision_number
end

Instance Method Details

#consumer_nameObject



36
37
38
# File 'lib/pact_broker/domain/pact.rb', line 36

def consumer_name
  consumer.name
end

#consumer_version_tag_namesObject



48
49
50
# File 'lib/pact_broker/domain/pact.rb', line 48

def consumer_version_tag_names
  consumer_version.tags.collect(&:name)
end

#content_hashObject



76
77
78
# File 'lib/pact_broker/domain/pact.rb', line 76

def content_hash
  JSON.parse(json_content, PACT_PARSING_OPTIONS)
end

#content_objectObject



80
81
82
83
84
85
86
# File 'lib/pact_broker/domain/pact.rb', line 80

def content_object
  @content_object ||= begin
    PactBroker::Pacts::Content.from_json(json_content)
  rescue
    PactBroker::Pacts::Content.new
  end
end

#latest_consumer_version_tag_names=(latest_consumer_version_tag_names) ⇒ Object



52
53
54
# File 'lib/pact_broker/domain/pact.rb', line 52

def latest_consumer_version_tag_names= latest_consumer_version_tag_names
  @latest_consumer_version_tag_names = latest_consumer_version_tag_names
end

#nameObject



68
69
70
# File 'lib/pact_broker/domain/pact.rb', line 68

def name
  "Pact between #{consumer.name} (#{consumer_version_number}) and #{provider.name}"
end

#pact_publication_idObject



88
89
90
# File 'lib/pact_broker/domain/pact.rb', line 88

def pact_publication_id
  id
end

#pending?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/pact_broker/domain/pact.rb', line 96

def pending?
  !pact_version.verified_successfully_by_any_provider_version?
end

#provider_nameObject



40
41
42
# File 'lib/pact_broker/domain/pact.rb', line 40

def provider_name
  provider.name
end

#select_pending_provider_version_tags(provider_version_tags) ⇒ Object



92
93
94
# File 'lib/pact_broker/domain/pact.rb', line 92

def select_pending_provider_version_tags(provider_version_tags)
  provider_version_tags - db_model.pact_version.select_provider_tags_with_successful_verifications(provider_version_tags)
end

#to_json(options = {}) ⇒ Object



64
65
66
# File 'lib/pact_broker/domain/pact.rb', line 64

def to_json options = {}
  json_content
end

#to_sObject



60
61
62
# File 'lib/pact_broker/domain/pact.rb', line 60

def to_s
  "Pact: consumer=#{consumer.name} provider=#{provider.name}"
end

#version_and_updated_dateObject



72
73
74
# File 'lib/pact_broker/domain/pact.rb', line 72

def version_and_updated_date
  "Version #{consumer_version_number} - #{created_at.to_time.localtime.strftime("%d/%m/%Y")}"
end