class Silicon::Routing::FileReader

Public Class Methods

new(silicon_config) click to toggle source
# File lib/silicon/routing/file_reader.rb, line 4
def initialize(silicon_config)
  @config = silicon_config
end

Public Instance Methods

read() click to toggle source
# File lib/silicon/routing/file_reader.rb, line 8
def read
  path = File.join('./', @config[:path][:routes])
  content = File.read(path)

  # use '^' instead spaces and tabs
  raw_content = content.gsub(/\t/, '  ')
                  .gsub('  ', '^')
                  .gsub(' ', '')

  ###Hack:
  # grammar problem - can't simply match '-' character in route path when '->' present.
  # Will be resolved later. Replace '->', '<-' with '*>', '<*' for a while for syntax parser.
  ###
  raw_content = raw_content.gsub('->', '*>').gsub('<-', '<*')

  raw_content.gsub!("\n", ';') + ';'
end