rwr-redux 0.4.0 → 0.5.0
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/.travis.yml +36 -0
- data/CHANGELOG.md +3 -0
- data/js/src/integrations/redux-container.js +10 -11
- data/js/src/version.js +1 -1
- data/js/test/integrations/redux-container.spec.js +30 -9
- data/lib/react_webpack_rails/redux_integration/services/redux_container.rb +1 -1
- data/lib/react_webpack_rails/redux_integration/services/redux_element.rb +3 -2
- data/lib/react_webpack_rails/redux_integration/version.rb +1 -1
- data/lib/react_webpack_rails/redux_integration/view_helpers.rb +4 -4
- data/package.json +4 -4
- data/redux_integration.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50f41380d2060a620d37eb31a11264e40914c233
|
4
|
+
data.tar.gz: 9265820c4fa8ec67b0db8288b94ded5401df805f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f85aa615b4956186a80d980b1f11ce6af9f5736121406179dc370c1016a559b060dd939bda192e81614cba3eaa8e5ddd0e4f86eda39f25533449ff47c2d9f837
|
7
|
+
data.tar.gz: 1f8e40644371cc5e856300842a9499505f19e9a9d02ca3f00ddf8d397556a7d9bf3a1aae2fa50be5aebb41cd9dff117404355c90536d4bf66f9512cb52fc0c03
|
data/.travis.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
branches:
|
2
|
+
except:
|
3
|
+
- docs
|
4
|
+
|
5
|
+
language: ruby
|
6
|
+
|
7
|
+
cache:
|
8
|
+
bundler: true
|
9
|
+
directories:
|
10
|
+
- node_modules
|
11
|
+
- spec/rails4_dummy_app/node_modules
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
include:
|
15
|
+
- rvm: 2.2.4
|
16
|
+
gemfile: spec/rails4_dummy_app/Gemfile
|
17
|
+
env: TEST_SUITE=rails4
|
18
|
+
- rvm: 2.2.4
|
19
|
+
gemfile: Gemfile
|
20
|
+
env: TEST_SUITE=gem
|
21
|
+
- rvm: 2.2.4
|
22
|
+
env: TEST_SUITE=node
|
23
|
+
|
24
|
+
before_script:
|
25
|
+
- nvm install 4.1
|
26
|
+
- nvm use 4.1
|
27
|
+
- npm install -g npm@^2.0
|
28
|
+
- npm install -g webpack@^1.12.1
|
29
|
+
- bundle exec rake setup:$TEST_SUITE
|
30
|
+
- 'export CHROME_BIN=chromium-browser'
|
31
|
+
- "export DISPLAY=:99.0" # Setup display for selenium driver
|
32
|
+
- "sh -e /etc/init.d/xvfb start"
|
33
|
+
- sleep 4 # give xvfb some time to start
|
34
|
+
|
35
|
+
script:
|
36
|
+
- bundle exec rake test:$TEST_SUITE
|
data/CHANGELOG.md
CHANGED
@@ -26,20 +26,20 @@ class ReduxContainer {
|
|
26
26
|
return this.containers[name];
|
27
27
|
}
|
28
28
|
|
29
|
-
createContainer(name) {
|
29
|
+
createContainer(name, props) {
|
30
30
|
const constructor = this.getContainer(name);
|
31
|
-
return createElement(constructor);
|
31
|
+
return createElement(constructor, props);
|
32
32
|
}
|
33
33
|
|
34
|
-
createRootComponent(name, storeName) {
|
35
|
-
const container = this.createContainer(name);
|
34
|
+
createRootComponent(name, { props, storeName }) {
|
35
|
+
const container = this.createContainer(name, props);
|
36
36
|
const store = ReduxStore.getStore(storeName);
|
37
37
|
|
38
38
|
return createElement(Provider, { store }, container);
|
39
39
|
}
|
40
40
|
|
41
|
-
renderContainer(name,
|
42
|
-
const rootComponent = this.createRootComponent(name,
|
41
|
+
renderContainer(name, payload, node) {
|
42
|
+
const rootComponent = this.createRootComponent(name, payload);
|
43
43
|
render(rootComponent, node);
|
44
44
|
}
|
45
45
|
|
@@ -47,8 +47,8 @@ class ReduxContainer {
|
|
47
47
|
unmountComponentAtNode(node);
|
48
48
|
}
|
49
49
|
|
50
|
-
renderContainerToString(name,
|
51
|
-
const rootComponent = this.createRootComponent(name,
|
50
|
+
renderContainerToString(name, payload) {
|
51
|
+
const rootComponent = this.createRootComponent(name, payload);
|
52
52
|
const result = renderToString(rootComponent);
|
53
53
|
|
54
54
|
return JSON.stringify({ body: result });
|
@@ -57,7 +57,7 @@ class ReduxContainer {
|
|
57
57
|
get integrationWrapper() {
|
58
58
|
return {
|
59
59
|
mount: function _mount(node, payload) {
|
60
|
-
this.renderContainer(payload.name,
|
60
|
+
this.renderContainer(payload.name, payload, node);
|
61
61
|
}.bind(this),
|
62
62
|
|
63
63
|
unmount: function _unmount(node) {
|
@@ -65,8 +65,7 @@ class ReduxContainer {
|
|
65
65
|
}.bind(this),
|
66
66
|
|
67
67
|
nodeRun: function _prerender(payload) {
|
68
|
-
|
69
|
-
return this.renderContainerToString(name, storeName);
|
68
|
+
return this.renderContainerToString(payload.name, payload);
|
70
69
|
}.bind(this),
|
71
70
|
};
|
72
71
|
}
|
data/js/src/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export default '0.
|
1
|
+
export default '0.5.0';
|
@@ -57,7 +57,7 @@ describe('ReduxContainer', function () {
|
|
57
57
|
describe('#createContainer', function () {
|
58
58
|
it('creates redux container', function () {
|
59
59
|
subject.registerContainer('AppContainer', AppContainer);
|
60
|
-
const container = subject.createContainer('AppContainer');
|
60
|
+
const container = subject.createContainer('AppContainer', { points: 2 });
|
61
61
|
|
62
62
|
expect(React.isValidElement(container)).toBe(true);
|
63
63
|
expect(container.type).toBe(AppContainer);
|
@@ -67,11 +67,18 @@ describe('ReduxContainer', function () {
|
|
67
67
|
describe('#createRootComponent', function () {
|
68
68
|
it('creates redux root component', function () {
|
69
69
|
const initialState = { fake: 'state' };
|
70
|
+
const payload = {
|
71
|
+
name: 'ContainerName',
|
72
|
+
props: { points: 2 },
|
73
|
+
storeName: 'StoreName',
|
74
|
+
};
|
75
|
+
|
70
76
|
ReduxStore.registerStore('StoreName', store);
|
71
77
|
ReduxStore.mountStore('StoreName', initialState);
|
72
78
|
|
73
79
|
subject.registerContainer('AppContainer', AppContainer);
|
74
|
-
const rootComponent = subject.createRootComponent(
|
80
|
+
const rootComponent = subject.createRootComponent(
|
81
|
+
payload.name, payload);
|
75
82
|
|
76
83
|
expect(React.isValidElement(rootComponent)).toBe(true);
|
77
84
|
});
|
@@ -81,11 +88,16 @@ describe('ReduxContainer', function () {
|
|
81
88
|
it('calls #createRootComponent and ReactDOM.render functions', function () {
|
82
89
|
const subjectSpy = spyOn(subject, 'createRootComponent');
|
83
90
|
const reactSpy = spyOn(ReactDOM, 'render');
|
91
|
+
const payload = {
|
92
|
+
name: 'ContainerName',
|
93
|
+
props: { points: 2 },
|
94
|
+
storeName: 'StoreName',
|
95
|
+
};
|
84
96
|
|
85
|
-
subject.renderContainer(
|
97
|
+
subject.renderContainer(payload.name, payload, 'node');
|
86
98
|
|
87
99
|
expect(subjectSpy.calls.length).toEqual(1);
|
88
|
-
expect(subjectSpy).toHaveBeenCalledWith(
|
100
|
+
expect(subjectSpy).toHaveBeenCalledWith(payload.name, payload);
|
89
101
|
expect(reactSpy.calls.length).toEqual(1);
|
90
102
|
});
|
91
103
|
});
|
@@ -106,11 +118,16 @@ describe('ReduxContainer', function () {
|
|
106
118
|
it('calls #createRootComponent and ReactDOM.renderToString', function () {
|
107
119
|
const subjectSpy = spyOn(subject, 'createRootComponent');
|
108
120
|
const reactSpy = spyOn(ReactDOMServer, 'renderToString');
|
121
|
+
const payload = {
|
122
|
+
name: 'ContainerName',
|
123
|
+
props: { points: 2 },
|
124
|
+
storeName: 'StoreName',
|
125
|
+
};
|
109
126
|
|
110
|
-
subject.renderContainerToString(
|
127
|
+
subject.renderContainerToString(payload.name, payload);
|
111
128
|
|
112
129
|
expect(subjectSpy.calls.length).toEqual(1);
|
113
|
-
expect(subjectSpy).toHaveBeenCalledWith(
|
130
|
+
expect(subjectSpy).toHaveBeenCalledWith(payload.name, payload);
|
114
131
|
expect(reactSpy.calls.length).toEqual(1);
|
115
132
|
});
|
116
133
|
|
@@ -128,7 +145,11 @@ describe('ReduxContainer', function () {
|
|
128
145
|
|
129
146
|
describe('#integrationWrapper', function () {
|
130
147
|
const node = { nodeType: 1, nodeName: 'DIV' };
|
131
|
-
const payload = {
|
148
|
+
const payload = {
|
149
|
+
name: 'ContainerName',
|
150
|
+
props: { points: 2 },
|
151
|
+
storeName: 'StoreName',
|
152
|
+
};
|
132
153
|
|
133
154
|
describe('mount', function () {
|
134
155
|
it('calls #renderContainer', function () {
|
@@ -136,7 +157,7 @@ describe('ReduxContainer', function () {
|
|
136
157
|
subject.integrationWrapper.mount(node, payload);
|
137
158
|
|
138
159
|
expect(mountSpy.calls.length).toEqual(1);
|
139
|
-
expect(mountSpy).toHaveBeenCalledWith(payload.name,
|
160
|
+
expect(mountSpy).toHaveBeenCalledWith(payload.name, payload, node);
|
140
161
|
});
|
141
162
|
});
|
142
163
|
|
@@ -156,7 +177,7 @@ describe('ReduxContainer', function () {
|
|
156
177
|
subject.integrationWrapper.nodeRun(payload);
|
157
178
|
|
158
179
|
expect(nodeRunSpy.calls.length).toEqual(1);
|
159
|
-
expect(nodeRunSpy).toHaveBeenCalledWith(payload.name, payload
|
180
|
+
expect(nodeRunSpy).toHaveBeenCalledWith(payload.name, payload);
|
160
181
|
});
|
161
182
|
});
|
162
183
|
});
|
@@ -5,6 +5,7 @@ module ReactWebpackRails
|
|
5
5
|
def initialize(integration_name, element_name, base_options, path = nil)
|
6
6
|
@integration_name = integration_name
|
7
7
|
@element_name = element_name
|
8
|
+
@props = base_options[:props]
|
8
9
|
@store_name = base_options[:store_name]
|
9
10
|
@server_side = base_options[:server_side]
|
10
11
|
@base_options = base_options
|
@@ -17,12 +18,12 @@ module ReactWebpackRails
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def options
|
20
|
-
base_options.except(:store_name, :server_side)
|
21
|
+
base_options.except(:props, :store_name, :server_side)
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
attr_reader :integration_name, :element_name, :store_name, :server_side, :base_options, :path
|
26
|
+
attr_reader :integration_name, :element_name, :store_name, :server_side, :base_options, :path, :props
|
26
27
|
|
27
28
|
def node_integration
|
28
29
|
NodeIntegrationRunner.new(integration_name, payload).run
|
@@ -11,13 +11,13 @@ module ReactWebpackRails
|
|
11
11
|
NodeIntegrationRunner.new('redux-store', name: name, props: props).run
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
rwr_element('redux-store', { name: name, props: props }, options)
|
15
15
|
end
|
16
16
|
|
17
17
|
def redux_container(name, options = {})
|
18
18
|
container = Services::ReduxContainer.new('redux-container', name, options)
|
19
19
|
|
20
|
-
|
20
|
+
rwr_element('redux-container', container.payload, container.options) do
|
21
21
|
container.result['body'].html_safe
|
22
22
|
end
|
23
23
|
end
|
@@ -26,7 +26,7 @@ module ReactWebpackRails
|
|
26
26
|
router = Services::ReduxRouter.new('redux-router', name, options, request.path)
|
27
27
|
result = handle_response_code(router.result, name, request.path)
|
28
28
|
|
29
|
-
|
29
|
+
rwr_element('redux-router', router.payload, router.options) do
|
30
30
|
result
|
31
31
|
end
|
32
32
|
end
|
@@ -46,7 +46,7 @@ module ReactWebpackRails
|
|
46
46
|
when 302
|
47
47
|
controller.redirect_to(result['redirectUri'])
|
48
48
|
else
|
49
|
-
raise ActionController::RoutingError
|
49
|
+
raise ActionController::RoutingError.new(routing_error(name, path))
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "rwr-redux",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.0",
|
4
4
|
"description": "Redux integration for react_webpack_rails",
|
5
5
|
"main": "js/lib/index.js",
|
6
6
|
"files": [
|
@@ -31,9 +31,9 @@
|
|
31
31
|
"homepage": "https://github.com/netguru/rwr-redux",
|
32
32
|
"dependencies": {
|
33
33
|
"react-redux": "^4.4.5",
|
34
|
-
"react-router": "^2.
|
35
|
-
"react-router-redux": "^4.0.
|
36
|
-
"react-webpack-rails": "^0.
|
34
|
+
"react-router": "^2.6.1",
|
35
|
+
"react-router-redux": "^4.0.5",
|
36
|
+
"react-webpack-rails": "^0.5.0",
|
37
37
|
"redux": "^3.5.2"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
data/redux_integration.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwr-redux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kacper Goliński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
76
|
+
version: 0.5.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.
|
83
|
+
version: 0.5.0
|
84
84
|
description: Redux integration for react_webpack_rails
|
85
85
|
email:
|
86
86
|
- react@netguru.co
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- ".eslintrc"
|
93
93
|
- ".gitignore"
|
94
94
|
- ".rubocop.yml"
|
95
|
+
- ".travis.yml"
|
95
96
|
- CHANGELOG.md
|
96
97
|
- Gemfile
|
97
98
|
- LICENSE.txt
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
145
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.5.1
|
146
147
|
signing_key:
|
147
148
|
specification_version: 4
|
148
149
|
summary: Redux integration for react_webpack_rails
|