render-react 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -21
- data/lib/render/react/version.rb +1 -1
- data/render-react.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0601736fa6ccfc71f59c1b6b4917615d23ad10ce
|
4
|
+
data.tar.gz: c424e643224f08d78117d85ba5b1f6a9b3b5cd8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7fb9e86dd55826c6984beb8ee247450d6d4c8e50c03d732a589d3537f806bb2c4ac3eef0c3604e5613f2660f7c21308606edf2eaab88720ea5ea8235cf9f81c
|
7
|
+
data.tar.gz: 7257db251438a7b46d1913dc145aa0aed6e1361fb5dd48cb0313a543ac4b9dfecbc092bf8732670f39c4978fb3d8b8508a3116cdc1b948895c808e95ab74a1e2
|
data/README.md
CHANGED
@@ -1,41 +1,75 @@
|
|
1
|
-
|
1
|
+
### Work in progress, please beware.
|
2
2
|
|
3
|
-
|
3
|
+
## Overview
|
4
|
+
This gem renders [React](https://facebook.github.io/react/) components into your views!
|
4
5
|
|
5
|
-
|
6
|
+
It's plain Ruby so you can use it with almost every Ruby framework out there.
|
6
7
|
|
7
|
-
##
|
8
|
+
## Design
|
9
|
+
It uses [V8 engine](https://developers.google.com/v8/) as dynamic library for JavaScript execution. On application load React components are discovered, compiled from ES6 to ES5 and executed into memory. When you call `render_react` from your view - rendering is done from preloaded components at speeds comparable to native Ruby partials.
|
8
10
|
|
9
|
-
|
11
|
+
## Installation
|
12
|
+
Just add render-react to your Gemfile and you're done.
|
13
|
+
```bash
|
14
|
+
echo 'gem render-react' >> Gemfile
|
15
|
+
bundle install
|
16
|
+
```
|
10
17
|
|
18
|
+
## Usage (Rails)
|
19
|
+
1. Include Render::React into your ApplicationHelper
|
11
20
|
```ruby
|
12
|
-
|
21
|
+
module ApplicationHelper
|
22
|
+
include Render::React
|
23
|
+
...
|
13
24
|
```
|
14
25
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
2. Create initializer config/initializers/render_react.rb
|
27
|
+
```ruby
|
28
|
+
Render::React::Config.path File.join(Rails.root, 'app/assets/javascripts/components-local')
|
29
|
+
Render::React::Config.path File.join(Rails.root, 'some/other/directory')
|
30
|
+
```
|
31
|
+
or
|
32
|
+
```ruby
|
33
|
+
Render::React::Config.path(
|
34
|
+
File.join(Rails.root, 'app/assets/javascripts/components-other'),
|
35
|
+
File.join(Rails.root, 'some/other/directory')
|
36
|
+
)
|
37
|
+
```
|
24
38
|
|
25
|
-
|
39
|
+
3. Render react component into your view (e.g. slim):
|
40
|
+
```ruby
|
41
|
+
== render_react 'Card', \
|
42
|
+
className: 'city-block swiper-slide', \
|
43
|
+
href: city_path(city.slug), \
|
44
|
+
text: city.location, \
|
45
|
+
name: city.name, \
|
46
|
+
cover: image_path(city.cover.square_thumb), \
|
47
|
+
count: city.compilations.length
|
48
|
+
```
|
26
49
|
|
27
|
-
##
|
50
|
+
## Debugging
|
51
|
+
To be sure that everything is tip-top.
|
28
52
|
|
29
|
-
|
53
|
+
In terms of rendering time:
|
54
|
+
```ruby
|
55
|
+
- start = Time.now
|
56
|
+
== render_react 'ComponentName', \
|
57
|
+
className: 'city-block swiper-slide', \
|
58
|
+
...
|
59
|
+
- finish = Time.now
|
60
|
+
- Rails.logger.warn "Render::React durability: #{Render::React::Compiler.instance_variable_get(:@durability)} time: #{finish - start}"
|
61
|
+
```
|
30
62
|
|
31
|
-
|
63
|
+
In terms of memory.
|
64
|
+
```bash
|
65
|
+
ps x -o rss,command | grep "unicorn" | grep -v grep | sort
|
66
|
+
```
|
32
67
|
|
33
68
|
## Contributing
|
34
69
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
70
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rambler-digital-solutions/render-react. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
71
|
|
37
72
|
|
38
73
|
## License
|
39
74
|
|
40
75
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/render/react/version.rb
CHANGED
data/render-react.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Alexander Krasnoschekov"]
|
10
10
|
spec.email = ["akrasnoschekov@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = "
|
13
|
-
spec.homepage = "https://
|
12
|
+
spec.summary = "Renders React.js components into your Ruby views"
|
13
|
+
spec.homepage = "https://github.com/rambler-digital-solutions/render-react"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render-react
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Krasnoschekov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: therubyracer
|
@@ -107,7 +107,7 @@ files:
|
|
107
107
|
- lib/render/react/transpiler.rb
|
108
108
|
- lib/render/react/version.rb
|
109
109
|
- render-react.gemspec
|
110
|
-
homepage: https://
|
110
|
+
homepage: https://github.com/rambler-digital-solutions/render-react
|
111
111
|
licenses:
|
112
112
|
- MIT
|
113
113
|
metadata: {}
|
@@ -130,5 +130,5 @@ rubyforge_project:
|
|
130
130
|
rubygems_version: 2.5.1
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
|
-
summary:
|
133
|
+
summary: Renders React.js components into your Ruby views
|
134
134
|
test_files: []
|