classy-yaml 1.4.0 → 1.5.0
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/component_helpers.rb +5 -5
- data/lib/classy/yaml/helpers.rb +10 -10
- data/lib/classy/yaml/version.rb +1 -1
- data/lib/classy/yaml.rb +37 -5
- 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: b91dad78932d510d2299faae67a08584bad33501c3a048435603a6e673049090
|
4
|
+
data.tar.gz: c3d9d4e2c543e3f3b70b94260f2293d5d3f6a24474e228690aa5c97f5a80666f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bc0b46c0d2f9fb2a49eedada6e497c7aebf14bc6f95f75609461620f44d5df12066dd8437fe8be90240053670dad19bf6cf1a80a1d8a3f08f0a54ea8e1ce6ad
|
7
|
+
data.tar.gz: bcf8f2d58c819e91a935076eb920094e27b2855e30d13038fd26ad3942447d1c5c14f646427e18d3787a6c39774da89bc63443995cf0373935eceb28db0186b4
|
@@ -2,13 +2,13 @@ module Classy
|
|
2
2
|
module Yaml
|
3
3
|
module ComponentHelpers
|
4
4
|
def yass(*args)
|
5
|
-
calling_path = Object.const_source_location(self.class.name).first.split(
|
6
|
-
calling_file = Object.const_source_location(self.class.name).first.split(
|
7
|
-
component_name = self.class.name.underscore.split(
|
5
|
+
calling_path = Object.const_source_location(self.class.name).first.split("/")[0...-1].join("/")
|
6
|
+
calling_file = Object.const_source_location(self.class.name).first.split("/").last.split(".").first
|
7
|
+
component_name = self.class.name.underscore.split("/").last.split(".").first
|
8
8
|
|
9
|
-
classy_files = ["#{calling_path}/#{component_name}.yml",
|
9
|
+
classy_files = [ "#{calling_path}/#{component_name}.yml",
|
10
10
|
"#{calling_path}/#{calling_file}/#{calling_file}.yml",
|
11
|
-
"#{calling_path}/#{calling_file}/#{component_name}.yml"]
|
11
|
+
"#{calling_path}/#{calling_file}/#{component_name}.yml" ]
|
12
12
|
|
13
13
|
if args.first.is_a?(Hash)
|
14
14
|
args.first.merge!({ classy_files: classy_files.uniq })
|
data/lib/classy/yaml/helpers.rb
CHANGED
@@ -47,8 +47,8 @@ module Classy
|
|
47
47
|
begin
|
48
48
|
path_obj = file_path.is_a?(Pathname) ? file_path : Rails.root.join(file_path)
|
49
49
|
if File.exist?(path_obj)
|
50
|
-
content = File.read(path_obj, encoding:
|
51
|
-
parsed_yaml = YAML.safe_load(content, permitted_classes: [Symbol, String, Array, Hash], aliases: true)
|
50
|
+
content = File.read(path_obj, encoding: "UTF-8")
|
51
|
+
parsed_yaml = YAML.safe_load(content, permitted_classes: [ Symbol, String, Array, Hash ], aliases: true)
|
52
52
|
classy_yamls << parsed_yaml if parsed_yaml && parsed_yaml.is_a?(Hash)
|
53
53
|
end
|
54
54
|
rescue Psych::SyntaxError => e
|
@@ -73,14 +73,14 @@ module Classy
|
|
73
73
|
end
|
74
74
|
|
75
75
|
value.keys.each do |key|
|
76
|
-
values << (root + [key.to_s])
|
77
|
-
flatten_args(root: root + [key.to_s], values: [value[key]], keys: keys, added_classes: added_classes)
|
76
|
+
values << (root + [ key.to_s ])
|
77
|
+
flatten_args(root: root + [ key.to_s ], values: [ value[key] ], keys: keys, added_classes: added_classes)
|
78
78
|
end
|
79
79
|
else
|
80
80
|
if value.is_a?(Array)
|
81
81
|
flatten_args(root: root, values: value, keys: keys, added_classes: added_classes)
|
82
82
|
else
|
83
|
-
keys << (root + [value.to_s])
|
83
|
+
keys << (root + [ value.to_s ])
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -106,12 +106,12 @@ module Classy
|
|
106
106
|
begin
|
107
107
|
value_at_key = classy_yaml.send(:dig, *key)
|
108
108
|
base_value = if value_at_key.is_a?(Hash)
|
109
|
-
classy_yaml.send(:dig, *(key + [
|
110
|
-
|
111
|
-
classy_yaml.send(:dig, *(key[0...-1] + [
|
112
|
-
|
109
|
+
classy_yaml.send(:dig, *(key + [ "base" ]))
|
110
|
+
elsif key.length > 1
|
111
|
+
classy_yaml.send(:dig, *(key[0...-1] + [ "base" ]))
|
112
|
+
else
|
113
113
|
nil
|
114
|
-
|
114
|
+
end
|
115
115
|
normalized_base = normalize_original(base_value)
|
116
116
|
base_classes ||= normalized_base
|
117
117
|
rescue
|
data/lib/classy/yaml/version.rb
CHANGED
data/lib/classy/yaml.rb
CHANGED
@@ -13,6 +13,9 @@ module Classy
|
|
13
13
|
mattr_accessor :extra_files
|
14
14
|
@@extra_files = []
|
15
15
|
|
16
|
+
mattr_accessor :override_tag_helpers
|
17
|
+
@@override_tag_helpers = false
|
18
|
+
|
16
19
|
# -- Autoloads --
|
17
20
|
autoload :Helpers, "classy/yaml/helpers"
|
18
21
|
autoload :ComponentHelpers, "classy/yaml/component_helpers"
|
@@ -39,6 +42,11 @@ module Classy
|
|
39
42
|
@cached_default_yaml = nil # Clear cache on reassignment
|
40
43
|
end
|
41
44
|
|
45
|
+
def self.override_tag_helpers=(value)
|
46
|
+
@@override_tag_helpers = value
|
47
|
+
apply_tag_helper_override if value
|
48
|
+
end
|
49
|
+
|
42
50
|
# -- Cached Data Accessors (Lazy Loading) --
|
43
51
|
def self.cached_engine_yamls
|
44
52
|
# Bypass cache in development and test environments
|
@@ -73,18 +81,42 @@ module Classy
|
|
73
81
|
# Clear all caches when configuration changes
|
74
82
|
@cached_engine_yamls = nil
|
75
83
|
@cached_default_yaml = nil
|
84
|
+
# Apply tag helper override if enabled
|
85
|
+
apply_tag_helper_override if @@override_tag_helpers
|
76
86
|
end
|
77
87
|
|
78
88
|
private
|
79
89
|
|
80
|
-
|
90
|
+
def self.apply_tag_helper_override
|
91
|
+
return unless defined?(ActionView::Helpers::TagHelper)
|
92
|
+
|
93
|
+
# Override the TagBuilder class which is what the tag method returns
|
94
|
+
ActionView::Helpers::TagHelper::TagBuilder.class_eval do
|
95
|
+
unless method_defined?(:classy_yaml_original_tag_options)
|
96
|
+
alias_method :classy_yaml_original_tag_options, :tag_options
|
97
|
+
|
98
|
+
def tag_options(options, escape = true)
|
99
|
+
if options
|
100
|
+
class_key = options.key?(:class) ? :class : "class"
|
101
|
+
options = options.dup
|
102
|
+
val = options[class_key]
|
103
|
+
if val.is_a?(Symbol) || val.is_a?(Hash) || val.is_a?(Array)
|
104
|
+
options[:class] = yass(val)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
classy_yaml_original_tag_options(options, escape)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
81
113
|
def self.load_engine_yamls
|
82
114
|
yamls = []
|
83
115
|
self.engine_files.each do |file_path|
|
84
116
|
begin
|
85
117
|
if File.exist?(file_path)
|
86
|
-
content = File.read(file_path, encoding:
|
87
|
-
parsed_yaml = YAML.safe_load(content, permitted_classes: [Symbol, String, Array, Hash], aliases: true)
|
118
|
+
content = File.read(file_path, encoding: "UTF-8")
|
119
|
+
parsed_yaml = YAML.safe_load(content, permitted_classes: [ Symbol, String, Array, Hash ], aliases: true)
|
88
120
|
yamls << parsed_yaml if parsed_yaml && parsed_yaml.is_a?(Hash)
|
89
121
|
end
|
90
122
|
rescue Psych::SyntaxError => e
|
@@ -100,8 +132,8 @@ module Classy
|
|
100
132
|
default_path = Rails.root.join(self.default_file)
|
101
133
|
begin
|
102
134
|
if File.exist?(default_path)
|
103
|
-
content = File.read(default_path, encoding:
|
104
|
-
parsed_yaml = YAML.safe_load(content, permitted_classes: [Symbol, String, Array, Hash], aliases: true)
|
135
|
+
content = File.read(default_path, encoding: "UTF-8")
|
136
|
+
parsed_yaml = YAML.safe_load(content, permitted_classes: [ Symbol, String, Array, Hash ], aliases: true)
|
105
137
|
return parsed_yaml if parsed_yaml && parsed_yaml.is_a?(Hash)
|
106
138
|
end
|
107
139
|
rescue Psych::SyntaxError => e
|
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.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tonksthebear
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|