Sha256: 07fe9845925d953cfb196f9839baf82192d8fde0aea2997611c2f2d2958524e5

Contents?: true

Size: 839 Bytes

Versions: 74

Compression:

Stored size: 839 Bytes

Contents

class Parser

  ANYTHINGS = %w[([^\"]*) ([^"]+) ([^"]*) (.*) (.*?) [^"]+ ([^\"]+) ([^']*)
    ([^\/]*) (.+) (.*[^:]) (.+?) .+].map &Regexp.method(:escape)

  def self.human_regex(regex)
    regex.
      sub(/^\(?\/\^?/, ''). # Strip Regex beginning
      sub(/\$?\/\)?$/, ''). # Strip Regex end
      gsub(' ?', ' ').
      gsub('(?:|I )', 'I ').
      gsub('(?:', '(').
      gsub(Regexp.new(Regexp.escape '(\d+)(st|nd|rd|th)'), '<nth>').
      gsub(Regexp.new(ANYTHINGS.join '|'), '...').
      gsub(/\\\//, '/')
  end

  def self.format_comment(comment)
    comment.gsub! /.*coding:.*UTF-8.*/, ''
    comment.strip!
    comment_lines = comment.split("\n").take_while { |line| line =~ /^\s*#/ }
    formatted = comment_lines && comment_lines.join("\n").gsub(/^\s*# ?/, '')

    formatted if formatted and not formatted.empty?
  end

end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
spreewald-4.6.3 support/parser.rb
spreewald-4.6.2 support/parser.rb
spreewald-4.6.1 support/parser.rb
spreewald-4.6.0 support/parser.rb
spreewald-4.5.1 support/parser.rb
spreewald-4.5.0 support/parser.rb
spreewald-4.4.4 support/parser.rb
spreewald-4.4.3 support/parser.rb
spreewald-4.4.2 support/parser.rb
spreewald-4.4.1 support/parser.rb
spreewald-4.4.0 support/parser.rb
spreewald-4.3.6 support/parser.rb
spreewald-4.3.5 support/parser.rb
spreewald-4.3.4 support/parser.rb
spreewald-4.3.3 support/parser.rb
spreewald-4.3.2 support/parser.rb
spreewald-4.2.3 support/parser.rb
spreewald-4.2.2 support/parser.rb
spreewald-4.1.2 support/parser.rb
spreewald-4.1.1 support/parser.rb