superglue 0.40.0 → 0.50.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/rails/scaffold_controller_generator.rb +3 -3
- data/lib/generators/rails/superglue_generator.rb +52 -46
- data/lib/generators/rails/templates/_form.json.props +3 -10
- data/lib/generators/rails/templates/index.json.props +3 -1
- data/lib/generators/rails/templates/web/edit.js +9 -2
- data/lib/generators/rails/templates/web/index.js +8 -1
- data/lib/generators/rails/templates/web/new.js +9 -2
- data/lib/install/templates/web/actions.js +0 -1
- data/lib/install/templates/web/application.js +28 -73
- data/lib/install/templates/web/application.json.props +1 -4
- data/lib/install/templates/web/initializer.rb +1 -1
- data/lib/install/templates/web/page_to_page_mapping.js +12 -0
- data/lib/install/templates/web/reducer.js +1 -29
- data/lib/install/web.rb +21 -35
- data/lib/superglue/helpers.rb +7 -517
- data/lib/superglue/redirection.rb +1 -2
- data/lib/superglue.rb +6 -6
- data/lib/tasks/install.rake +4 -27
- metadata +15 -22
- data/test/engine_test.rb +0 -7
- data/test/helpers_test.rb +0 -23
- data/test/render_test.rb +0 -81
- data/test/test_helper.rb +0 -20
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superglue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.50.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.23.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.23.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: form_props
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.0.3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.0.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activerecord
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,21 +178,18 @@ files:
|
|
178
178
|
- lib/install/templates/web/application.json.props
|
179
179
|
- lib/install/templates/web/application_visit.js
|
180
180
|
- lib/install/templates/web/initializer.rb
|
181
|
+
- lib/install/templates/web/page_to_page_mapping.js
|
181
182
|
- lib/install/templates/web/reducer.js
|
182
183
|
- lib/install/web.rb
|
183
184
|
- lib/superglue.rb
|
184
185
|
- lib/superglue/helpers.rb
|
185
186
|
- lib/superglue/redirection.rb
|
186
187
|
- lib/tasks/install.rake
|
187
|
-
- test/engine_test.rb
|
188
|
-
- test/helpers_test.rb
|
189
|
-
- test/render_test.rb
|
190
|
-
- test/test_helper.rb
|
191
188
|
homepage: https://github.com/thoughtbot/superglue/
|
192
189
|
licenses:
|
193
190
|
- MIT
|
194
191
|
metadata: {}
|
195
|
-
post_install_message:
|
192
|
+
post_install_message:
|
196
193
|
rdoc_options: []
|
197
194
|
require_paths:
|
198
195
|
- lib
|
@@ -203,16 +200,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
200
|
version: '0'
|
204
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
202
|
requirements:
|
206
|
-
- - "
|
203
|
+
- - ">"
|
207
204
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
205
|
+
version: 1.3.1
|
209
206
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
-
signing_key:
|
207
|
+
rubygems_version: 3.4.6
|
208
|
+
signing_key:
|
212
209
|
specification_version: 4
|
213
210
|
summary: Rails integration for SuperglueJS
|
214
|
-
test_files:
|
215
|
-
- test/render_test.rb
|
216
|
-
- test/helpers_test.rb
|
217
|
-
- test/engine_test.rb
|
218
|
-
- test/test_helper.rb
|
211
|
+
test_files: []
|
data/test/engine_test.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class EngineTest < ActiveSupport::TestCase
|
4
|
-
test "does not include itself in action controller base when superglue auto include is false" do
|
5
|
-
refute ActionController::Base.included_modules.any? { |m| m.name && m.name.include?('Superglue') }
|
6
|
-
end
|
7
|
-
end
|
data/test/helpers_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class HelpersTest < ActiveSupport::TestCase
|
4
|
-
include Superglue::Helpers
|
5
|
-
|
6
|
-
test 'clean_props_at returns nil if qry is nil' do
|
7
|
-
qry = nil
|
8
|
-
|
9
|
-
assert_nil param_to_search_path(qry)
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'clean_props_at returns a refined qry' do
|
13
|
-
qry = 'foo...bar/?)()-'
|
14
|
-
|
15
|
-
assert_equal param_to_search_path(qry), ['foo', 'bar']
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'camelize_path' do
|
19
|
-
path = ['foo_bar', 'foo_bar=1', 'foo_baz_roo']
|
20
|
-
|
21
|
-
assert_equal search_path_to_camelized_param(path), 'fooBar.fooBar=1.fooBazRoo'
|
22
|
-
end
|
23
|
-
end
|
data/test/render_test.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RenderController < TestController
|
4
|
-
require 'action_view/testing/resolvers'
|
5
|
-
|
6
|
-
append_view_path(ActionView::FixtureResolver.new(
|
7
|
-
'render/simple_render_with_superglue.json.props' => 'json.author "john smith"',
|
8
|
-
'render/simple_render_with_superglue_with_bad_layout.json.props' => 'json.author "john smith"',
|
9
|
-
'layouts/application.json.props' => 'json.data {yield json}',
|
10
|
-
'layouts/does_not_exist.html.erb' => '',
|
11
|
-
'layouts/application.html.erb' => <<~HTML
|
12
|
-
<html>
|
13
|
-
<head>
|
14
|
-
<script><%= @initial_state.strip.html_safe %></script>
|
15
|
-
</head>
|
16
|
-
<body><%=yield%></body>
|
17
|
-
</html>
|
18
|
-
HTML
|
19
|
-
))
|
20
|
-
|
21
|
-
layout 'application'
|
22
|
-
|
23
|
-
def render_action
|
24
|
-
render :action
|
25
|
-
end
|
26
|
-
|
27
|
-
def simple_render_with_superglue
|
28
|
-
@initial_state = render_to_string(formats: [:json], layout: true)
|
29
|
-
render inline: '', layout: true
|
30
|
-
end
|
31
|
-
|
32
|
-
def simple_render_with_superglue_with_bad_layout
|
33
|
-
@initial_state = render_to_string(formats: [:json], layout: 'does_not_exist')
|
34
|
-
render inline: '', layout: true
|
35
|
-
end
|
36
|
-
|
37
|
-
def form_authenticity_token
|
38
|
-
"secret"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class RenderTest < ActionController::TestCase
|
43
|
-
tests RenderController
|
44
|
-
|
45
|
-
|
46
|
-
setup do
|
47
|
-
if Rails.version >= '6'
|
48
|
-
# In rails 6, the fixture orders the templates based on their appearance in the handler
|
49
|
-
# This doesn't happen IRL, so I'm going to explicitly set the handler here.
|
50
|
-
#
|
51
|
-
# Note that the original is the following
|
52
|
-
# @controller.lookup_context.handlers = [:raw, :superglue, :erb, :js, :html, :builder, :ruby]
|
53
|
-
@controller.lookup_context.handlers = [:props, :erb]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
test "simple render with superglue" do
|
58
|
-
get :simple_render_with_superglue
|
59
|
-
|
60
|
-
assert_response 200
|
61
|
-
rendered = <<~HTML
|
62
|
-
<html>
|
63
|
-
<head>
|
64
|
-
<script>{"data":{"author":"john smith"}}</script>
|
65
|
-
</head>
|
66
|
-
<body></body>
|
67
|
-
</html>
|
68
|
-
HTML
|
69
|
-
|
70
|
-
assert_equal rendered, @response.body
|
71
|
-
assert_equal 'text/html', @response.media_type
|
72
|
-
end
|
73
|
-
|
74
|
-
test "simple render when the layout doesn't exist" do
|
75
|
-
err = assert_raise ActionView::MissingTemplate do |e|
|
76
|
-
get :simple_render_with_superglue_with_bad_layout
|
77
|
-
end
|
78
|
-
|
79
|
-
assert_equal(true, err.message.starts_with?('Missing template layouts/does_not_exist with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:props, :erb]}.'))
|
80
|
-
end
|
81
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'rails'
|
2
|
-
require 'abstract_controller'
|
3
|
-
require 'abstract_controller/railties/routes_helpers'
|
4
|
-
require 'action_controller'
|
5
|
-
require 'superglue'
|
6
|
-
require "active_support"
|
7
|
-
require 'active_record'
|
8
|
-
require 'active_support/testing/autorun'
|
9
|
-
require 'active_support/test_case'
|
10
|
-
|
11
|
-
require 'props_template'
|
12
|
-
|
13
|
-
ActiveSupport::TestCase.test_order = :random if ActiveSupport::TestCase.respond_to?(:test_order=)
|
14
|
-
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
15
|
-
Rails.cache = ActiveSupport::Cache::MemoryStore.new
|
16
|
-
|
17
|
-
load File.dirname(__FILE__) + '/support/schema.rb'
|
18
|
-
require 'support/models'
|
19
|
-
require 'support/test_application'
|
20
|
-
|