tina4ruby 3.10.60 → 3.10.66

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: 13acdd49bf29d256910ee8f803a6cd0983d9b38a903d3bc3e3efbba4bc07b565
4
+ data.tar.gz: 2e344b8b471db71b218d29e69d18d0aa0f3b3d8493e60840f5d409c9c2807c31
5
5
  SHA512:
6
- metadata.gz: 80aae860b1a396277acbd1c6157f3d463f8345e803c8a70d1e89a3a0915ab609bda1eb6825fc73e107681105ada1a226b77f85e2e782af5940c6ba634a4e1582
7
- data.tar.gz: 46f3e5b59f8d98e1c7574093e3ecb2e5dbc0160bc3565b04cbd086beaf2a43ea74005c530de5a70bd3f0108965d3ada5e902328a58fcb75c5d6a12d067d57c66
6
+ metadata.gz: b314ccc66d3cc707e5efcaf27a162da73d2f84255faf1cde06369b11144591c58223f007808415f9697d3d158d496786baeda362a20ceafb7eddd4d5e4ec450c
7
+ data.tar.gz: 1117b18973c2f6c44b28caa2d18f6064b3ce63fa4f0e6d4a6a88250c448bd2133a026b05a4f85978a7cf38473043d9d41e440c7a6b92af8693ef78af3ece5a27
data/lib/tina4/metrics.rb CHANGED
@@ -21,6 +21,9 @@ module Tina4
21
21
  @full_cache_time = 0
22
22
  CACHE_TTL = 60
23
23
 
24
+ # Stores the resolved scan root so file_detail can locate framework files.
25
+ @last_scan_root = ""
26
+
24
27
  # ── Root Resolution ──────────────────────────────────────────
25
28
 
26
29
  # Pick the right directory to scan.
@@ -30,10 +33,17 @@ module Tina4
30
33
  def self._resolve_root(root = 'src')
31
34
  root_path = Pathname.new(root)
32
35
  if root_path.directory? && !Dir.glob(root_path.join('**', '*.rb')).empty?
36
+ @last_scan_root = File.expand_path(root)
33
37
  return root
34
38
  end
35
39
  # Fallback: scan the framework package itself
36
- File.dirname(__FILE__)
40
+ fw_dir = File.dirname(__FILE__)
41
+ @last_scan_root = fw_dir
42
+ fw_dir
43
+ end
44
+
45
+ def self.last_scan_root
46
+ @last_scan_root
37
47
  end
38
48
 
39
49
  # ── Quick Metrics ───────────────────────────────────────────
@@ -137,7 +147,7 @@ module Tina4
137
147
  total_functions += functions
138
148
 
139
149
  rel_path = begin
140
- Pathname.new(f).relative_path_from(Pathname.new('.')).to_s
150
+ Pathname.new(f).relative_path_from(root_path).to_s
141
151
  rescue ArgumentError
142
152
  f
143
153
  end
@@ -238,7 +248,7 @@ module Tina4
238
248
  end
239
249
 
240
250
  rel_path = begin
241
- Pathname.new(f).relative_path_from(Pathname.new('.')).to_s
251
+ Pathname.new(f).relative_path_from(root_path).to_s
242
252
  rescue ArgumentError
243
253
  f
244
254
  end
@@ -346,6 +356,15 @@ module Tina4
346
356
  # ── File Detail ─────────────────────────────────────────────
347
357
 
348
358
  def self.file_detail(file_path)
359
+ unless File.exist?(file_path)
360
+ # Try resolving relative to the last scan root (framework mode)
361
+ if @last_scan_root && !@last_scan_root.empty?
362
+ candidate = File.join(@last_scan_root, file_path)
363
+ if File.exist?(candidate)
364
+ file_path = candidate
365
+ end
366
+ end
367
+ end
349
368
  unless File.exist?(file_path)
350
369
  return { "error" => "File not found: #{file_path}" }
351
370
  end
@@ -405,14 +424,61 @@ module Tina4
405
424
  private_class_method
406
425
 
407
426
  def self._has_matching_test(rel_path)
427
+ require 'set'
428
+
408
429
  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")
430
+ # Parent directory name (e.g. "database" from "database/sqlite3_adapter.rb")
431
+ parent_dir = File.dirname(rel_path)
432
+ parent_module = (parent_dir != '.' && !parent_dir.empty?) ? File.basename(parent_dir) : ''
433
+
434
+ # Stage 1: Filename matching — name_spec, name_test, test_name patterns
435
+ test_dirs = ['spec', 'spec/tina4', 'test', 'tests']
436
+ test_dirs.each do |td|
437
+ patterns = [
438
+ "#{td}/#{name}_spec.rb",
439
+ "#{td}/#{name}s_spec.rb",
440
+ "#{td}/#{name}_test.rb",
441
+ "#{td}/test_#{name}.rb",
442
+ ]
443
+ # Also check parent-named tests (spec/database_spec.rb covers database/sqlite3_adapter.rb)
444
+ if parent_module && !parent_module.empty? && parent_module != name
445
+ patterns << "#{td}/#{parent_module}_spec.rb"
446
+ patterns << "#{td}/#{parent_module}s_spec.rb"
447
+ patterns << "#{td}/#{parent_module}_test.rb"
448
+ patterns << "#{td}/test_#{parent_module}.rb"
449
+ end
450
+ return true if patterns.any? { |p| File.exist?(p) }
451
+ end
452
+
453
+ # Build a dotted/slashed require path for import matching
454
+ # e.g. "lib/tina4/database/sqlite3_adapter.rb" → "tina4/database/sqlite3_adapter"
455
+ path_without_ext = rel_path.sub(/\.rb$/, '')
456
+ # Strip leading lib/ prefix if present
457
+ require_path = path_without_ext.sub(%r{^lib/}, '')
458
+
459
+ # Build CamelCase class name from snake_case module name
460
+ # e.g. "sqlite3_adapter" → "Sqlite3Adapter"
461
+ class_name = name.split('_').map(&:capitalize).join
462
+
463
+ # Stage 2+3: Content scan — check if any spec/test file references this module
464
+ scan_dirs = ['spec', 'test', 'tests']
465
+ scan_dirs.each do |td|
466
+ next unless Dir.exist?(td)
467
+ Dir.glob(File.join(td, '**', '*.rb')).each do |test_file|
468
+ content = begin
469
+ File.read(test_file, encoding: 'utf-8')
470
+ rescue StandardError
471
+ next
472
+ end
473
+ # Stage 2: require/require_relative path matching
474
+ return true if !require_path.empty? && content.include?(require_path)
475
+ # Stage 3: class name or module name mention
476
+ return true if content.match?(/\b#{Regexp.escape(class_name)}\b/)
477
+ return true if content.match?(/\b#{Regexp.escape(name)}\b/i)
478
+ end
479
+ end
480
+
481
+ false
416
482
  end
417
483
 
418
484
  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.66"
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.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team