Class: WebpackRailsReact::ViewGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- WebpackRailsReact::ViewGenerator
- Defined in:
- lib/generators/webpack_rails_react/view_generator.rb
Overview
:nodoc:
Instance Method Summary collapse
- #create_container ⇒ Object
- #create_entry_file ⇒ Object
- #create_rails_view ⇒ Object
- #normalize_view_name ⇒ Object
- #update_webpack_entry ⇒ Object
Instance Method Details
#create_container ⇒ Object
30 31 32 33 34 35 |
# File 'lib/generators/webpack_rails_react/view_generator.rb', line 30 def create_container name = @view.titleize.gsub(/ /, '') file = "webpack/containers/#{name}.js" copy_file "boilerplate/views/ContainerTemplate.js", file gsub_file file, /Placeholder/, name end |
#create_entry_file ⇒ Object
23 24 25 26 27 28 |
# File 'lib/generators/webpack_rails_react/view_generator.rb', line 23 def create_entry_file file = "webpack/#{@view.gsub(/ /, '')}.js" name = @view.titleize.gsub(/ /, '') copy_file "boilerplate/views/ViewTemplate.js", file gsub_file file, /Placeholder/, name end |
#create_rails_view ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/generators/webpack_rails_react/view_generator.rb', line 37 def create_rails_view name = @view.downcase.gsub(/ /, '_') empty_directory "app/views/#{name.pluralize}" file = "app/views/#{name.pluralize}/index.html.erb" copy_file "boilerplate/views/rails_view.html.erb", file gsub_file file, /placeholder/, name end |
#normalize_view_name ⇒ Object
8 9 10 11 |
# File 'lib/generators/webpack_rails_react/view_generator.rb', line 8 def normalize_view_name raise "View name argument missing" if args.length == 0 @view = args[0] end |
#update_webpack_entry ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/webpack_rails_react/view_generator.rb', line 13 def update_webpack_entry name = @view.downcase.gsub(/ /, "_") path = "'#{name}': './webpack/#{name}.js'," insert_into_file 'config/webpack.config.js', after: /entry: {\n/ do <<-CONFIG #{path} CONFIG end end |