Module: JekyllRemotePlantUMLPlugin::Utils::PlantUML

Included in:
Block
Defined in:
lib/jekyll_remote_plantuml_plugin/utils.rb

Instance Method Summary collapse

Instance Method Details

#expand_path(path, current, last, separator) ⇒ Object



86
87
88
89
90
# File 'lib/jekyll_remote_plantuml_plugin/utils.rb', line 86

def expand_path(path, current, last, separator)
  path = path[1..] if path.start_with?(separator) && current.zero?
  path = [path, separator] unless path.end_with?(separator) || current == last
  path
end

#generate_url(provider, encoded_content, format) ⇒ Object



74
75
76
# File 'lib/jekyll_remote_plantuml_plugin/utils.rb', line 74

def generate_url(provider, encoded_content, format)
  join_paths(provider, format, encoded_content).to_s
end

#join_paths(*paths, separator: "/") ⇒ Object



78
79
80
81
82
83
84
# File 'lib/jekyll_remote_plantuml_plugin/utils.rb', line 78

def join_paths(*paths, separator: "/")
  paths = paths.compact.reject(&:empty?)
  last = paths.length - 1
  paths.each_with_index.map do |path, index|
    expand_path(path, index, last, separator)
  end.join
end