Class: ArchUnit::Metrics::Extraction::FileInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/archunit/metrics/extraction/metric_info.rb

Overview

Static counts and class declarations extracted from one Ruby source file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, lines_of_code:, statement_count:, import_count:, class_count:, function_count:, class_infos: [], type_count: nil, abstract_type_count: 0) ⇒ FileInfo

rubocop:disable-next Metrics/MethodLength, Metrics/ParameterLists – Independent count facts.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 105

def initialize(
  path:,
  lines_of_code:,
  statement_count:,
  import_count:,
  class_count:,
  function_count:,
  class_infos: [],
  type_count: nil,
  abstract_type_count: 0
)
  path = immutable_string(path, :path, normalize_path: true)
  lines_of_code = non_negative_integer(lines_of_code, :lines_of_code)
  statement_count = non_negative_integer(statement_count, :statement_count)
  import_count = non_negative_integer(import_count, :import_count)
  class_count = non_negative_integer(class_count, :class_count)
  function_count = non_negative_integer(function_count, :function_count)
  class_infos = immutable_values(class_infos, ClassInfo, :class_infos)
  type_count = non_negative_integer(type_count || class_count, :type_count)
  abstract_type_count = non_negative_integer(
    abstract_type_count, :abstract_type_count
  )
  if abstract_type_count > type_count
    raise ArgumentError, 'abstract_type_count cannot exceed type_count'
  end

  super
end

Instance Attribute Details

#abstract_type_count ⇒ Object (readonly)

Returns the value of attribute abstract_type_count

Returns:

  • (Object) —

    the current value of abstract_type_count



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def abstract_type_count
  @abstract_type_count
end

#class_count ⇒ Object (readonly)

Returns the value of attribute class_count

Returns:

  • (Object) —

    the current value of class_count



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def class_count
  @class_count
end

#class_infos ⇒ Object (readonly)

Returns the value of attribute class_infos

Returns:

  • (Object) —

    the current value of class_infos



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def class_infos
  @class_infos
end

#function_count ⇒ Object (readonly)

Returns the value of attribute function_count

Returns:

  • (Object) —

    the current value of function_count



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def function_count
  @function_count
end

#import_count ⇒ Object (readonly)

Returns the value of attribute import_count

Returns:

  • (Object) —

    the current value of import_count



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def import_count
  @import_count
end

#lines_of_code ⇒ Object (readonly)

Returns the value of attribute lines_of_code

Returns:

  • (Object) —

    the current value of lines_of_code



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def lines_of_code
  @lines_of_code
end

#path ⇒ Object (readonly)

Returns the value of attribute path

Returns:

  • (Object) —

    the current value of path



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def path
  @path
end

#statement_count ⇒ Object (readonly)

Returns the value of attribute statement_count

Returns:

  • (Object) —

    the current value of statement_count



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def statement_count
  @statement_count
end

#type_count ⇒ Object (readonly)

Returns the value of attribute type_count

Returns:

  • (Object) —

    the current value of type_count



91
92
93
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 91

def type_count
  @type_count
end

Instance Method Details

#identifier ⇒ Object



134
135
136
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 134

def identifier
  path
end