Class: PactBroker::Client::Matrix::Resource

Inherits:
Hash
  • Object
show all
Defined in:
lib/pact_broker/client/matrix/resource.rb

Instance Method Summary collapse

Methods inherited from Hash

#compact, #compact!, #except

Constructor Details

#initialize(hash) ⇒ Resource

Returns a new instance of Resource.



21
22
23
# File 'lib/pact_broker/client/matrix/resource.rb', line 21

def initialize hash
  self.merge!(hash)
end

Instance Method Details

#any_unknown?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/pact_broker/client/matrix/resource.rb', line 25

def any_unknown?
  if supports_unknown_count?
    unknown_count > 0
  else
    false
  end
end

#deployable?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/pact_broker/client/matrix/resource.rb', line 53

def deployable?
  self[:summary][:deployable]
end

#no_results?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/pact_broker/client/matrix/resource.rb', line 33

def no_results?
  self[:summary][:success] == 0 && self[:summary][:failed] == 0
end

#noticesObject



57
58
59
60
61
62
63
# File 'lib/pact_broker/client/matrix/resource.rb', line 57

def notices
  if self[:notices].is_a?(Array)
    self[:notices].collect { | notice_hash | Notice.new(notice_hash) }
  else
    nil
  end
end

#reasonObject



49
50
51
# File 'lib/pact_broker/client/matrix/resource.rb', line 49

def reason
  self[:summary][:reason]
end

#supports_ignore?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/pact_broker/client/matrix/resource.rb', line 41

def supports_ignore?
  !!(self[:summary] && Integer === self[:summary][:ignored] )
end

#supports_unknown_count?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/pact_broker/client/matrix/resource.rb', line 37

def supports_unknown_count?
  !!(self[:summary] && Integer === self[:summary][:unknown] )
end

#unknown_countObject



45
46
47
# File 'lib/pact_broker/client/matrix/resource.rb', line 45

def unknown_count
  supports_unknown_count? ? self[:summary][:unknown] : nil
end