Class: Outliers::Evaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/outliers/evaluation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Evaluation

Returns a new instance of Evaluation.



6
7
8
9
# File 'lib/outliers/evaluation.rb', line 6

def initialize(args)
  @run  = args[:run]
  @name = args[:name]
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



4
5
6
# File 'lib/outliers/evaluation.rb', line 4

def collection
  @collection
end

#provider_nameObject (readonly)

Returns the value of attribute provider_name.



4
5
6
# File 'lib/outliers/evaluation.rb', line 4

def provider_name
  @provider_name
end

#provider_name_arrayObject (readonly)

Returns the value of attribute provider_name_array.



4
5
6
# File 'lib/outliers/evaluation.rb', line 4

def provider_name_array
  @provider_name_array
end

Instance Method Details

#connect(name, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/outliers/evaluation.rb', line 11

def connect(name, options={})
  @provider_name = merged_credentials(name, options).fetch 'provider'

  logger.info "Connecting via '#{name}' to '#{@provider_name}'."
  logger.info "Including connection options '#{options.map {|k,v| "#{k}=#{v}"}.join(',')}'." if options.any?

  set_provider_name_array

  @provider = Outliers::Provider.connect_to merged_credentials(name, options)
end

#exclude(exclusions) ⇒ Object



35
36
37
# File 'lib/outliers/evaluation.rb', line 35

def exclude(exclusions)
  collection.exclude_by_key Array(exclusions)
end

#filter(args) ⇒ Object



39
40
41
# File 'lib/outliers/evaluation.rb', line 39

def filter(args)
  collection.filter args.keys_to_s
end

#resources(name, targets = []) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/outliers/evaluation.rb', line 22

def resources(name, targets=[])
  logger.info "Loading '#{name}' resource collection."
  @collection = collection_object name

  targets_array = Array(targets)

  if targets_array.any?
    logger.info "Verifying '#{targets_array.join(', ')}' from '#{name}' collection."
    collection.targets = targets_array
  end
  collection
end

#verify(verification, arguments = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/outliers/evaluation.rb', line 43

def verify(verification, arguments={})
  @resources_loaded ||= collection.load_all

  verification_result = collection.verify verification, arguments.keys_to_sym

  result = Outliers::Result.new evaluation:        @name,
                                failing_resources: verification_result.fetch(:failing_resources),
                                passing_resources: verification_result.fetch(:passing_resources),
                                resource:          @collection,
                                verification:      verification

  logger.info "Verification '#{verification}' #{result}."

  @run.results << result
end