Class: Klenod::Build::Plugins::CSSPlugin::TransformResult

Inherits:
Data
  • Object
show all
Defined in:
lib/klenod/plugin/css/transformer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes

Returns:

  • (Object)

    the current value of classes



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def classes
  @classes
end

#codeObject (readonly)

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def code
  @code
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies

Returns:

  • (Object)

    the current value of dependencies



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def dependencies
  @dependencies
end

#elementsObject (readonly)

Returns the value of attribute elements

Returns:

  • (Object)

    the current value of elements



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def elements
  @elements
end

#exportsObject (readonly)

Returns the value of attribute exports

Returns:

  • (Object)

    the current value of exports



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def exports
  @exports
end

#referencesObject (readonly)

Returns the value of attribute references

Returns:

  • (Object)

    the current value of references



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def references
  @references
end

#serialized_variablesObject (readonly)

Returns the value of attribute serialized_variables

Returns:

  • (Object)

    the current value of serialized_variables



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def serialized_variables
  @serialized_variables
end

#source_mapObject (readonly)

Returns the value of attribute source_map

Returns:

  • (Object)

    the current value of source_map



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def source_map
  @source_map
end

#variablesObject (readonly)

Returns the value of attribute variables

Returns:

  • (Object)

    the current value of variables



40
41
42
# File 'lib/klenod/plugin/css/transformer.rb', line 40

def variables
  @variables
end

Class Method Details

.dependency_from_ext(dep) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/klenod/plugin/css/transformer.rb', line 54

def self.dependency_from_ext(dep)
  case dep.fetch("type")
  when "import"
    ImportDependency[
      url: dep.fetch("url"),
      placeholder: dep.fetch("placeholder"),
      supports: dep.fetch("supports"),
      media: dep.fetch("media"),
      loc: Loc.from_ext(dep.fetch("loc"))
    ]
  when "url"
    UrlDependency[
      url: dep.fetch("url"),
      placeholder: dep.fetch("placeholder"),
      loc: Loc.from_ext(dep.fetch("loc"))
    ]
  end
end

.export_from_ext(export) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/klenod/plugin/css/transformer.rb', line 73

def self.export_from_ext(export)
  Export[
    name: export.fetch("name"),
    referenced?: export.fetch("isReferenced"),
    composes: export.fetch("composes").map do |compose|
      case compose.fetch("type")
      when "local"
        ComposeLocal[name: compose.fetch("name").to_sym]
      when "global"
        ComposeGlobal[name: compose.fetch("name")]
      when "dependency"
        ComposeDependency[name: compose.fetch("name").to_sym, specifier: compose.fetch("specifier")]
      end
    end
  ]
end

.from_ext(data) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/klenod/plugin/css/transformer.rb', line 41

def self.from_ext(data) =
new(
  classes: data.fetch("classes").transform_keys(&:to_sym),
  elements: data.fetch("elements").transform_keys(&:to_sym),
  variables: data.fetch("variables"),
  serialized_variables: data.fetch("serialized_variables"),
  code: data.fetch("code"),
  source_map: data.fetch("source_map"),
  dependencies: JSON.parse(data.fetch("dependencies")).map { dependency_from_ext(it) },
  exports: JSON.parse(data.fetch("exports")).transform_values { export_from_ext(it) },
  references: JSON.parse(data.fetch("references")).transform_values { reference_from_ext(it) }
)

.reference_from_ext(reference) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/klenod/plugin/css/transformer.rb', line 90

def self.reference_from_ext(reference)
  case reference.fetch("type")
  when "dependency"
    VariableDependency[
      name: reference.fetch("name"),
      specifier: reference.fetch("specifier")
    ]
  end
end