Class: LieutenantGovernor::Generators::JsRouteHelpers
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- LieutenantGovernor::Generators::JsRouteHelpers
- Extended by:
- Thor::Actions
- Defined in:
- lib/lieutenant_governor/generators/js_route_helpers.rb
Class Method Summary collapse
-
.generate_paths_file(path) ⇒ Object
Use the extractor to get the hash assume function exists to translate hash to javascript text using Thor, open up a file, and then write the javascript text to the file.
Class Method Details
.generate_paths_file(path) ⇒ Object
Use the extractor to get the hash assume function exists to translate hash to javascript text using Thor, open up a file, and then write the javascript text to the file
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lieutenant_governor/generators/js_route_helpers.rb', line 17 def self.generate_paths_file(path) raise TypeError.new('Path must be String.') unless path.class == String routes = Rails.application.routes.routes route_table = LieutenantGovernor::Routing::Extractor.extract(routes) template = LieutenantGovernor::Templates::JsPaths.new(route_table) # create_file '/client/paths.js', template.render File.open(path, 'w') do |f| f.puts template.render end end |