Sha256: 17d09a7fd7c95a0d9fffcebe85cb6ade8d757beff904404ea4e3ab8985ce13c6

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

module PlantumlBuilder
  class Format
    DEFAULT_HOST = 'http://www.plantuml.com/plantuml'.freeze

    def initialize(diagram, host=DEFAULT_HOST)
      self.host = host
      self.diagram = diagram
    end

    def load
      compress_diagram
      build_url
      fetch_diagram

      data
    end

    protected

    def format
      raise NotImplementedError, '#format should be overloaded'
    end

    private

    def compress_diagram
      self.data = PlantumlBuilder::Compressor.new(diagram).encode
    end

    def build_url
      self.data = PlantumlBuilder::UrlBuilder.new(host, format, data).build
    end

    def fetch_diagram
      self.data = PlantumlBuilder::DiagramFetcher.new(data).fetch
    end

    attr_accessor :host, :diagram, :data
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plantuml_builder-0.3.0 lib/plantuml_builder/format.rb
plantuml_builder-0.2.0 lib/plantuml_builder/format.rb
plantuml_builder-0.1.1 lib/plantuml_builder/format.rb
plantuml_builder-0.1.0 lib/plantuml_builder/format.rb