Sha256: 5beffdf3bc6da93157d648b94c799104742b76d3e59d21f44931ee3a43c8d7fd

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

module Blogo::Renderer
  class Base

    class << self
      # @!attribute [rw] dependencies
      #   @return [Array<Hash>]
      attr_accessor :dependencies

      # Declare external gem dependencies for a render.
      #
      # @param dependency [Hash] hash with :gem and :require keys
      #
      # @return [void]
      def add_dependency(dependency)
        self.dependencies ||= []
        self.dependencies << dependency
      end

      # Try to load dependencies, otherwise raise meaningful error.
      #
      # @param renderer_name [Symbol, String]
      #
      # @return [void]
      def load_dependencies!(renderer_name)
        return unless dependencies

        dependencies.each do |dependency|
          begin
            require dependency[:require]
          rescue LoadError
            msg = "Please add `gem \"#{dependency[:gem]}\"` to the Gemfile " \
                  "to use Blogo with #{renderer_name.inspect} renderer"
            raise LoadError, msg
          end
        end
      end
    end


    # @param raw_text [String]
    #
    # @return [String] html
    def render(raw_text)
      raise AbstractMethodCallError, __method__
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
blogo-0.1.1 lib/blogo/renderer/base.rb
blogo-0.1.0 lib/blogo/renderer/base.rb
blogo-0.0.10 lib/blogo/renderer/base.rb
blogo-0.0.9 lib/blogo/renderer/base.rb
blogo-0.0.8 lib/blogo/renderer/base.rb
blogo-0.0.7 lib/blogo/renderer/base.rb
blogo-0.0.6 lib/blogo/renderer/base.rb
blogo-0.0.5 lib/blogo/renderer/base.rb
blogo-0.0.4 lib/blogo/renderer/base.rb
blogo-0.0.3 lib/blogo/renderer/base.rb
blogo-0.0.2 lib/blogo/renderer/base.rb
blogo-0.0.1 lib/blogo/renderer/base.rb