Sha256: 23b8059f2a673a03fd604e1857dc50cd7e3bf174c3f9c88a66a4db18613cabcb

Contents?: true

Size: 776 Bytes

Versions: 46

Compression:

Stored size: 776 Bytes

Contents

module Junoser
  class Input
    def initialize(io_or_string)
      @io_or_string = io_or_string
    end

    def read
      content = if @io_or_string.respond_to?(:read)
                  @io_or_string.read
                else
                  @io_or_string.to_s
                end

      content = remove_blank_and_comment_line(content)
      content = unify_carriage_return(content)
    end


    private

    # As for comment line, a trailing comment after configuration will be processed by parslet
    def remove_blank_and_comment_line(str)
      str.gsub! /^\s*#.*/, ''
      str.gsub! /^\s*\/\*((?!\*\/).)*\*\//m, ''
      str.gsub! /\n\s*/, "\n"
      str.strip
    end

    def unify_carriage_return(str)
      str.gsub! /\r\n?/, "\n"
      str
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
junoser-0.5.5 lib/junoser/input.rb
junoser-0.5.4 lib/junoser/input.rb
junoser-0.5.3 lib/junoser/input.rb
junoser-0.5.2 lib/junoser/input.rb
junoser-0.5.1 lib/junoser/input.rb
junoser-0.5.0 lib/junoser/input.rb
junoser-0.4.7 lib/junoser/input.rb
junoser-0.4.6 lib/junoser/input.rb
junoser-0.4.5 lib/junoser/input.rb
junoser-0.4.4 lib/junoser/input.rb
junoser-0.4.3 lib/junoser/input.rb
junoser-0.4.2 lib/junoser/input.rb
junoser-0.4.1 lib/junoser/input.rb
junoser-0.4.0 lib/junoser/input.rb
junoser-0.3.13 lib/junoser/input.rb
junoser-0.3.12 lib/junoser/input.rb
junoser-0.3.11 lib/junoser/input.rb
junoser-0.3.10 lib/junoser/input.rb
junoser-0.3.9 lib/junoser/input.rb
junoser-0.3.8 lib/junoser/input.rb