react-rails 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/assets/javascripts/react_ujs.js +10 -3
- data/lib/generators/react/component_generator.rb +28 -2
- data/lib/generators/templates/component.es6.jsx +2 -1
- data/lib/generators/templates/component.js.jsx +2 -1
- data/lib/generators/templates/component.js.jsx.coffee +2 -2
- data/lib/react/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37de0baf50c91ac20c61f03afd79b0538dce4588
|
4
|
+
data.tar.gz: c04e9318f7675006a78be2339cc1a38de92f3b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f328fdff77009184e2b682ddab263faf7714e17fcac5b7dff9d56fa79ada9f1b8e7fb160b4fe5e8b279277962dad469257097948cdb0300c4eee147857c0428
|
7
|
+
data.tar.gz: 06ec30fbde19289622ecc7aa76ce7254e10f18e6c038746beb2efb7b50ad11d07fb9ea87ecca4ec9443f772a49404a891f44fe84f2b7cbb18f6a3301649ce7f8
|
data/CHANGELOG.md
CHANGED
@@ -8,7 +8,19 @@
|
|
8
8
|
|
9
9
|
#### Bug Fixes
|
10
10
|
|
11
|
-
## 2.0
|
11
|
+
## 2.2.0
|
12
|
+
|
13
|
+
#### New Features
|
14
|
+
|
15
|
+
- Improve error handling when components aren't found #704
|
16
|
+
|
17
|
+
#### Bug Fixes
|
18
|
+
|
19
|
+
- Camelize filename when generating for webpack #703
|
20
|
+
- Include node module boilerplate when generating for webpack #710
|
21
|
+
- Don't look for non-existent `Turbolinks.EVENTS` #708
|
22
|
+
|
23
|
+
## 2.1.0 (April 18, 2017)
|
12
24
|
|
13
25
|
#### New Features
|
14
26
|
|
@@ -119,7 +119,9 @@ var turbolinksClassicEvents = __webpack_require__(10)
|
|
119
119
|
module.exports = function(ujs) {
|
120
120
|
if (ujs.handleEvent) {
|
121
121
|
// We're calling this a second time -- remove previous handlers
|
122
|
-
|
122
|
+
if (typeof Turbolinks.EVENTS !== "undefined") {
|
123
|
+
turbolinksClassicEvents.teardown(ujs);
|
124
|
+
}
|
123
125
|
turbolinksEvents.teardown(ujs);
|
124
126
|
turbolinksClassicDeprecatedEvents.teardown(ujs);
|
125
127
|
pjaxEvents.teardown(ujs);
|
@@ -185,9 +187,14 @@ module.exports = function(reqctx) {
|
|
185
187
|
try {
|
186
188
|
// `require` will raise an error if this className isn't found:
|
187
189
|
component = fromCtx(className)
|
188
|
-
} catch (
|
190
|
+
} catch (firstErr) {
|
189
191
|
// fallback to global:
|
190
|
-
|
192
|
+
try {
|
193
|
+
component = fromGlobal(className)
|
194
|
+
} catch (secondErr) {
|
195
|
+
console.error(firstErr)
|
196
|
+
console.error(secondErr)
|
197
|
+
}
|
191
198
|
}
|
192
199
|
return component
|
193
200
|
}
|
@@ -100,23 +100,49 @@ module React
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# Prefer webpacker to sprockets:
|
103
|
-
if
|
103
|
+
if webpacker?
|
104
|
+
new_file_name = file_name.camelize
|
104
105
|
extension = options[:coffee] ? "coffee" : "js"
|
105
106
|
target_dir = Webpacker::Configuration.source_path
|
106
107
|
.join("components")
|
107
108
|
.relative_path_from(::Rails.root)
|
108
109
|
.to_s
|
109
110
|
else
|
111
|
+
new_file_name = file_name
|
110
112
|
extension = template_extension
|
111
113
|
target_dir = 'app/assets/javascripts/components'
|
112
114
|
end
|
113
115
|
|
114
|
-
file_path = File.join(target_dir, "#{
|
116
|
+
file_path = File.join(target_dir, "#{new_file_name}.#{extension}")
|
115
117
|
template("component.#{template_extension}", file_path)
|
116
118
|
end
|
117
119
|
|
118
120
|
private
|
119
121
|
|
122
|
+
def component_name
|
123
|
+
file_name.camelize
|
124
|
+
end
|
125
|
+
|
126
|
+
def file_header
|
127
|
+
if webpacker?
|
128
|
+
%|var React = require("react")\n|
|
129
|
+
else
|
130
|
+
""
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def file_footer
|
135
|
+
if webpacker?
|
136
|
+
%|module.exports = #{component_name}|
|
137
|
+
else
|
138
|
+
""
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def webpacker?
|
143
|
+
defined?(Webpacker)
|
144
|
+
end
|
145
|
+
|
120
146
|
def parse_attributes!
|
121
147
|
self.attributes = (attributes || []).map do |attr|
|
122
148
|
name, type, options = "", "", ""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class <%=
|
1
|
+
<%= file_header %>class <%= component_name %> extends React.Component {
|
2
2
|
render () {
|
3
3
|
<% if attributes.size > 0 -%>
|
4
4
|
return (
|
@@ -21,3 +21,4 @@ class <%= file_name.camelize %> extends React.Component {
|
|
21
21
|
<% end -%>
|
22
22
|
};
|
23
23
|
<% end -%>
|
24
|
+
<%= file_footer %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var <%=
|
1
|
+
<%= file_header %>var <%= component_name %> = React.createClass({
|
2
2
|
<% if attributes.size > 0 -%>
|
3
3
|
propTypes: {
|
4
4
|
<% attributes.each_with_index do |attribute, idx| -%>
|
@@ -21,3 +21,4 @@ var <%= file_name.camelize %> = React.createClass({
|
|
21
21
|
<% end -%>
|
22
22
|
}
|
23
23
|
});
|
24
|
+
<%= file_footer %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class @<%=
|
1
|
+
class @<%= component_name %> extends React.Component
|
2
2
|
<% if attributes.size > 0 -%>
|
3
3
|
@propTypes =
|
4
4
|
<% attributes.each do |attribute| -%>
|
@@ -15,4 +15,4 @@ class @<%= file_name.camelize %> extends React.Component
|
|
15
15
|
</div>`
|
16
16
|
<% else -%>
|
17
17
|
`<div />`
|
18
|
-
<% end -%>
|
18
|
+
<% end -%>
|
data/lib/react/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul O’Shannessy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appraisal
|
@@ -326,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
326
|
version: '0'
|
327
327
|
requirements: []
|
328
328
|
rubyforge_project:
|
329
|
-
rubygems_version: 2.
|
329
|
+
rubygems_version: 2.6.11
|
330
330
|
signing_key:
|
331
331
|
specification_version: 4
|
332
332
|
summary: React integration for Ruby on Rails
|