classy-yaml 1.7.1 → 1.7.2
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/classy/yaml/version.rb +1 -1
- data/lib/classy/yaml.rb +18 -9
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97e19478fc64b51321f597e6449e4a6b72708391561401a1fcd8c09996f1ace2
|
|
4
|
+
data.tar.gz: 428fb76c90fea87eb601ab917fa86715e2ed0634669ab0ddf8e061da9087ac85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8aef2b74c04eacb3573d5958108559f729965abc7766be1441dd903d62b2375f98e6b917e0d055fc8b0e2246bff4c959242ee8eacfa29a5c8827fdc725a85393
|
|
7
|
+
data.tar.gz: e2a5ce4eccecd4ada862ba28e98bd731b9e37ad54d6fb8060b5a06471cd906d805c78ec473f426a5a98de49078c3df65cffbc780171a557d66151793b3d91743
|
data/lib/classy/yaml/version.rb
CHANGED
data/lib/classy/yaml.rb
CHANGED
|
@@ -52,10 +52,10 @@ module Classy
|
|
|
52
52
|
|
|
53
53
|
# -- Cached Data Accessors (Lazy Loading) --
|
|
54
54
|
def self.cached_engine_yamls
|
|
55
|
-
# Check file metadata
|
|
56
|
-
return load_engine_yamls if
|
|
55
|
+
# Check file metadata only while Rails reloads code
|
|
56
|
+
return load_engine_yamls if reloading?
|
|
57
57
|
|
|
58
|
-
#
|
|
58
|
+
# Classes are cached: parse once
|
|
59
59
|
return @cached_engine_yamls if @cached_engine_yamls
|
|
60
60
|
|
|
61
61
|
@load_lock.synchronize do
|
|
@@ -66,10 +66,10 @@ module Classy
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def self.cached_default_yaml
|
|
69
|
-
# Check file metadata
|
|
70
|
-
return load_default_yaml if
|
|
69
|
+
# Check file metadata only while Rails reloads code
|
|
70
|
+
return load_default_yaml if reloading?
|
|
71
71
|
|
|
72
|
-
#
|
|
72
|
+
# Classes are cached: parse once
|
|
73
73
|
return @cached_default_yaml if @cached_default_yaml
|
|
74
74
|
|
|
75
75
|
@load_lock.synchronize do
|
|
@@ -117,14 +117,22 @@ module Classy
|
|
|
117
117
|
cached_yaml_file(default_file, "default")
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
#
|
|
120
|
+
# Edits are picked up without a restart only while Rails reloads code.
|
|
121
|
+
# With classes cached (test, production) a parsed file is never stat'ed again.
|
|
122
|
+
def self.reloading?
|
|
123
|
+
!Rails.application.config.cache_classes
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Check metadata on each access while reloading so edits do not require a restart.
|
|
121
127
|
def self.cached_yaml_file(file_path, file_type)
|
|
122
128
|
@file_lock.synchronize do
|
|
123
129
|
begin
|
|
124
130
|
path = Rails.root.join(file_path).to_s
|
|
131
|
+
cached = @file_cache[path]
|
|
132
|
+
return cached[:yaml] if cached && !reloading?
|
|
133
|
+
|
|
125
134
|
stat = File.stat(path)
|
|
126
135
|
signature = [ stat.mtime, stat.ctime, stat.size, stat.ino, stat.dev ]
|
|
127
|
-
cached = @file_cache[path]
|
|
128
136
|
return cached[:yaml] if cached && cached[:signature] == signature
|
|
129
137
|
|
|
130
138
|
content = File.read(path, encoding: "UTF-8")
|
|
@@ -133,7 +141,8 @@ module Classy
|
|
|
133
141
|
@file_cache[path] = { signature: signature, yaml: yaml }
|
|
134
142
|
yaml
|
|
135
143
|
rescue Errno::ENOENT, Errno::ENOTDIR
|
|
136
|
-
|
|
144
|
+
# A missing file stays missing until the next restart when classes are cached.
|
|
145
|
+
reloading? ? @file_cache.delete(path) : @file_cache[path] = { signature: nil, yaml: nil }
|
|
137
146
|
nil
|
|
138
147
|
rescue Psych::SyntaxError => e
|
|
139
148
|
@file_cache.delete(path)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: classy-yaml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tonksthebear
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|