redux_rails 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +82 -27
- data/lib/generators/container/container_generator.rb +3 -3
- data/lib/redux_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b1046f9e1b856388203708b660b93fce9800c0f
|
4
|
+
data.tar.gz: 8c7835e72c424dbee6bbb7ea06cf1849d7b3bb1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d455c23cf3e2b0ee4ae93adc30f737779d27ac0c652eef3b4ecf1f3b4e900b34691973c47800adadc12060b5fbd76e404a97416d2bbb7e636985679ef83b7f70
|
7
|
+
data.tar.gz: 62cea610996c0c79e71d11395b6467ffb4ce43f1d72d00088329b3531faa4aa3815d9fb683ea719a92c9b4df242159e96d8c4cbaa0b3f882ecc6f07c09ffadba
|
data/README.md
CHANGED
@@ -1,14 +1,38 @@
|
|
1
|
-
# ReduxRails
|
2
|
-
|
3
|
-
##
|
1
|
+
# ReduxRails [](https://badge.fury.io/rb/redux_rails)
|
2
|
+
Easily setup React and Redux in Rails -v 5.1. Create re-usable project files and folders for use throughout your project or outside of the current one. Start from scratch or add to an existing project. Redux is setup during the install generator, but not required and still functions correctly. With easy component and container generators you can add to any project and use on any other projects with or without Rails.
|
3
|
+
## Table of contents
|
4
|
+
- <a href="#reduxrails-">ReduxRails</a>
|
5
|
+
- <a href="#highlights">Highlights</a>
|
6
|
+
- <a href="#install-generator">Install Generator</a>
|
7
|
+
- <a href="#created-foldersfile">Created folders/files</a>
|
8
|
+
- <a href="#component-folder">Component folder</a>
|
9
|
+
- <a href="#container-folder">Container folder</a>
|
10
|
+
- <a href="#pack-generator">Pack Generator</a>
|
11
|
+
- <a href="#created-foldersfile-1">Created folders/files</a>
|
12
|
+
- <a href="#component-folder-1">Component folder</a>
|
13
|
+
- <a href="#container-folder-1">Container folder</a>
|
14
|
+
- <a href="#component-generator">Component Generator</a>
|
15
|
+
- <a href="#created-folderfiles">Created folder/files</a>
|
16
|
+
- <a href="#container-generator">Container Generator</a>
|
17
|
+
- <a href="#created-folderfiles-1">Created folder/files</a>
|
18
|
+
- <a href="#installation">Installation</a>
|
19
|
+
- <a href="#usage">Usage</a>
|
20
|
+
- <a href="#install-generator-1">Install Generator</a>
|
21
|
+
- <a href="#pack-generator-1">Pack Generator</a>
|
22
|
+
- <a href="#component-generator-1">Component Generator</a>
|
23
|
+
- <a href="#container-generator-1">Container Generator</a>
|
24
|
+
- <a href="#development">Development</a>
|
25
|
+
- <a href="#license">License</a>
|
26
|
+
### Highlights
|
4
27
|
- install, pack, component and container generator
|
5
|
-
- creates a
|
28
|
+
- creates a pack tag for `rails g redux_rails:install #{your_app_name}` command and installs the necessary lines to manifest.json. Allowing you to have several seperate React apps inside of a single rails project.
|
29
|
+
- pack generator creates a new React app you can use anywhere in your project. It includes everything from the `redux_rails:install` command without re-installing the javascript dependencies.
|
6
30
|
- install component and container folders in any folder location from the command line with the necessary import/export/require lines.
|
7
31
|
- react-router-dom
|
8
32
|
- redux-devtools-extension
|
9
|
-
|
10
|
-
### Install
|
11
|
-
- Installs the following dependencies `
|
33
|
+
###### <a href="#reduxrails-">Back to top</a>
|
34
|
+
### Install Generator
|
35
|
+
- Installs the following dependencies `react-redux` `redux` `redux-devtools-extension` `react-router-dom` `react-router-redux` `history`
|
12
36
|
- Installs a new #{your_app_name}.jsx file in app/javascript/packs with additional Redux setup options commented out for modifications.
|
13
37
|
###### *if you leave #{your_app_name} blank. file, component and container names will default to 'app'*
|
14
38
|
- Links it to public/packs/manifest.json
|
@@ -30,17 +54,37 @@
|
|
30
54
|
* app/javascript/src/#{your_app_name}/containers/app/actionTypes.js,
|
31
55
|
* app/javascript/src/#{your_app_name}/containers/app/constants.js,
|
32
56
|
* app/javascript/src/#{your_app_name}/containers/app/appReducer.js
|
57
|
+
###### <a href="#reduxrails-">Back to top</a>
|
58
|
+
### Pack Generator
|
59
|
+
- Installs a new #{your_app_name}.jsx file in app/javascript/packs with additional Redux setup options commented out for modifications.
|
60
|
+
###### *if you leave #{your_app_name} blank. file, component and container names will default to 'app'*
|
61
|
+
- Links it to public/packs/manifest.json
|
62
|
+
#### Created folders/files
|
63
|
+
* app/javascript/src/#{your_app_name},
|
64
|
+
* app/javascript/src/#{your_app_name}/reducer.js, `for your combineReducer`
|
33
65
|
|
34
|
-
|
35
|
-
|
66
|
+
###### Component folder
|
67
|
+
* app/javascript/src/#{your_app_name}/components,
|
68
|
+
* app/javascript/src/#{your_app_name}/components/app,
|
69
|
+
* app/javascript/src/#{your_app_name}/components/app/app.js,
|
70
|
+
* app/javascript/src/#{your_app_name}/components/app/app.scss
|
36
71
|
|
37
|
-
|
72
|
+
###### Container folder
|
73
|
+
* app/javascript/src/#{your_app_name}/containers,
|
74
|
+
* app/javascript/src/#{your_app_name}/containers/app,
|
75
|
+
* app/javascript/src/#{your_app_name}/containers/app/app.js,
|
76
|
+
* app/javascript/src/#{your_app_name}/containers/app/action.js,
|
77
|
+
* app/javascript/src/#{your_app_name}/containers/app/actionTypes.js,
|
78
|
+
* app/javascript/src/#{your_app_name}/containers/app/constants.js,
|
79
|
+
* app/javascript/src/#{your_app_name}/containers/app/appReducer.js
|
80
|
+
###### <a href="#reduxrails-">Back to top</a>
|
81
|
+
### Component Generator
|
38
82
|
#### Created folder/files
|
39
83
|
* app/javascript/src/#{your_app_name}/components/app/#{your_component_name},
|
40
84
|
* app/javascript/src/#{your_app_name}/components/app/#{your_component_name}/#{your_component_name}.js,
|
41
85
|
* app/javascript/src/#{your_app_name}/components/app/#{your_component_name}/#{your_component_name}.scss
|
42
|
-
|
43
|
-
### Container
|
86
|
+
###### <a href="#reduxrails-">Back to top</a>
|
87
|
+
### Container Generator
|
44
88
|
#### Created folder/files
|
45
89
|
* app/javascript/src/#{your_app_name}/containers/#{your_container_name},
|
46
90
|
* app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}.js,
|
@@ -49,7 +93,7 @@
|
|
49
93
|
* app/javascript/src/#{your_app_name}/containers/#{your_container_name}/constants.js,
|
50
94
|
* app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}Reducer.js
|
51
95
|
- each generated container reducer will be imported into #{your_app_name} root reducer at app/javascript/src/#{your_app_name}/reducer.js and included in the combineReducer
|
52
|
-
|
96
|
+
###### <a href="#reduxrails-">Back to top</a>
|
53
97
|
## Installation
|
54
98
|
|
55
99
|
Create a new Rails project with webpack option
|
@@ -63,7 +107,7 @@ Then navigate into your new project:
|
|
63
107
|
Add this line to your application's Gemfile:
|
64
108
|
|
65
109
|
```ruby
|
66
|
-
gem 'redux_rails'
|
110
|
+
gem 'redux_rails', '~> 0.1.4'
|
67
111
|
```
|
68
112
|
|
69
113
|
And then execute:
|
@@ -80,7 +124,7 @@ To allow javascript_pack_tag to load assets from webpack-dev-server navigate to
|
|
80
124
|
config.x.webpacker[:dev_server_host] = "http://127.0.0.1:8080"
|
81
125
|
```
|
82
126
|
|
83
|
-
To create the packs/manifest.json run:
|
127
|
+
To create the `packs/manifest.json` run:
|
84
128
|
|
85
129
|
$ bin/webpack-dev-server --host 127.0.0.1
|
86
130
|
|
@@ -109,11 +153,11 @@ At this point, Rails has created a javascript friendly app for you. To render th
|
|
109
153
|
```
|
110
154
|
Hello React!
|
111
155
|
```
|
112
|
-
|
156
|
+
###### <a href="#reduxrails-">Back to top</a>
|
113
157
|
## Usage
|
114
158
|
|
115
159
|
### Install generator
|
116
|
-
###### *only run this once! If you wish to create additional pack files run `rails generate
|
160
|
+
###### *only run this once! If you wish to create additional pack files run `rails generate pack #{pack_name}`*
|
117
161
|
Once your rails app is setup with the webpack=react option and the redux-rails gem is installed and your `config/environments/development.rb` is updated execute:
|
118
162
|
###### *if you leave #{your_app_name} blank file, component and container names will default to 'app'*
|
119
163
|
|
@@ -141,7 +185,7 @@ and adds and installs these dependencies to your package.json file:
|
|
141
185
|
|
142
186
|
`react-redux` `redux` `redux-devtools-extension` `react-router-dom` `react-router-redux` `history`
|
143
187
|
|
144
|
-
Once the
|
188
|
+
Once the Install Generator is finished:
|
145
189
|
1. add the following pack_tags to the file you want the react component to be rendered in
|
146
190
|
```
|
147
191
|
<%= javascript_pack_tag '#{your_app_name}' %>
|
@@ -150,8 +194,9 @@ Once the install generator is finished:
|
|
150
194
|
2. Restart your servers or open two new ones with the commands above and navigate to the page in your browser and you should see:
|
151
195
|
```
|
152
196
|
#{your_app_name} component!
|
153
|
-
find me in find me in app/javascript/src/#{your_app_name}/components/#{your_app_name}
|
197
|
+
find me in find me in app/javascript/src/#{your_app_name}/components/#{your_app_name}/#{your_app_name}.js
|
154
198
|
```
|
199
|
+
###### <a href="#reduxrails-">Back to top</a>
|
155
200
|
### Pack generator
|
156
201
|
The Pack generator takes a single name argument
|
157
202
|
###### *if you leave #{your_app_name} blank file, component and container names will default to 'app'*
|
@@ -178,10 +223,21 @@ This will generate a new React app inside of the `app/javascript/src` folder. In
|
|
178
223
|
- `app/javascript/src/#{your_app_name}/containers/#{your_app_name}/constants.js`
|
179
224
|
- `app/javascript/src/#{your_app_name}/containers/#{your_app_name}/#{your_app_name}Reducer.js`
|
180
225
|
|
181
|
-
|
226
|
+
Once the Pack Generator is finished:
|
227
|
+
1. add the following pack_tags to the file you want the react component to be rendered in
|
228
|
+
```
|
229
|
+
<%= javascript_pack_tag '#{your_app_name}' %>
|
230
|
+
<%= stylesheet_pack_tag '#{your_app_name}' %>
|
231
|
+
```
|
232
|
+
2. Restart your servers or open two new ones with the commands above and navigate to the page in your browser and you should see:
|
233
|
+
```
|
234
|
+
#{your_app_name} component!
|
235
|
+
find me in find me in app/javascript/src/#{your_app_name}/components/#{your_app_name}/#{your_app_name}.js
|
236
|
+
```
|
237
|
+
###### <a href="#reduxrails-">Back to top</a>
|
182
238
|
### Component generator
|
183
239
|
The Component generator takes two arguments (the new Component name and the desired install location)
|
184
|
-
###### *if you leave #{your_app_name} or #{your_component_name} blank file, component and container names will default to 'app'*
|
240
|
+
###### *if you leave #{your_app_name} or #{your_component_name} blank. file, component and container names will default to 'app'*
|
185
241
|
To create a new component run:
|
186
242
|
|
187
243
|
$ rails generate component #{your_component_name} #{your_app_name}
|
@@ -190,10 +246,10 @@ This will generate a new folder inside of your components folder with the follow
|
|
190
246
|
- `app/javascript/src/#{your_app_name}/components/#{your_component_name}`
|
191
247
|
- `app/javascript/src/#{your_app_name}/components/#{your_component_name}/#{your_component_name}.js`
|
192
248
|
- `app/javascript/src/#{your_app_name}/components/#{your_component_name}/#{your_component_name}.scss`
|
193
|
-
|
249
|
+
###### <a href="#reduxrails-">Back to top</a>
|
194
250
|
### Container generator
|
195
251
|
The Container generator takes two arguments (the new Container name and the desired install location)
|
196
|
-
###### *if you leave #{your_app_name} or #{your_container_name} blank file, component and container names will default to 'app'*
|
252
|
+
###### *if you leave #{your_app_name} or #{your_container_name} blank. file, component and container names will default to 'app'*
|
197
253
|
To create a new container run:
|
198
254
|
|
199
255
|
$ rails generate container #{your_container_name} #{your_app_name}
|
@@ -205,15 +261,13 @@ This will generate a new folder inside of your containers folder with the follow
|
|
205
261
|
- `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/actionTypes.js`
|
206
262
|
- `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/constants.js`
|
207
263
|
- `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}Reducer.js`
|
208
|
-
|
209
|
-
|
210
|
-
|
264
|
+
###### <a href="#reduxrails-">Back to top</a>
|
211
265
|
## Development
|
212
266
|
|
213
267
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
214
268
|
|
215
269
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
216
|
-
|
270
|
+
###### <a href="#reduxrails-">Back to top</a>
|
217
271
|
## Contributing
|
218
272
|
|
219
273
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Luke-Popwell/redux_rails.
|
@@ -221,3 +275,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Luke-P
|
|
221
275
|
## License
|
222
276
|
|
223
277
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
278
|
+
###### <a href="#reduxrails-">Back to top</a>
|
@@ -11,10 +11,10 @@ class ContainerGenerator < Rails::Generators::NamedBase
|
|
11
11
|
create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/#{name}.js",
|
12
12
|
"import * as actions from './actions';
|
13
13
|
import * as constants from './constants';
|
14
|
-
import #{name}Reducer from '
|
14
|
+
import #{name}Reducer from './#{name}Reducer';
|
15
15
|
|
16
16
|
export default { actions, constants, #{name}Reducer };"
|
17
|
-
create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/
|
17
|
+
create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/actions.js",
|
18
18
|
"// import {} from './constants';
|
19
19
|
//import * as t from './actionTypes';
|
20
20
|
|
@@ -39,7 +39,7 @@ export default #{name}Reducer;"
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def add_namedReducer_to_reducer
|
42
|
-
inject_into_file "app/javascript/src/#{install_folder_name}/reducer.js", "import #{name}Reducer from './containers/#{name}/#{name}.js'\n", :after => "import { combineReducers } from 'redux'\n"
|
42
|
+
inject_into_file "app/javascript/src/#{install_folder_name}/reducer.js", "import #{name}Reducer from './containers/#{name}/#{name}Reducer.js'\n", :after => "import { combineReducers } from 'redux'\n"
|
43
43
|
|
44
44
|
inject_into_file "app/javascript/src/#{install_folder_name}/reducer.js", " #{name}Reducer,\n", :after => "const rootReducer = combineReducers({\n"
|
45
45
|
end
|
data/lib/redux_rails/version.rb
CHANGED