Class: Mayu::CSS::TransformResult
- Inherits:
-
Data
- Object
- Data
- Mayu::CSS::TransformResult
- Defined in:
- lib/mayu/css.rb
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#exports ⇒ Object
readonly
Returns the value of attribute exports.
-
#source_map ⇒ Object
readonly
Returns the value of attribute source_map.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes
40 41 42 |
# File 'lib/mayu/css.rb', line 40 def classes @classes end |
#code ⇒ Object (readonly)
Returns the value of attribute code
40 41 42 |
# File 'lib/mayu/css.rb', line 40 def code @code end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies
40 41 42 |
# File 'lib/mayu/css.rb', line 40 def dependencies @dependencies end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements
40 41 42 |
# File 'lib/mayu/css.rb', line 40 def elements @elements end |
#exports ⇒ Object (readonly)
Returns the value of attribute exports
40 41 42 |
# File 'lib/mayu/css.rb', line 40 def exports @exports end |
#source_map ⇒ Object (readonly)
Returns the value of attribute source_map
40 41 42 |
# File 'lib/mayu/css.rb', line 40 def source_map @source_map end |
Class Method Details
.from_ext(data) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mayu/css.rb', line 41 def self.from_ext(data) = new( classes: data.classes.transform_keys(&:to_sym), elements: data.elements.transform_keys(&:to_sym), code: data.code, source_map: data.source_map, dependencies: data.serialized_dependencies .then { JSON.parse(_1, symbolize_names: true) } .map do |dep| case dep in { type: "import", url:, placeholder:, supports:, media:, loc: } ImportDependency[url:, placeholder:, supports:, media:, loc: Loc.from_ext(loc) ] in { type: "url", url:, placeholder:, loc: } UrlDependency[url:, placeholder:, loc: Loc.from_ext(loc)] end end, exports: data.serialized_exports .then { JSON.parse(_1, symbolize_names: true) } .transform_keys(&:to_s) .transform_values do |export| Export[ name: export[:name], referenced?: export[:isReferenced], composes: export[:composes].map do |compose| case compose in { type: "local", name: } ComposeLocal[name: name.to_sym] in { type: "dependency", name:, specifier: } ComposeDependency[name: name.to_sym, specifier:] end end ] end ) |
Instance Method Details
#code_with_source_map ⇒ Object
84 85 86 87 88 89 |
# File 'lib/mayu/css.rb', line 84 def code_with_source_map " \#{code}\n /*# sourceMappingURL=\#{source_map} */\n CSS\nend\n" |
#replace_dependencies ⇒ Object
78 79 80 81 82 |
# File 'lib/mayu/css.rb', line 78 def replace_dependencies dependencies.reduce(code) do |code, dependency| code.gsub(dependency.placeholder, (yield dependency)) end end |