Class: Dandy::Routing::FileReader
- Inherits:
-
Object
- Object
- Dandy::Routing::FileReader
- Defined in:
- lib/dandy/routing/file_reader.rb
Instance Method Summary collapse
-
#initialize(dandy_config) ⇒ FileReader
constructor
A new instance of FileReader.
- #read ⇒ Object
Constructor Details
#initialize(dandy_config) ⇒ FileReader
Returns a new instance of FileReader.
4 5 6 |
# File 'lib/dandy/routing/file_reader.rb', line 4 def initialize(dandy_config) @config = dandy_config end |
Instance Method Details
#read ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dandy/routing/file_reader.rb', line 8 def read path = File.join('./', @config[:path][:routes]) raw_content = File.read(path) raw_content.gsub!(/\\\s*\n+\s*->/, '->') raw_content.gsub!(/\\\s*\n+\s*=>/, '=>') raw_content.gsub!(/\\\s*\n+\s*=\*/, '=>') # use '^' instead spaces and tabs raw_content = raw_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 |