Class: KalibroClient::Entities::Processor::ModuleResult

Inherits:
Base
  • Object
show all
Defined in:
lib/kalibro_client/entities/processor/module_result.rb

Instance Attribute Summary collapse

Attributes included from DateAttributes

#created_at, #updated_at

Attributes inherited from Base

#kalibro_errors, #persisted

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

address

Methods inherited from Base

#==, create, create_array_from_hash, create_objects_array_from_hash, #destroy, exists?, #initialize, request, #save, #save!, #to_hash, to_object, to_objects_array, #update

Methods included from RequestMethods::ClassMethods

#exists_action, #find_action, #id_params

Methods included from HashConverters

#convert_to_hash, #date_with_milliseconds, #field_to_hash

Methods included from XMLConverters

#get_xml, #xml_instance_class_name

Methods included from RequestMethods

#destroy_action, #destroy_params, #destroy_prefix, #save_action, #save_params, #save_prefix, #update_params, #update_prefix

Constructor Details

This class inherits a constructor from KalibroClient::Entities::Base

Instance Attribute Details

#gradeObject

Returns the value of attribute grade.



22
23
24
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 22

def grade
  @grade
end

#heightObject

Returns the value of attribute height.



22
23
24
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 22

def height
  @height
end

#idObject

Returns the value of attribute id.



22
23
24
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 22

def id
  @id
end

#kalibro_moduleObject

Returns the value of attribute kalibro_module.



22
23
24
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 22

def kalibro_module
  @kalibro_module
end

#parent_idObject

Returns the value of attribute parent_id.



22
23
24
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 22

def parent_id
  @parent_id
end

#processing_idObject

Returns the value of attribute processing_id.



22
23
24
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 22

def processing_id
  @processing_id
end

Class Method Details

.find(id) ⇒ Object

FIXME: KalibroProcessor should return a 404 if the object does not exist instead of 422



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 94

def self.find(id)
  begin
    super
  rescue KalibroClient::Errors::RequestError => e
    if(e.response.status == 422)
      raise KalibroClient::Errors::RecordNotFound.new(response: e.response)
    else
      raise e
    end
  end
end

.history_of(module_result, repository_id) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 74

def self.history_of(module_result, repository_id)
  response = self.create_array_from_hash(Repository.request(':id/module_result_history_of', {id: repository_id, kalibro_module_id: module_result.kalibro_module.id})['date_module_results'])
  response.map do |date_module_result_pair|
    date_module_result = KalibroClient::Entities::Miscellaneous::DateModuleResult.new
    date_module_result.date = date_module_result_pair.first
    date_module_result.module_result = KalibroClient::Entities::Processor::ModuleResult.new date_module_result_pair.last
    date_module_result
  end
end

Instance Method Details

#childrenObject



24
25
26
27
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 24

def children
  response = self.class.request(':id/children', {id: id}, :get)
  self.class.create_objects_array_from_hash(response)
end

#file?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 70

def file?
  !self.folder?
end

#folder?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 66

def folder?
  self.children.count > 0
end

#hotspot_metric_resultsObject



88
89
90
91
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 88

def hotspot_metric_results
  HotspotMetricResult.create_objects_array_from_hash(self.class.request(":id/hotspot_metric_results",
                                                                        {id: self.id}, :get))
end

#parentsObject



29
30
31
32
33
34
35
36
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 29

def parents
  if parent_id == 0
    []
  else
    parent = self.class.find(parent_id)
    parent.parents << parent
  end
end

#processingObject



54
55
56
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 54

def processing
  KalibroClient::Entities::Processor::Processing.find(self.processing_id)
end

#tree_metric_resultsObject



84
85
86
# File 'lib/kalibro_client/entities/processor/module_result.rb', line 84

def tree_metric_results
  TreeMetricResult.create_objects_array_from_hash(self.class.request(":id/metric_results", {id: self.id}, :get))
end