reactive_rails_generator 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 261804c681fdc92a75b361581d50b3dc8c1f5e3a
4
- data.tar.gz: f5b6ba12186b4682a3289e98c683b3752e840bb5
3
+ metadata.gz: dd400b8d05f2940350b712ef6d59e33c3fb454a9
4
+ data.tar.gz: 6846868648782263335a299501f55ab2d4acfd8f
5
5
  SHA512:
6
- metadata.gz: ebb8d0deb79fb6b62498482aa7c4bbb2694cd3e2c29f9ffadf7b8a7736069f96135bf7eaaa4a4945c6209c6fff5fc9fce2d1ab3389105801ac745cd154864fe6
7
- data.tar.gz: b345cd8d5410ddebb8f231bd6b2eff4982158c8950334a3adf3c63d466e1ea8e22bfcec8f8ff57e38c6a53dc95ff125dafcd7c2a764bfc386f614492e2d6cf7f
6
+ metadata.gz: dce3d4e680b0878f56a7ded3b35746730e291c018ed424d31ae93fc99b4e685bb0c69c6624824988859520ccc18e8222d6cd6e59847c860c4eb76d8e17f5b0af
7
+ data.tar.gz: e9c20199e2aa797378ee630c988085ee90b28076fbc82680e1867ddf800fcc972e01319336ab8ac35ba5742d453efe8929648d7fe5fdf0508faa9dd6a211c137
@@ -16,6 +16,3 @@ module Reactrb
16
16
 
17
17
  end
18
18
  end
19
-
20
-
21
-
@@ -9,7 +9,6 @@ module Reactrb
9
9
  def inject_react_file_js
10
10
  inject_into_file 'app/assets/javascripts/application.js', after: "// about supported directives.\n" do <<-'JS'
11
11
  //= require 'components'
12
- //= require 'react'
13
12
  //= require 'react_ujs'
14
13
  JS
15
14
  end
@@ -36,14 +35,15 @@ JS
36
35
  # app/react/components.rb
37
36
  require 'opal'
38
37
  require 'reactive-ruby'
38
+ require 'react'
39
39
  if React::IsomorphicHelpers.on_opal_client?
40
40
  require 'opal-jquery'
41
41
  require 'browser'
42
42
  require 'browser/interval'
43
43
  require 'browser/delay'
44
- # add any requires that can ONLY run on client here
44
+ # add any additional requires that can ONLY run on client here
45
45
  end
46
- #{"require 'reactive-router'" if options[:"reactive-router"] || options[:all]}
46
+ #{"require 'reactive-router'\nrequire 'react_router'" if options[:"reactive-router"] || options[:all]}
47
47
  #{"require 'reactive-record'" if options[:"reactive-record"] || options[:all]}
48
48
  #{"require 'models'" if options[:"reactive-record"] || options[:all]}
49
49
  require_tree './components'
@@ -74,7 +74,10 @@ require_tree './models'
74
74
  gem 'therubyracer', platforms: :ruby
75
75
 
76
76
  # optional gems
77
- gem 'reactive-router' if options[:"reactive-router"] || options[:all]
77
+ if options[:"reactive-router"] || options[:all]
78
+ gem 'react-router-rails', '~>0.13.3'
79
+ gem 'reactive-router'
80
+ end
78
81
  gem 'reactive-record' if options[:"reactive-record"] || options[:all]
79
82
  end
80
83
  end
@@ -1,12 +1,40 @@
1
1
  module Components
2
2
  <%- @modules.each do |module_name| %><%= " "* @indet %>module <%= module_name.camelize %><%- @indet += 1 %>
3
3
  <%- end %><%=" "* @indet %>class <%= @file_name %> < React::Component::Base
4
+
4
5
  <%=" "* @indet %># param :my_param
6
+ <%=" "* @indet %># param param_with_default: "default value"
7
+ <%=" "* @indet %># param :param_with_default2, default: "default value" # alternative syntax
8
+ <%=" "* @indet %># param :param_with_type, type: Hash
9
+ <%=" "* @indet %># param :array_of_hashes, type: [Hash]
10
+ <%=" "* @indet %># collect_all_other_params_as :attributes #collects all other params into a hash
11
+
12
+ <%=" "* @indet %># The following are the most common lifecycle call backs,
13
+ <%=" "* @indet %># the following are the most common lifecycle call backs# delete any that you are not using.
14
+ <%=" "* @indet %># call backs may also reference an instance method i.e. before_mount :my_method
15
+
16
+ <%=" "* @indet %>before_mount do
17
+ <%=" "* @indet %> # any initialization particularly of state variables goes here.
18
+ <%=" "* @indet %> # this will execute on server (prerendering) and client.
19
+ <%=" "* @indet %>end
20
+
21
+ <%=" "* @indet %>after_mount do
22
+ <%=" "* @indet %> # any client only post rendering initialization goes here.
23
+ <%=" "* @indet %> # i.e. start timers, HTTP requests, and low level jquery operations etc.
24
+ <%=" "* @indet %>end
25
+
26
+ <%=" "* @indet %>before_update do
27
+ <%=" "* @indet %> # called whenever a component will be re-rerendered
28
+ <%=" "* @indet %>end
29
+
30
+ <%=" "* @indet %>before_unmount do
31
+ <%=" "* @indet %> # cleanup any thing (i.e. timers) before component is destroyed
32
+ <%=" "* @indet %>end
5
33
 
6
34
  <%=" "* @indet %>def render
7
- <%=" "* @indet %> # div do
8
- <%=" "* @indet %> # "Some display code"
9
- <%=" "* @indet %> # end
35
+ <%=" "* @indet %> div do
36
+ <%=" "* @indet %> "<%= (@modules+[@file_name]).join('::') %>"
37
+ <%=" "* @indet %> end
10
38
  <%=" "* @indet %>end
11
39
  <%=" "* @indet %>end
12
40
  <%- @modules.each do %><%- @indet -= 1 %><%=" "* @indet %>end
@@ -1,3 +1,4 @@
1
1
  require 'rails/generators'
2
2
  require "generators/reactrb/install_generator"
3
3
  require "generators/reactrb/component_generator"
4
+ require "generators/reactrb/router_generator"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_rails_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loic Boutet