Sha256: 419fe7db0ed07d72d04e1210339f8c5e0195ca11803464bed5de9edfb22d9493

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require "rails/generators"

module ReactOnRails
  module Generators
    class ReactWithReduxGenerator < Rails::Generators::Base
      Rails::Generators.hide_namespace(namespace)
      source_root(File.expand_path("../templates", __FILE__))

      def create_redux_directories
        dirs = %w[actions constants reducers store]
        dirs.each { |name| empty_directory("client/app/bundles/HelloWorld/#{name}") }
      end

      def copy_base_redux_files
        base_path = "redux/base/"
        %w[client/app/bundles/HelloWorld/components/HelloWorld.jsx
           client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
           client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx
           client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx
           client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx
           client/app/bundles/HelloWorld/store/helloWorldStore.jsx
           client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx].each do |file|
             copy_file(base_path + file, file)
           end
      end

      def create_appropriate_templates
        base_path = "base/base/"
        location = "client/app/bundles/HelloWorld/"
        source = base_path + location
        config = {
          component_name: "HelloWorldApp",
          app_relative_path: "./HelloWorldApp"
        }
        template("#{source}/startup/registration.jsx.tt", "#{location}/startup/registration.jsx", config)
        template("#{base_path}app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
react_on_rails-9.0.0.beta.11 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.10 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.9 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.8 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.7 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.6 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.5 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.4 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.3 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.2 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-9.0.0.beta.1 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.6 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.6.rc.1 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.6.rc.0 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.5 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.4 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.3 lib/generators/react_on_rails/react_with_redux_generator.rb
react_on_rails-8.0.2 lib/generators/react_on_rails/react_with_redux_generator.rb