superglue 0.41.0 → 0.50.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 +4 -4
- data/lib/generators/rails/scaffold_controller_generator.rb +3 -3
- data/lib/generators/rails/superglue_generator.rb +49 -60
- data/lib/generators/rails/templates/_form.json.props +3 -10
- data/lib/generators/rails/templates/edit.json.props +2 -4
- data/lib/generators/rails/templates/index.json.props +3 -1
- data/lib/generators/rails/templates/new.json.props +2 -4
- data/lib/generators/rails/templates/web/edit.js +11 -7
- data/lib/generators/rails/templates/web/index.js +12 -5
- data/lib/generators/rails/templates/web/new.js +11 -7
- data/lib/generators/rails/templates/web/show.js +3 -3
- data/lib/install/templates/web/actions.js +6 -3
- data/lib/install/templates/web/application.js +20 -47
- data/lib/install/templates/web/application.json.props +5 -6
- data/lib/install/templates/web/flash.js +19 -0
- 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/pages.js +15 -0
- data/lib/install/templates/web/store.js +32 -0
- data/lib/install/web.rb +15 -19
- 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 +1 -12
- metadata +20 -40
- data/lib/install/templates/web/action_creators.js +0 -14
- data/lib/install/templates/web/reducer.js +0 -44
- 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
|
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: 2023-
|
11
|
+
date: 2023-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 7.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: props_template
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
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
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '7.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '7.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '12.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: byebug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '9.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '9.0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: sqlite3
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,27 +158,25 @@ files:
|
|
172
158
|
- lib/generators/rails/templates/web/new.js
|
173
159
|
- lib/generators/rails/templates/web/show.html.erb
|
174
160
|
- lib/generators/rails/templates/web/show.js
|
175
|
-
- lib/install/templates/web/action_creators.js
|
176
161
|
- lib/install/templates/web/actions.js
|
177
162
|
- lib/install/templates/web/application.js
|
178
163
|
- lib/install/templates/web/application.json.props
|
179
164
|
- lib/install/templates/web/application_visit.js
|
165
|
+
- lib/install/templates/web/flash.js
|
180
166
|
- lib/install/templates/web/initializer.rb
|
181
|
-
- lib/install/templates/web/
|
167
|
+
- lib/install/templates/web/page_to_page_mapping.js
|
168
|
+
- lib/install/templates/web/pages.js
|
169
|
+
- lib/install/templates/web/store.js
|
182
170
|
- lib/install/web.rb
|
183
171
|
- lib/superglue.rb
|
184
172
|
- lib/superglue/helpers.rb
|
185
173
|
- lib/superglue/redirection.rb
|
186
174
|
- 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
175
|
homepage: https://github.com/thoughtbot/superglue/
|
192
176
|
licenses:
|
193
177
|
- MIT
|
194
178
|
metadata: {}
|
195
|
-
post_install_message:
|
179
|
+
post_install_message:
|
196
180
|
rdoc_options: []
|
197
181
|
require_paths:
|
198
182
|
- lib
|
@@ -207,12 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
191
|
- !ruby/object:Gem::Version
|
208
192
|
version: '0'
|
209
193
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
-
signing_key:
|
194
|
+
rubygems_version: 3.4.6
|
195
|
+
signing_key:
|
212
196
|
specification_version: 4
|
213
197
|
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
|
198
|
+
test_files: []
|
@@ -1,44 +0,0 @@
|
|
1
|
-
// Example:
|
2
|
-
//
|
3
|
-
// import {
|
4
|
-
// CLEAR_FORM_ERRORS
|
5
|
-
// } from './actions'
|
6
|
-
// import produce from "immer"
|
7
|
-
//
|
8
|
-
// export const applicationPagesReducer = (state = {}, action) => {
|
9
|
-
// switch(action.type) {
|
10
|
-
// case CLEAR_FORM_ERRORS: {
|
11
|
-
// const {pageKey} = action.payload
|
12
|
-
//
|
13
|
-
// return produce(state, draft => {
|
14
|
-
// const currentPage = draft[pageKey]
|
15
|
-
// delete currentPage.errors
|
16
|
-
// })
|
17
|
-
// }
|
18
|
-
// default:
|
19
|
-
// return state
|
20
|
-
// }
|
21
|
-
// }
|
22
|
-
|
23
|
-
|
24
|
-
// The applicationPageReducer is for cross page reducers
|
25
|
-
// Its common to add to this. You'll typically have to pass a pageKey to the
|
26
|
-
// action payload to distinguish the current page
|
27
|
-
//
|
28
|
-
// The pageKey is passed through the props in your component. Access it like
|
29
|
-
// this: `this.props.pageKey` then dispatch it in an action
|
30
|
-
export const applicationPagesReducer = (state = {}, action) => {
|
31
|
-
switch(action.type) {
|
32
|
-
default:
|
33
|
-
return state
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
// The applicationRootReducer is for app wide reducers
|
38
|
-
// Its rare to be adding to this.
|
39
|
-
export const applicationRootReducer = (state = {}, action) => {
|
40
|
-
switch(action.type) {
|
41
|
-
default:
|
42
|
-
return state
|
43
|
-
}
|
44
|
-
}
|
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
|
-
|