Sha256: 6a96e8a393604282596d34d81045ff931676c72de0124b91c75a2947c5d11c0e

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module TailwindDsl
  module Etl
    module RawComponents
      # NOTE: Director is badly named.

      # Use the Director to build the UiKit which will store the JSON representations of each Design System plus components.
      #
      # This is a raw representation of the source.
      #
      # This data structure will be used by the component transformer to build
      # auxiliary data structures for components such as clean HTML, Astro, data shapes.
      class Director
        attr_reader :uikit

        def initialize
          @uikit = ::TailwindDsl::Etl::RawComponents::UiKit.new
        end

        def add_design_system(path, name: nil)
          name = (name || File.basename(path)).to_s

          design_system = Transformer.new.call(name, path)

          uikit.add_design_system(design_system)
        end

        def write(file)
          FileUtils.mkdir_p(File.dirname(file))
          File.write(file, JSON.pretty_generate(uikit.to_h))
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tailwind_dsl-0.0.19 lib/tailwind_dsl/etl/raw_components/director.rb
tailwind_dsl-0.0.18 lib/tailwind_dsl/etl/raw_components/director.rb
tailwind_dsl-0.0.17 lib/tailwind_dsl/etl/raw_components/director.rb
tailwind_dsl-0.0.16 lib/tailwind_dsl/etl/raw_components/director.rb
tailwind_dsl-0.0.15 lib/tailwind_dsl/etl/raw_components/director.rb
tailwind_dsl-0.0.14 lib/tailwind_dsl/etl/raw_components/director.rb