tina4ruby 3.10.60 → 3.10.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tina4/metrics.rb +56 -9
- data/lib/tina4/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6fa463a9244bec2d1144ebcdc903e19681ea7e60cc0b3ea3438e21b8388ec9e
|
|
4
|
+
data.tar.gz: 3ac6566d7b754979331b290e9c3610778eaa69ce6c31ae0eb8d8b16dd69deaa5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c40fcd4bc17ee1e0d2e41a297750210fc1e66708080a20c180dfe2f6338ce435d8e30042c0799a9455384b5808f221c00f156d13bdbd9aac4ecbbd655d9204fa
|
|
7
|
+
data.tar.gz: 180229e03f54704f3d3455d6b1c6690aea1979fbcbbfe2b05150c1831b25630628cbeb3b52cb7810f72939d9360e40d4a0ff8c42196df46591114aa923ea1e74
|
data/lib/tina4/metrics.rb
CHANGED
|
@@ -137,7 +137,7 @@ module Tina4
|
|
|
137
137
|
total_functions += functions
|
|
138
138
|
|
|
139
139
|
rel_path = begin
|
|
140
|
-
Pathname.new(f).relative_path_from(
|
|
140
|
+
Pathname.new(f).relative_path_from(root_path).to_s
|
|
141
141
|
rescue ArgumentError
|
|
142
142
|
f
|
|
143
143
|
end
|
|
@@ -238,7 +238,7 @@ module Tina4
|
|
|
238
238
|
end
|
|
239
239
|
|
|
240
240
|
rel_path = begin
|
|
241
|
-
Pathname.new(f).relative_path_from(
|
|
241
|
+
Pathname.new(f).relative_path_from(root_path).to_s
|
|
242
242
|
rescue ArgumentError
|
|
243
243
|
f
|
|
244
244
|
end
|
|
@@ -405,14 +405,61 @@ module Tina4
|
|
|
405
405
|
private_class_method
|
|
406
406
|
|
|
407
407
|
def self._has_matching_test(rel_path)
|
|
408
|
+
require 'set'
|
|
409
|
+
|
|
408
410
|
name = File.basename(rel_path, '.rb')
|
|
409
|
-
|
|
410
|
-
File.
|
|
411
|
-
File.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
411
|
+
# Parent directory name (e.g. "database" from "database/sqlite3_adapter.rb")
|
|
412
|
+
parent_dir = File.dirname(rel_path)
|
|
413
|
+
parent_module = (parent_dir != '.' && !parent_dir.empty?) ? File.basename(parent_dir) : ''
|
|
414
|
+
|
|
415
|
+
# Stage 1: Filename matching — name_spec, name_test, test_name patterns
|
|
416
|
+
test_dirs = ['spec', 'spec/tina4', 'test', 'tests']
|
|
417
|
+
test_dirs.each do |td|
|
|
418
|
+
patterns = [
|
|
419
|
+
"#{td}/#{name}_spec.rb",
|
|
420
|
+
"#{td}/#{name}s_spec.rb",
|
|
421
|
+
"#{td}/#{name}_test.rb",
|
|
422
|
+
"#{td}/test_#{name}.rb",
|
|
423
|
+
]
|
|
424
|
+
# Also check parent-named tests (spec/database_spec.rb covers database/sqlite3_adapter.rb)
|
|
425
|
+
if parent_module && !parent_module.empty? && parent_module != name
|
|
426
|
+
patterns << "#{td}/#{parent_module}_spec.rb"
|
|
427
|
+
patterns << "#{td}/#{parent_module}s_spec.rb"
|
|
428
|
+
patterns << "#{td}/#{parent_module}_test.rb"
|
|
429
|
+
patterns << "#{td}/test_#{parent_module}.rb"
|
|
430
|
+
end
|
|
431
|
+
return true if patterns.any? { |p| File.exist?(p) }
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
# Build a dotted/slashed require path for import matching
|
|
435
|
+
# e.g. "lib/tina4/database/sqlite3_adapter.rb" → "tina4/database/sqlite3_adapter"
|
|
436
|
+
path_without_ext = rel_path.sub(/\.rb$/, '')
|
|
437
|
+
# Strip leading lib/ prefix if present
|
|
438
|
+
require_path = path_without_ext.sub(%r{^lib/}, '')
|
|
439
|
+
|
|
440
|
+
# Build CamelCase class name from snake_case module name
|
|
441
|
+
# e.g. "sqlite3_adapter" → "Sqlite3Adapter"
|
|
442
|
+
class_name = name.split('_').map(&:capitalize).join
|
|
443
|
+
|
|
444
|
+
# Stage 2+3: Content scan — check if any spec/test file references this module
|
|
445
|
+
scan_dirs = ['spec', 'test', 'tests']
|
|
446
|
+
scan_dirs.each do |td|
|
|
447
|
+
next unless Dir.exist?(td)
|
|
448
|
+
Dir.glob(File.join(td, '**', '*.rb')).each do |test_file|
|
|
449
|
+
content = begin
|
|
450
|
+
File.read(test_file, encoding: 'utf-8')
|
|
451
|
+
rescue StandardError
|
|
452
|
+
next
|
|
453
|
+
end
|
|
454
|
+
# Stage 2: require/require_relative path matching
|
|
455
|
+
return true if !require_path.empty? && content.include?(require_path)
|
|
456
|
+
# Stage 3: class name or module name mention
|
|
457
|
+
return true if content.match?(/\b#{Regexp.escape(class_name)}\b/)
|
|
458
|
+
return true if content.match?(/\b#{Regexp.escape(name)}\b/i)
|
|
459
|
+
end
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
false
|
|
416
463
|
end
|
|
417
464
|
|
|
418
465
|
def self._files_hash(root)
|
data/lib/tina4/version.rb
CHANGED