Sha256: b63539cb5d02a007f0f129512f6392fda76f13f2f433945a319b5fda543105d3

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative "../pathname_utility"
module JsDependency
  module Mermaid
    class TargetPathname
      attr_accessor :color_css, :font_size_css

      # @param [String] target_path
      def initialize(target_path)
        @pathname = to_target_pathname(target_path)
        @color_css = "#f9f"
        @font_size_css = "4px"
      end

      # @param [String] src_path
      # @return [String]
      def mermaid_style(src_path)
        src_pathname = Pathname.new(src_path).realpath
        export_style(parse(@pathname.exist? ? @pathname.relative_path_from(src_pathname) : @pathname).join("_"))
      end

      private

      # @param [String] path
      # @return [String]
      def export_style(path)
        "style #{path} stroke:#{@color_css},stroke-width:#{@font_size_css}"
      end

      # @param [Pathname] pathname
      # @param [Integer] level
      def parse(pathname, level = -1)
        JsDependency::PathnameUtility.parse(pathname, level)
      end

      # @param [String] target_path
      # @return [Pathname]
      def to_target_pathname(target_path)
        JsDependency::PathnameUtility.to_target_pathname(target_path)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
js_dependency-0.4.1 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.4.0 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.15 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.14 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.13 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.12 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.11 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.10 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.9 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.8 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.7 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.6 lib/js_dependency/mermaid/target_pathname.rb
js_dependency-0.3.5 lib/js_dependency/mermaid/target_pathname.rb