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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddb9c534659e0d305415603e274260d767bc4970a35522a810953265096d3749
4
- data.tar.gz: 81fcaba8b3541777f3211b4e9972004b08718e97821debdb534fad71f06a1796
3
+ metadata.gz: a6fa463a9244bec2d1144ebcdc903e19681ea7e60cc0b3ea3438e21b8388ec9e
4
+ data.tar.gz: 3ac6566d7b754979331b290e9c3610778eaa69ce6c31ae0eb8d8b16dd69deaa5
5
5
  SHA512:
6
- metadata.gz: 80aae860b1a396277acbd1c6157f3d463f8345e803c8a70d1e89a3a0915ab609bda1eb6825fc73e107681105ada1a226b77f85e2e782af5940c6ba634a4e1582
7
- data.tar.gz: 46f3e5b59f8d98e1c7574093e3ecb2e5dbc0160bc3565b04cbd086beaf2a43ea74005c530de5a70bd3f0108965d3ada5e902328a58fcb75c5d6a12d067d57c66
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(Pathname.new('.')).to_s
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(Pathname.new('.')).to_s
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
- File.exist?("spec/#{name}_spec.rb") ||
410
- File.exist?("spec/#{name}s_spec.rb") ||
411
- File.exist?("spec/tina4/#{name}_spec.rb") ||
412
- File.exist?("test/#{name}_test.rb") ||
413
- File.exist?("spec/#{name}_test.rb") ||
414
- File.exist?("test/test_#{name}.rb") ||
415
- File.exist?("test/#{name}_spec.rb")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.10.60"
4
+ VERSION = "3.10.65"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.60
4
+ version: 3.10.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team