Sha256: 128c88e3b76c271a45c358e9bf41250c7431d4ea4732103bad81706efc21669d

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

require 'somemoji'

module Middleman
  module Somemoji
    class Converter
      def initialize(options)
        @provider     = options[:provider]
        @format       = options[:format]
        @emoji_class  = options[:emoji_class]
        @emojis_dir   = options[:emojis_dir]
      end

      def convert(app)
        files = Dir.glob(File.join(app.config[:build_dir], "**", "*.html"))
        files.each do |file|
          body = eval("::Somemoji::#{@provider}_emoji_collection").replace_code(File.read(file)) do |emoji|
            %(<img alt="#{emoji.character}" class="#{@emoji_class}" src="#{@emojis_dir}/#{emoji.base_path}.#{@format}">)
          end
          File.open(file, 'w') do |f|
            f.write body
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-somemoji-0.2.0 lib/middleman-somemoji/converter.rb