reactive_rails_generator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c670c4b33f14daa908bb101784813d83d513adc8
|
4
|
+
data.tar.gz: 52b100d8fd125f8aaaa761d622b543a6ddaec17e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e23abb5ea7e1f92ff1e0c40ec90e0b0efda77f6f145baeb8a0bc885c42e91336913d0927a52622edf74b97134463f70635e6fef4c368182d9f5d0d40aa91fe2
|
7
|
+
data.tar.gz: 733070925fcd826ef5680d7abbec2edb840810922ac153a4f75bac303f2ced0f5beba299440ff7ed958b939b16aef5e2aeeb7f7685c85e79aa234c33aa3a300e
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
module Reactrb
|
3
|
+
class Component < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
argument :components, :type => :array
|
7
|
+
def create_component_file()
|
8
|
+
self.components.each do |component|
|
9
|
+
component_array = component.split("::")
|
10
|
+
@modules = component_array[0..-2]
|
11
|
+
@file_name = component_array.last
|
12
|
+
@indet = 1
|
13
|
+
template "component_template.rb", File.join('app/react/components', @modules.join("/"), "#{@file_name.underscore}.rb")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
module Reactrb
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
class_option :"reactive-record", :type => :boolean
|
5
|
+
class_option :"opal-jquery", :type => :boolean
|
6
|
+
class_option :"reactive-router", :type => :boolean
|
7
|
+
class_option :all, :type => :boolean
|
8
|
+
|
9
|
+
def inject_react_file_js
|
10
|
+
inject_into_file 'app/assets/javascripts/application.js', after: "// about supported directives.\n" do <<-'RUBY'
|
11
|
+
//= require 'components'
|
12
|
+
//= require 'react_ujs'
|
13
|
+
RUBY
|
14
|
+
end
|
15
|
+
|
16
|
+
if options[:"opal-jquery"] || options[:all]
|
17
|
+
inject_into_file 'app/assets/javascripts/application.js', after: "//= require jquery_ujs\n" do <<-'RUBY'
|
18
|
+
//= require 'opal-jquery'
|
19
|
+
RUBY
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def inject_engine_to_routes
|
26
|
+
if options[:"reactive-record"] || options[:all]
|
27
|
+
route "mount ReactiveRecord::Engine => \"/rr\""
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_components_directory
|
32
|
+
create_file "app/react/components/.keep", ""
|
33
|
+
create_file "app/react/models/.keep", "" if options[:"reactive-record"] || options[:all]
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_manifests
|
37
|
+
create_file "app/react/components.rb", <<-FILE
|
38
|
+
# app/react/components.rb
|
39
|
+
require 'opal'
|
40
|
+
require 'reactive-ruby'
|
41
|
+
#{"require 'reactive-router'" if options[:"reactive-router"] || options[:all]}
|
42
|
+
#{"require 'reactive-record'" if options[:"reactive-record"] || options[:all]}
|
43
|
+
#{"require 'models'" if options[:"reactive-record"] || options[:all]}
|
44
|
+
require_tree './components'
|
45
|
+
FILE
|
46
|
+
|
47
|
+
if options[:"reactive-record"] || options[:all]
|
48
|
+
create_file "app/react/models.rb", <<-FILE
|
49
|
+
# app/react/components.rb
|
50
|
+
require_tree './models'
|
51
|
+
FILE
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_gems
|
56
|
+
gem 'reactive-ruby'
|
57
|
+
gem 'react-rails', '~> 1.3.0'
|
58
|
+
gem 'opal-rails', '>= 0.8.1'
|
59
|
+
gem 'therubyracer', platforms: :ruby
|
60
|
+
|
61
|
+
# optional gems
|
62
|
+
gem 'opal-jquery' if options[:"opal-jquery"] || options[:all]
|
63
|
+
gem 'reactive-router' if options[:"reactive-router"] || options[:all]
|
64
|
+
gem 'reactive-record' if options[:"reactive-record"] || options[:all]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Components
|
2
|
+
<%- @modules.each do |module_name| %><%= " "* @indet %>module <%= module_name.camelize %><%- @indet += 1 %>
|
3
|
+
<%- end %><%=" "* @indet %>class <%= @file_name %> < React::Component::Base
|
4
|
+
<%=" "* @indet %># param :my_param
|
5
|
+
|
6
|
+
<%=" "* @indet %>def render
|
7
|
+
<%=" "* @indet %> # div do
|
8
|
+
<%=" "* @indet %> # "Some display code"
|
9
|
+
<%=" "* @indet %> # end
|
10
|
+
<%=" "* @indet %>end
|
11
|
+
<%=" "* @indet %>end
|
12
|
+
<%- @modules.each do %><%- @indet -= 1 %><%=" "* @indet %>end
|
13
|
+
<%- end %>end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reactive_rails_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Loic Boutet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
description: This gem provide rails generators for react.rb
|
28
|
+
email: loic@boutet.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/generators/reactrb/component_generator.rb
|
34
|
+
- lib/generators/reactrb/install_generator.rb
|
35
|
+
- lib/generators/reactrb/templates/component_template.rb
|
36
|
+
- lib/reactive_rails_generator.rb
|
37
|
+
homepage: http://rubygems.org/gems/hola
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.4.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: React.rb generators for rails
|
61
|
+
test_files: []
|