Class: SvgConform::ProfileCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/svg_conform/profile_compiler.rb

Overview

Compiles and prepares SVG validation profiles Centralizes profile loading logic for better separation of concerns

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.compile_cacheObject (readonly)

Returns the value of attribute compile_cache.



13
14
15
# File 'lib/svg_conform/profile_compiler.rb', line 13

def compile_cache
  @compile_cache
end

.compile_mutexObject (readonly)

Returns the value of attribute compile_mutex.



13
14
15
# File 'lib/svg_conform/profile_compiler.rb', line 13

def compile_mutex
  @compile_mutex
end

Class Method Details

.clear_cache!Object

Clear compilation cache



50
51
52
53
54
# File 'lib/svg_conform/profile_compiler.rb', line 50

def clear_cache!
  compile_mutex.synchronize do
    compile_cache.clear
  end
end

.compile(profile_id) ⇒ Object

Compile a profile by name Returns a cached profile if already compiled



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/svg_conform/profile_compiler.rb', line 17

def compile(profile_id)
  profile_key = profile_id.to_s

  # Check cache (thread-safe)
  compile_mutex.synchronize do
    return compile_cache[profile_key] if compile_cache[profile_key]
  end

  # Load and compile profile
  profile = load_profile(profile_key)
  compiled_profile = prepare_profile(profile)

  # Cache result (thread-safe)
  compile_mutex.synchronize do
    compile_cache[profile_key] = compiled_profile
  end

  compiled_profile
end

.compile_from_file(file_path) ⇒ Object

Compile from file path



44
45
46
47
# File 'lib/svg_conform/profile_compiler.rb', line 44

def compile_from_file(file_path)
  profile = Profile.load_from_file(file_path)
  prepare_profile(profile)
end

.compile_from_yaml(yaml_content) ⇒ Object

Compile from YAML content



38
39
40
41
# File 'lib/svg_conform/profile_compiler.rb', line 38

def compile_from_yaml(yaml_content)
  profile = Profile.from_yaml(yaml_content)
  prepare_profile(profile)
end