Sha256: 1eff61aa6063468b3b2c64ae10799396aa2e4d8ec19e4a28b98803e7d8b45ec3

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module DrawioDsl
  # :nocov:
  class DrawIoExtensions

    attr_reader :sections
    attr_reader :current_section

    def initialize
      @sections = []
    end

    def section(name)
      @current_section = {
        name: name,
        shapes: []
      }
      @sections << current_section
      
      yield if block_given?
    end

    def shape(name, style, original_name)
      shape = {
        name: name,
        style: style,
        original_name: original_name
      }
      current_section[:shapes] << shape
      shape
    end

    def to_h
      {
        sections: @sections.map(&:to_h)
      }
    end

    # This methods was generated using Extensions.js
    # This generation can be improved over time and the code to do the generation
    # can be found in the .builders/generators/10-transform-drawio-js.rb.
    # original source: ~/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js
    def build_extensions
      # Constants
{{{constants}}}
      {{#each sections}}
      section :{{snake ./name}} do
        {{#each ./shapes}}
        shape :{{padr (snake ./name) 60}}, "{{{./style}}}", "{{./name}}"
        {{/each}}
      end
      {{/each}}
    end
  end
  # :nocov:
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
drawio_dsl-0.8.4 .builders/.templates/basic/drawio_extensions.rb
drawio_dsl-0.8.3 .builders/.templates/basic/drawio_extensions.rb
drawio_dsl-0.8.2 .builders/.templates/basic/drawio_extensions.rb
drawio_dsl-0.8.1 .builders/.templates/basic/drawio_extensions.rb
drawio_dsl-0.8.0 .builders/.templates/basic/drawio_extensions.rb
drawio_dsl-0.7.0 .builders/.templates/basic/drawio_extensions.rb
drawio_dsl-0.6.0 .builders/.templates/basic/drawio_extensions.rb