Sha256: ec9e77af5d9edaa1ceac1665c1241a675dab88987a0d687632449a584f04678a

Contents?: true

Size: 1012 Bytes

Versions: 3

Compression:

Stored size: 1012 Bytes

Contents

module Cleaners
    def self.starting_tags_without_spaces_cleaner(str) 
        str && str.gsub(/\{\s*\{\s*%/, '{{%')
    end

    def self.ending_tags_without_spaces_cleaner(str) 
        str && str.gsub(/%\s*\}\s*\}/, '%}}')
    end

    def self.single_quote_cleaner(str)
        str && str.gsub(/\‘/, '\'').gsub(/\’/, '\'')
    end

    def self.var_without_duplicated_spaces_cleaner(str) 
        str && str.gsub(/\s+/, ' ')
    end

    def self.var_without_spaces_inside_brackets_cleaner(str) 
        str && str.gsub(/\[(.*?)\]/) { |match| match.gsub(/\s/, '')}
    end

    def self.no_spaces_around_undeline_cleaner(str) 
        str && str.gsub(/\s*\_\s*/, "_")
    end

    def self.join_dots_and_brackets_cleaner(str)
        str && str.gsub(/\s*\.\s*/, '.').gsub(/\s*\[\s*/, '[').gsub(/\s*\]/, ']')
    end

    def self.question_method_cleaner(str)
        if str && str =~ /\A\{\{\s+if\s*(.*?)\s*\?\s+\}\}\Z/
            "{{ if #{$1}\? }}"
        else
            str
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docx-builder-0.1.13 lib/docx/cleaners.rb
docx-builder-0.1.11 lib/docx/cleaners.rb
docx-builder-0.1.8 lib/docx/cleaners.rb