class ReactWebpackRails::Install::ReduxGenerator

Constants

REACT_INDEX_FILE

Public Instance Methods

add_import() click to toggle source
# File lib/generators/react_webpack_rails/install/redux_generator.rb, line 22
      def add_import
        inject_into_file REACT_INDEX_FILE, after: "import RWR from 'react-webpack-rails';\n" do
          <<-'JS'.strip_heredoc
            import RWRRedux from 'rwr-redux';

          JS
        end
      end
add_integration_managers() click to toggle source
# File lib/generators/react_webpack_rails/install/redux_generator.rb, line 37
      def add_integration_managers
        inject_into_file REACT_INDEX_FILE, after: "RWR.run();\n" do
          <<-'JS'.strip_heredoc

            integrationsManager.register('redux-store', RWRRedux.storeIntegrationWrapper);
            integrationsManager.register('redux-container', RWRRedux.containerIntegrationWrapper);
          JS
        end
      end
add_rwr_redux() click to toggle source
# File lib/generators/react_webpack_rails/install/redux_generator.rb, line 47
      def add_rwr_redux
        append_file 'Gemfile' do
          <<-'RB'.strip_heredoc
            gem 'rwr-redux'
          RB
        end
      end
gsub_rwr_import() click to toggle source
# File lib/generators/react_webpack_rails/install/redux_generator.rb, line 31
def gsub_rwr_import
  old_line = "import RWR from 'react-webpack-rails';"
  new_line = "import RWR, { integrationsManager } from 'react-webpack-rails';"
  gsub_file REACT_INDEX_FILE, old_line, new_line
end
package() click to toggle source
# File lib/generators/react_webpack_rails/install/redux_generator.rb, line 17
def package
  merge_options = options.tmp_package ? { package_file: 'tmp/package.json', force: true } : {}
  merge_into_package 'packages/redux.json', merge_options
end