Class: LazyFeatures::Parser
- Inherits:
-
Object
- Object
- LazyFeatures::Parser
- Defined in:
- lib/lazyfeatures/parser.rb
Instance Attribute Summary collapse
-
#collection_resources ⇒ Object
Returns the value of attribute collection_resources.
-
#route_contents ⇒ Object
Returns the value of attribute route_contents.
-
#singleton_resources ⇒ Object
Returns the value of attribute singleton_resources.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Parser
constructor
A new instance of Parser.
- #parse_collections ⇒ Object
- #parse_resources ⇒ Object
- #parse_singletons ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Parser
Returns a new instance of Parser.
6 7 8 9 |
# File 'lib/lazyfeatures/parser.rb', line 6 def initialize(file_path) self.route_contents = File.open(file_path).read.split("\n") parse_resources end |
Instance Attribute Details
#collection_resources ⇒ Object
Returns the value of attribute collection_resources.
4 5 6 |
# File 'lib/lazyfeatures/parser.rb', line 4 def collection_resources @collection_resources end |
#route_contents ⇒ Object
Returns the value of attribute route_contents.
4 5 6 |
# File 'lib/lazyfeatures/parser.rb', line 4 def route_contents @route_contents end |
#singleton_resources ⇒ Object
Returns the value of attribute singleton_resources.
4 5 6 |
# File 'lib/lazyfeatures/parser.rb', line 4 def singleton_resources @singleton_resources end |
Instance Method Details
#parse_collections ⇒ Object
23 24 25 26 27 28 |
# File 'lib/lazyfeatures/parser.rb', line 23 def parse_collections route_contents.map do |route| match = route.match(/^.*\.resources\s\:(\w+).*$/) match[1] if match end.compact end |
#parse_resources ⇒ Object
11 12 13 14 |
# File 'lib/lazyfeatures/parser.rb', line 11 def parse_resources self.singleton_resources = parse_singletons self.collection_resources = parse_collections end |
#parse_singletons ⇒ Object
16 17 18 19 20 21 |
# File 'lib/lazyfeatures/parser.rb', line 16 def parse_singletons route_contents.map do |route| match = route.match(/^.*\.resource\s\:(\w+).*$/) match[1] if match end.compact end |