hyper-react 0.10.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 +7 -0
- data/.codeclimate.yml +27 -0
- data/.gitignore +36 -0
- data/.rubocop.yml +1159 -0
- data/.travis.yml +29 -0
- data/Appraisals +20 -0
- data/CHANGELOG.md +93 -0
- data/Gemfile +6 -0
- data/LICENSE +19 -0
- data/README.md +121 -0
- data/Rakefile +33 -0
- data/UPGRADING.md +24 -0
- data/component-name-lookup.md +145 -0
- data/config.ru +25 -0
- data/gemfiles/opal_0.8_react_13.gemfile +13 -0
- data/gemfiles/opal_0.8_react_14.gemfile +13 -0
- data/gemfiles/opal_0.8_react_15.gemfile +13 -0
- data/gemfiles/opal_0.9_react_13.gemfile +13 -0
- data/gemfiles/opal_0.9_react_14.gemfile +13 -0
- data/gemfiles/opal_0.9_react_15.gemfile +13 -0
- data/hyper-react.gemspec +43 -0
- data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/components.rb +4 -0
- data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/test_application.rb +2 -0
- data/lib/generators/reactive_ruby/test_app/templates/boot.rb.erb +6 -0
- data/lib/generators/reactive_ruby/test_app/templates/script/rails +5 -0
- data/lib/generators/reactive_ruby/test_app/templates/test_application.rb.erb +13 -0
- data/lib/generators/reactive_ruby/test_app/templates/views/components/hello_world.rb +11 -0
- data/lib/generators/reactive_ruby/test_app/templates/views/components/todo.rb +14 -0
- data/lib/generators/reactive_ruby/test_app/templates/views/layouts/test_layout.html.erb +0 -0
- data/lib/generators/reactive_ruby/test_app/test_app_generator.rb +109 -0
- data/lib/hyper-react.rb +52 -0
- data/lib/rails-helpers/top_level_rails_component.rb +54 -0
- data/lib/react-sources/react-server.js +2 -0
- data/lib/react/api.rb +162 -0
- data/lib/react/callbacks.rb +42 -0
- data/lib/react/children.rb +30 -0
- data/lib/react/component.rb +139 -0
- data/lib/react/component/api.rb +50 -0
- data/lib/react/component/base.rb +9 -0
- data/lib/react/component/class_methods.rb +214 -0
- data/lib/react/component/dsl_instance_methods.rb +27 -0
- data/lib/react/component/params.rb +6 -0
- data/lib/react/component/props_wrapper.rb +83 -0
- data/lib/react/component/should_component_update.rb +98 -0
- data/lib/react/component/tags.rb +144 -0
- data/lib/react/element.rb +168 -0
- data/lib/react/event.rb +76 -0
- data/lib/react/ext/hash.rb +9 -0
- data/lib/react/ext/string.rb +8 -0
- data/lib/react/hash.rb +13 -0
- data/lib/react/native_library.rb +92 -0
- data/lib/react/object.rb +15 -0
- data/lib/react/observable.rb +29 -0
- data/lib/react/react-source.rb +9 -0
- data/lib/react/rendering_context.rb +142 -0
- data/lib/react/state.rb +190 -0
- data/lib/react/test.rb +16 -0
- data/lib/react/test/dsl.rb +17 -0
- data/lib/react/test/matchers/render_html_matcher.rb +49 -0
- data/lib/react/test/rspec.rb +15 -0
- data/lib/react/test/session.rb +46 -0
- data/lib/react/top_level.rb +132 -0
- data/lib/react/validator.rb +136 -0
- data/lib/reactive-ruby/component_loader.rb +49 -0
- data/lib/reactive-ruby/isomorphic_helpers.rb +197 -0
- data/lib/reactive-ruby/rails.rb +7 -0
- data/lib/reactive-ruby/rails/component_mount.rb +46 -0
- data/lib/reactive-ruby/rails/controller_helper.rb +15 -0
- data/lib/reactive-ruby/rails/railtie.rb +14 -0
- data/lib/reactive-ruby/serializers.rb +15 -0
- data/lib/reactive-ruby/server_rendering/contextual_renderer.rb +42 -0
- data/lib/reactive-ruby/version.rb +3 -0
- data/lib/reactrb/auto-import.rb +32 -0
- data/lib/reactrb/deep-compare.rb +24 -0
- data/lib/reactrb/new-event-name-convention.rb +11 -0
- data/lib/sources/react-latest.js +21169 -0
- data/lib/sources/react-v13.js +21645 -0
- data/lib/sources/react-v14.js +20821 -0
- data/lib/sources/react-v15.js +21170 -0
- data/logo1.png +0 -0
- data/logo2.png +0 -0
- data/logo3.png +0 -0
- data/path_release_steps.md +9 -0
- data/spec/controller_helper_spec.rb +34 -0
- data/spec/index.html.erb +10 -0
- data/spec/react/callbacks_spec.rb +106 -0
- data/spec/react/children_spec.rb +76 -0
- data/spec/react/component/base_spec.rb +32 -0
- data/spec/react/component_spec.rb +872 -0
- data/spec/react/dsl_spec.rb +296 -0
- data/spec/react/element_spec.rb +136 -0
- data/spec/react/event_spec.rb +24 -0
- data/spec/react/native_library_spec.rb +344 -0
- data/spec/react/observable_spec.rb +7 -0
- data/spec/react/opal_jquery_extensions_spec.rb +66 -0
- data/spec/react/param_declaration_spec.rb +258 -0
- data/spec/react/react_spec.rb +209 -0
- data/spec/react/state_spec.rb +55 -0
- data/spec/react/test/dsl_spec.rb +43 -0
- data/spec/react/test/matchers/render_html_matcher_spec.rb +83 -0
- data/spec/react/test/rspec_spec.rb +62 -0
- data/spec/react/test/session_spec.rb +100 -0
- data/spec/react/test/utils_spec.rb +45 -0
- data/spec/react/top_level_component_spec.rb +96 -0
- data/spec/react/tutorial/tutorial_spec.rb +36 -0
- data/spec/react/validator_spec.rb +124 -0
- data/spec/reactive-ruby/component_loader_spec.rb +71 -0
- data/spec/reactive-ruby/isomorphic_helpers_spec.rb +155 -0
- data/spec/reactive-ruby/rails/asset_pipeline_spec.rb +10 -0
- data/spec/reactive-ruby/rails/component_mount_spec.rb +66 -0
- data/spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb +35 -0
- data/spec/spec_helper.rb +115 -0
- data/spec/support/react/spec_helpers.rb +64 -0
- data/spec/vendor/es5-shim.min.js +6 -0
- data/spec/vendor/jquery-2.2.4.min.js +4 -0
- metadata +387 -0
data/config.ru
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler.require
|
|
3
|
+
|
|
4
|
+
require "opal/rspec"
|
|
5
|
+
require "opal-jquery"
|
|
6
|
+
|
|
7
|
+
if Opal::RSpec.const_defined?("SprocketsEnvironment")
|
|
8
|
+
sprockets_env = Opal::RSpec::SprocketsEnvironment.new
|
|
9
|
+
sprockets_env.cache = Sprockets::Cache::FileStore.new("tmp")
|
|
10
|
+
sprockets_env.add_spec_paths_to_sprockets
|
|
11
|
+
run Opal::Server.new(sprockets: sprockets_env) { |s|
|
|
12
|
+
s.main = 'opal/rspec/sprockets_runner'
|
|
13
|
+
s.debug = false
|
|
14
|
+
s.append_path 'spec/vendor'
|
|
15
|
+
s.index_path = 'spec/index.html.erb'
|
|
16
|
+
}
|
|
17
|
+
else
|
|
18
|
+
run Opal::Server.new { |s|
|
|
19
|
+
s.main = 'opal/rspec/sprockets_runner'
|
|
20
|
+
s.append_path 'spec'
|
|
21
|
+
s.append_path 'spec/vendor'
|
|
22
|
+
s.debug = false
|
|
23
|
+
s.index_path = 'spec/index.html.erb'
|
|
24
|
+
}
|
|
25
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "opal", "~> 0.8.0"
|
|
6
|
+
gem "opal-rails", "~> 0.8.1"
|
|
7
|
+
gem "react-rails", "~> 1.3.3", :require => false
|
|
8
|
+
|
|
9
|
+
group :development do
|
|
10
|
+
gem "appraisal"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "opal", "~> 0.8.0"
|
|
6
|
+
gem "opal-rails", "~> 0.8.1"
|
|
7
|
+
gem "react-rails", "~> 1.6.2", :require => false
|
|
8
|
+
|
|
9
|
+
group :development do
|
|
10
|
+
gem "appraisal"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "opal", "~> 0.8.0"
|
|
6
|
+
gem "opal-rails", "~> 0.8.1"
|
|
7
|
+
gem "react-rails", "~> 1.8.2", :require => false
|
|
8
|
+
|
|
9
|
+
group :development do
|
|
10
|
+
gem "appraisal"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "opal", "~> 0.9.0"
|
|
6
|
+
gem "opal-rails", "~> 0.9.0"
|
|
7
|
+
gem "react-rails", "~> 1.3.3", :require => false
|
|
8
|
+
|
|
9
|
+
group :development do
|
|
10
|
+
gem "appraisal"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "opal", "~> 0.9.0"
|
|
6
|
+
gem "opal-rails", "~> 0.9.0"
|
|
7
|
+
gem "react-rails", "~> 1.6.2", :require => false
|
|
8
|
+
|
|
9
|
+
group :development do
|
|
10
|
+
gem "appraisal"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "opal", "~> 0.9.0"
|
|
6
|
+
gem "opal-rails", "~> 0.9.0"
|
|
7
|
+
gem "react-rails", "~> 1.8.2", :require => false
|
|
8
|
+
|
|
9
|
+
group :development do
|
|
10
|
+
gem "appraisal"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
gemspec :path => "../"
|
data/hyper-react.gemspec
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path('../lib/', __FILE__)
|
|
3
|
+
|
|
4
|
+
require 'reactive-ruby/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'hyper-react'
|
|
8
|
+
s.version = React::VERSION
|
|
9
|
+
|
|
10
|
+
s.authors = ['David Chang', 'Adam Jahn', 'Mitch VanDuyn']
|
|
11
|
+
s.email = 'reactrb@catprint.com'
|
|
12
|
+
s.homepage = 'http://ruby-hyperloop.io/gems/reactrb/'
|
|
13
|
+
s.summary = 'Opal Ruby wrapper of React.js library.'
|
|
14
|
+
s.license = 'MIT'
|
|
15
|
+
s.description = "Write React UI components in pure Ruby."
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
s.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
s.add_dependency 'opal', '>= 0.8.0'
|
|
22
|
+
s.add_dependency 'opal-activesupport', '>= 0.2.0'
|
|
23
|
+
s.add_dependency 'react-rails'
|
|
24
|
+
s.add_development_dependency 'rake'
|
|
25
|
+
s.add_development_dependency 'rspec-rails', '3.3.3'
|
|
26
|
+
s.add_development_dependency 'timecop'
|
|
27
|
+
s.add_development_dependency 'opal-rspec'
|
|
28
|
+
s.add_development_dependency 'sinatra'
|
|
29
|
+
s.add_development_dependency 'opal-jquery'
|
|
30
|
+
|
|
31
|
+
# For Test Rails App
|
|
32
|
+
s.add_development_dependency 'rails', '4.2.4'
|
|
33
|
+
s.add_development_dependency 'mime-types', '< 3'
|
|
34
|
+
s.add_development_dependency 'opal-rails'
|
|
35
|
+
if RUBY_PLATFORM == 'java'
|
|
36
|
+
s.add_development_dependency 'jdbc-sqlite3'
|
|
37
|
+
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
|
|
38
|
+
s.add_development_dependency 'therubyrhino'
|
|
39
|
+
else
|
|
40
|
+
s.add_development_dependency 'sqlite3', '1.3.10'
|
|
41
|
+
s.add_development_dependency 'therubyracer', '0.12.2'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% if defined? application_definition %>
|
|
2
|
+
require 'rails/all'
|
|
3
|
+
require File.expand_path('../boot', __FILE__)
|
|
4
|
+
|
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
|
6
|
+
# you've limited to :test, :development, or :production.
|
|
7
|
+
Bundler.require(*Rails.groups(assets: %w(development test)))
|
|
8
|
+
|
|
9
|
+
require 'opal-rails'
|
|
10
|
+
require 'hyper-react'
|
|
11
|
+
|
|
12
|
+
<%= application_definition %>
|
|
13
|
+
<% end %>
|
|
File without changes
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require 'rails/generators/rails/app/app_generator'
|
|
2
|
+
|
|
3
|
+
module ReactiveRuby
|
|
4
|
+
class TestAppGenerator < ::Rails::Generators::Base
|
|
5
|
+
def self.source_paths
|
|
6
|
+
paths = self.superclass.source_paths
|
|
7
|
+
paths << File.expand_path('../templates', __FILE__)
|
|
8
|
+
paths.flatten
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def remove_existing_app
|
|
12
|
+
remove_dir(test_app_path) if File.directory?(test_app_path)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def generate_test_app
|
|
16
|
+
opts = options.dup
|
|
17
|
+
opts[:database] = 'sqlite3' if opts[:database].blank?
|
|
18
|
+
opts[:force] = true
|
|
19
|
+
opts[:skip_bundle] = true
|
|
20
|
+
|
|
21
|
+
puts "Generating Test Rails Application..."
|
|
22
|
+
invoke ::Rails::Generators::AppGenerator,
|
|
23
|
+
[ File.expand_path(test_app_path, destination_root) ], opts
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def configure_test_app
|
|
27
|
+
template 'boot.rb.erb', "#{test_app_path}/config/boot.rb", force: true
|
|
28
|
+
template 'test_application.rb.erb', "#{test_app_path}/config/application.rb", force: true
|
|
29
|
+
template 'assets/javascripts/test_application.rb',
|
|
30
|
+
"#{test_app_path}/app/assets/javascripts/application.rb", force: true
|
|
31
|
+
template 'assets/javascripts/components.rb',
|
|
32
|
+
"#{test_app_path}/app/views/components.rb", force: true
|
|
33
|
+
template 'views/components/hello_world.rb',
|
|
34
|
+
"#{test_app_path}/app/views/components/hello_world.rb", force: true
|
|
35
|
+
template 'views/components/todo.rb',
|
|
36
|
+
"#{test_app_path}/app/views/components/todo.rb", force: true
|
|
37
|
+
template 'views/layouts/test_layout.html.erb',
|
|
38
|
+
"#{test_app_path}/app/views/layouts/test_layout.html.erb", force: true
|
|
39
|
+
template 'views/layouts/test_layout.html.erb',
|
|
40
|
+
"#{test_app_path}/app/views/layouts/explicit_layout.html.erb", force: true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def clean_superfluous_files
|
|
44
|
+
inside test_app_path do
|
|
45
|
+
remove_file '.gitignore'
|
|
46
|
+
remove_file 'doc'
|
|
47
|
+
remove_file 'Gemfile'
|
|
48
|
+
remove_file 'lib/tasks'
|
|
49
|
+
remove_file 'app/assets/images/rails.png'
|
|
50
|
+
remove_file 'app/assets/javascripts/application.js'
|
|
51
|
+
remove_file 'public/index.html'
|
|
52
|
+
remove_file 'public/robots.txt'
|
|
53
|
+
remove_file 'README.rdoc'
|
|
54
|
+
remove_file 'test'
|
|
55
|
+
remove_file 'vendor'
|
|
56
|
+
remove_file 'spec'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def configure_opal_rspec
|
|
61
|
+
inject_into_file "#{test_app_path}/config/application.rb",
|
|
62
|
+
after: /class Application < Rails::Application/, verbose: true do
|
|
63
|
+
%Q[
|
|
64
|
+
config.opal.method_missing = true
|
|
65
|
+
config.opal.optimized_operators = true
|
|
66
|
+
config.opal.arity_check = false
|
|
67
|
+
config.opal.const_missing = true
|
|
68
|
+
config.opal.dynamic_require_severity = :ignore
|
|
69
|
+
config.opal.enable_specs = true
|
|
70
|
+
config.opal.spec_location = 'spec-opal'
|
|
71
|
+
]
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
protected
|
|
76
|
+
|
|
77
|
+
def application_definition
|
|
78
|
+
@application_definition ||= begin
|
|
79
|
+
test_application_contents
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
alias :store_application_definition! :application_definition
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def test_app_path
|
|
87
|
+
'spec/test_app'
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_application_path
|
|
91
|
+
File.expand_path("#{test_app_path}/config/application.rb",
|
|
92
|
+
destination_root)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_application_contents
|
|
96
|
+
return unless File.exists?(test_application_path) && !options[:pretend]
|
|
97
|
+
contents = File.read(test_application_path)
|
|
98
|
+
contents[(contents.index("module #{module_name}"))..-1]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def module_name
|
|
102
|
+
'TestApp'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def gemfile_path
|
|
106
|
+
'../../../../Gemfile'
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
data/lib/hyper-react.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
if RUBY_ENGINE == 'opal'
|
|
4
|
+
if `window.React === undefined || window.React.version === undefined`
|
|
5
|
+
raise [
|
|
6
|
+
"No React.js Available",
|
|
7
|
+
"",
|
|
8
|
+
"A global `React` must be defined before requiring 'hyper-react'",
|
|
9
|
+
"",
|
|
10
|
+
"To USE THE BUILT-IN SOURCE: ",
|
|
11
|
+
" add 'require \"react/react-source\"' immediately before the 'require \"hyper-react\" directive.",
|
|
12
|
+
"IF USING WEBPACK:",
|
|
13
|
+
" add 'react' to your webpack manifest."
|
|
14
|
+
].join("\n")
|
|
15
|
+
end
|
|
16
|
+
require 'react/hash'
|
|
17
|
+
require 'react/top_level'
|
|
18
|
+
require 'react/observable'
|
|
19
|
+
require 'react/validator'
|
|
20
|
+
require 'react/component'
|
|
21
|
+
require 'react/component/dsl_instance_methods'
|
|
22
|
+
require 'react/component/should_component_update'
|
|
23
|
+
require 'react/component/tags'
|
|
24
|
+
require 'react/component/base'
|
|
25
|
+
require 'react/element'
|
|
26
|
+
require 'react/event'
|
|
27
|
+
require 'react/api'
|
|
28
|
+
require 'react/rendering_context'
|
|
29
|
+
require 'react/state'
|
|
30
|
+
require 'react/object'
|
|
31
|
+
require 'reactive-ruby/isomorphic_helpers'
|
|
32
|
+
require 'rails-helpers/top_level_rails_component'
|
|
33
|
+
require 'reactive-ruby/version'
|
|
34
|
+
|
|
35
|
+
else
|
|
36
|
+
require 'opal'
|
|
37
|
+
# rubocop:disable Lint/HandleExceptions
|
|
38
|
+
begin
|
|
39
|
+
require 'opal-jquery'
|
|
40
|
+
rescue LoadError
|
|
41
|
+
end
|
|
42
|
+
# rubocop:enable Lint/HandleExceptions
|
|
43
|
+
require 'opal-activesupport'
|
|
44
|
+
require 'reactive-ruby/version'
|
|
45
|
+
require 'reactive-ruby/rails' if defined?(Rails)
|
|
46
|
+
require 'reactive-ruby/isomorphic_helpers'
|
|
47
|
+
require 'reactive-ruby/serializers'
|
|
48
|
+
|
|
49
|
+
Opal.append_path File.expand_path('../', __FILE__).untaint
|
|
50
|
+
Opal.append_path File.expand_path('../sources/', __FILE__).untaint
|
|
51
|
+
require "react/react-source"
|
|
52
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module React
|
|
2
|
+
class TopLevelRailsComponent
|
|
3
|
+
include React::Component
|
|
4
|
+
|
|
5
|
+
def self.search_path
|
|
6
|
+
@search_path ||= [Module]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
export_component
|
|
10
|
+
|
|
11
|
+
param :component_name
|
|
12
|
+
param :controller
|
|
13
|
+
param :render_params
|
|
14
|
+
|
|
15
|
+
backtrace :off
|
|
16
|
+
|
|
17
|
+
def render
|
|
18
|
+
paths_searched = []
|
|
19
|
+
if params.component_name.start_with? "::"
|
|
20
|
+
paths_searched << params.component_name.gsub(/^\:\:/,"")
|
|
21
|
+
component = params.component_name.gsub(/^\:\:/,"").split("::").inject(Module) { |scope, next_const| scope.const_get(next_const, false) } rescue nil
|
|
22
|
+
return present component, params.render_params if component && component.method_defined?(:render)
|
|
23
|
+
else
|
|
24
|
+
self.class.search_path.each do |path|
|
|
25
|
+
# try each path + params.controller + params.component_name
|
|
26
|
+
paths_searched << "#{path.name + '::' unless path == Module}#{params.controller}::#{params.component_name}"
|
|
27
|
+
component = "#{params.controller}::#{params.component_name}".split("::").inject(path) { |scope, next_const| scope.const_get(next_const, false) } rescue nil
|
|
28
|
+
return present component, params.render_params if component && component.method_defined?(:render)
|
|
29
|
+
end
|
|
30
|
+
self.class.search_path.each do |path|
|
|
31
|
+
# then try each path + params.component_name
|
|
32
|
+
paths_searched << "#{path.name + '::' unless path == Module}#{params.component_name}"
|
|
33
|
+
component = "#{params.component_name}".split("::").inject(path) { |scope, next_const| scope.const_get(next_const, false) } rescue nil
|
|
34
|
+
return present component, params.render_params if component && component.method_defined?(:render)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
raise "Could not find component class '#{params.component_name}' for params.controller '#{params.controller}' in any component directory. Tried [#{paths_searched.join(", ")}]"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class Module
|
|
43
|
+
def add_to_react_search_path(replace_search_path = nil)
|
|
44
|
+
if replace_search_path
|
|
45
|
+
React::TopLevelRailsComponent.search_path = [self]
|
|
46
|
+
elsif !React::TopLevelRailsComponent.search_path.include? self
|
|
47
|
+
React::TopLevelRailsComponent.search_path << self
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
module Components
|
|
53
|
+
add_to_react_search_path
|
|
54
|
+
end
|