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 Metrics/MethodLength, Metrics/ParameterLists -- Independent count facts.



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
133
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 106

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_countObject (readonly)

Returns the value of attribute abstract_type_count

Returns:

  • (Object)

    the current value of abstract_type_count



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

def abstract_type_count
  @abstract_type_count
end

#class_countObject (readonly)

Returns the value of attribute class_count

Returns:

  • (Object)

    the current value of class_count



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

def class_count
  @class_count
end

#class_infosObject (readonly)

Returns the value of attribute class_infos

Returns:

  • (Object)

    the current value of class_infos



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

def class_infos
  @class_infos
end

#function_countObject (readonly)

Returns the value of attribute function_count

Returns:

  • (Object)

    the current value of function_count



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

def function_count
  @function_count
end

#import_countObject (readonly)

Returns the value of attribute import_count

Returns:

  • (Object)

    the current value of import_count



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

def import_count
  @import_count
end

#lines_of_codeObject (readonly)

Returns the value of attribute lines_of_code

Returns:

  • (Object)

    the current value of lines_of_code



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

def lines_of_code
  @lines_of_code
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



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

def path
  @path
end

#statement_countObject (readonly)

Returns the value of attribute statement_count

Returns:

  • (Object)

    the current value of statement_count



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

def statement_count
  @statement_count
end

#type_countObject (readonly)

Returns the value of attribute type_count

Returns:

  • (Object)

    the current value of type_count



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

def type_count
  @type_count
end

Instance Method Details

#identifierObject

rubocop:enable Metrics/MethodLength, Metrics/ParameterLists



136
137
138
# File 'lib/archunit/metrics/extraction/metric_info.rb', line 136

def identifier
  path
end