Sha256: 98e468b46ba608c26cda3a81d7fbcb0ba2d1412064605d18d71ba790ce3f6078

Contents?: true

Size: 1.24 KB

Versions: 17

Compression:

Stored size: 1.24 KB

Contents

require "rabbit/utils"

dir = File.join("rabbit", "parser")
Rabbit::Utils.require_files_under_directory_in_load_path(dir)

module Rabbit
  module Parser
    include GetText

    module_function
    def parse(canvas, source)
      parser = Base.find_loader(source)
      if parser.nil?
        format = _("unsupported format. (supported: %s)")
        loader_names = Base.loaders.collect {|loader| loader.name}
        message = format % "[#{loader_names.join(', ')}]"
        raise UnsupportedFormatError.new(message)
      end
      parser.new(canvas, source).parse
    end

    def normalize_property_name(name)
      name.gsub(/_/, "-").strip
    end

    class SlidePropertySetter
      def initialize(slide)
        @slide = slide
      end

      def apply(element)
        return unless element.is_a?(Element::DescriptionList)
        element.each do |item|
          name = Parser.normalize_property_name(item.term.text)
          @slide[name] = item.content.text.strip
        end
      end
    end

    class NoteSetter
      def initialize(slide)
        @slide = slide
      end

      def apply(element)
        return unless element.is_a?(Element::Paragraph)
        @slide['note'] ||= ""
        @slide['note'] << element.text
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rabbit-2.1.6 lib/rabbit/parser.rb
rabbit-2.1.5 lib/rabbit/parser.rb
rabbit-2.1.4 lib/rabbit/parser.rb
rabbit-2.1.3 lib/rabbit/parser.rb
rabbit-2.1.2 lib/rabbit/parser.rb
rabbit-2.1.1 lib/rabbit/parser.rb
rabbit-2.1.0 lib/rabbit/parser.rb
rabbit-2.0.9 lib/rabbit/parser.rb
rabbit-2.0.8 lib/rabbit/parser.rb
rabbit-2.0.7 lib/rabbit/parser.rb
rabbit-2.0.6 lib/rabbit/parser.rb
rabbit-2.0.5 lib/rabbit/parser.rb
rabbit-2.0.4 lib/rabbit/parser.rb
rabbit-2.0.3 lib/rabbit/parser.rb
rabbit-2.0.2 lib/rabbit/parser.rb
rabbit-2.0.1 lib/rabbit/parser.rb
rabbit-2.0.0 lib/rabbit/parser.rb