Class: Silicon::Routing::FileReader
- Inherits:
-
Object
- Object
- Silicon::Routing::FileReader
- Defined in:
- lib/silicon/routing/file_reader.rb
Instance Method Summary collapse
-
#initialize(silicon_config) ⇒ FileReader
constructor
A new instance of FileReader.
- #read ⇒ Object
Constructor Details
#initialize(silicon_config) ⇒ FileReader
Returns a new instance of FileReader.
4 5 6 |
# File 'lib/silicon/routing/file_reader.rb', line 4 def initialize(silicon_config) @config = silicon_config end |
Instance Method Details
#read ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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 |