lookbook 0.7.2.beta.1 → 0.7.2.beta.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 +4 -4
- data/app/controllers/lookbook/pages_controller.rb +1 -4
- data/app/controllers/lookbook/previews_controller.rb +3 -4
- data/app/helpers/lookbook/component_helper.rb +1 -1
- data/app/helpers/lookbook/page_helper.rb +1 -2
- data/lib/lookbook/engine.rb +0 -4
- data/lib/lookbook/page.rb +1 -1
- data/lib/lookbook/preview.rb +20 -34
- data/lib/lookbook/preview_controller.rb +2 -2
- data/lib/lookbook/preview_group.rb +5 -1
- data/lib/lookbook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fade881318cf86e1a2531169e35458632e7822647de9707103b3875c4e6c2305
|
|
4
|
+
data.tar.gz: 776e91f2fe6cb3d2175d4f29d135731198406cf4c4529b6b9bb8ba392ad5ae45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73249cfe3598621f8ccb60c57d2516801e2cd5574c45f043ed777b7b3d9502df554b883a3f9822c31fa8046768c064506358c5e7281cd2f240df5b073400b5e3
|
|
7
|
+
data.tar.gz: 83d7478bdde7ceb4845ee6729e5a5280c8b144082d01d31be3012e405567ad6a9e3cd68973f2b8aa66d3479100f8787ea70f921c8ef006b26a57c56c5d44c95e
|
|
@@ -28,10 +28,7 @@ module Lookbook
|
|
|
28
28
|
@title = @page.title
|
|
29
29
|
rescue => exception
|
|
30
30
|
render "lookbook/error", locals: {
|
|
31
|
-
error: Lookbook::Error.new(exception,
|
|
32
|
-
file_path: @page.full_path,
|
|
33
|
-
source_code: @page.content
|
|
34
|
-
})
|
|
31
|
+
error: Lookbook::Error.new(exception, file_path: @page.full_path, source_code: @page.content)
|
|
35
32
|
}
|
|
36
33
|
end
|
|
37
34
|
end
|
|
@@ -66,7 +66,7 @@ module Lookbook
|
|
|
66
66
|
{
|
|
67
67
|
label: example.label,
|
|
68
68
|
notes: example.notes,
|
|
69
|
-
html: preview_controller.render_example_to_string
|
|
69
|
+
html: preview_controller.process(:render_example_to_string, @preview, example.name),
|
|
70
70
|
source: has_template ? example.template_source(render_args[:template]) : example.method_source,
|
|
71
71
|
source_lang: has_template ? example.template_lang(render_args[:template]) : example.source_lang,
|
|
72
72
|
params: example.params
|
|
@@ -74,7 +74,7 @@ module Lookbook
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def render_examples(examples)
|
|
77
|
-
preview_controller.render_in_layout_to_string
|
|
77
|
+
preview_controller.process(:render_in_layout_to_string, "layouts/lookbook/preview", {examples: examples}, @preview.layout)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def set_params
|
|
@@ -167,7 +167,6 @@ module Lookbook
|
|
|
167
167
|
message_parts = exception.message.split("\n").first.split
|
|
168
168
|
component_class = message_parts.first.constantize
|
|
169
169
|
naughty_method = message_parts.last.delete("#").delete("`").delete(".")
|
|
170
|
-
p naughty_method
|
|
171
170
|
method = component_class.instance_method(naughty_method.to_sym)
|
|
172
171
|
if method
|
|
173
172
|
{
|
|
@@ -176,7 +175,7 @@ module Lookbook
|
|
|
176
175
|
}
|
|
177
176
|
end
|
|
178
177
|
end
|
|
179
|
-
Lookbook::Error.new(exception, error_params || {})
|
|
178
|
+
Lookbook::Error.new(exception, **(error_params || {}))
|
|
180
179
|
end
|
|
181
180
|
end
|
|
182
181
|
end
|
|
@@ -19,12 +19,11 @@ module Lookbook
|
|
|
19
19
|
|
|
20
20
|
if example
|
|
21
21
|
@embed_counter += 1
|
|
22
|
-
render_component "embed",
|
|
22
|
+
render_component "embed",
|
|
23
23
|
id: generate_id("embed", url_for, example.lookup_path, @embed_counter - 1),
|
|
24
24
|
example: example,
|
|
25
25
|
params: params,
|
|
26
26
|
opts: opts
|
|
27
|
-
}
|
|
28
27
|
else
|
|
29
28
|
embed_not_found
|
|
30
29
|
end
|
data/lib/lookbook/engine.rb
CHANGED
|
@@ -78,15 +78,11 @@ module Lookbook
|
|
|
78
78
|
config.lookbook.cable.logger ||= Rails.logger
|
|
79
79
|
else
|
|
80
80
|
config.lookbook.cable.logger = Lookbook::NullLogger.new
|
|
81
|
-
config.action_view.logger = Lookbook::NullLogger.new
|
|
82
81
|
end
|
|
83
82
|
end
|
|
84
83
|
|
|
85
84
|
config.after_initialize do
|
|
86
85
|
@preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(rb|html.*)$/) do |modified, added, removed|
|
|
87
|
-
if Lookbook::Preview.errors.any?
|
|
88
|
-
Lookbook::Preview.reload
|
|
89
|
-
end
|
|
90
86
|
begin
|
|
91
87
|
parser.parse
|
|
92
88
|
rescue
|
data/lib/lookbook/page.rb
CHANGED
|
@@ -106,7 +106,7 @@ module Lookbook
|
|
|
106
106
|
rescue => exception
|
|
107
107
|
frontmatter = {}
|
|
108
108
|
line_number_match = exception.message.match(/.*line\s(\d+)/)
|
|
109
|
-
@errors.push(Lookbook::Error.new(exception, {
|
|
109
|
+
@errors.push(Lookbook::Error.new(exception, **{
|
|
110
110
|
title: "YAML frontmatter parsing error",
|
|
111
111
|
file_path: @pathname.to_s,
|
|
112
112
|
line_number: line_number_match ? line_number_match[1] : false
|
data/lib/lookbook/preview.rb
CHANGED
|
@@ -97,61 +97,47 @@ module Lookbook
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def all
|
|
100
|
-
|
|
100
|
+
load_previews if preview_files.size > ViewComponent::Preview.descendants.size
|
|
101
|
+
|
|
102
|
+
previews = ViewComponent::Preview.descendants.map do |p|
|
|
101
103
|
new(p)
|
|
102
104
|
rescue
|
|
103
105
|
Rails.logger.error "[lookbook] error instantiating preview\n#{exception.full_message}"
|
|
104
106
|
end
|
|
105
107
|
|
|
108
|
+
if errors.any?
|
|
109
|
+
errors.each do |error|
|
|
110
|
+
Rails.logger.error "[lookbook] preview error\n#{error.full_message}\n"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
106
114
|
sorted_previews = previews.compact.sort_by { |preview| [preview.position, preview.label] }
|
|
107
115
|
PreviewCollection.new(sorted_previews)
|
|
108
116
|
end
|
|
109
117
|
|
|
110
118
|
def errors
|
|
111
|
-
@errors
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def reload
|
|
115
|
-
load_previews
|
|
119
|
+
@errors ||= []
|
|
116
120
|
end
|
|
117
121
|
|
|
118
122
|
protected
|
|
119
123
|
|
|
120
|
-
def reset_files_data
|
|
121
|
-
@loaded_files = []
|
|
122
|
-
@errors = []
|
|
123
|
-
end
|
|
124
|
-
|
|
125
124
|
def load_previews
|
|
126
|
-
|
|
127
|
-
require_preview_files if @errors.any?
|
|
128
|
-
|
|
129
|
-
preview_classes = ViewComponent::Preview.descendants
|
|
130
|
-
if preview_files.size > preview_classes.size
|
|
131
|
-
require_preview_files
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
ViewComponent::Preview.descendants.filter { |klass| @loaded_files.include? "#{klass.name.underscore}.rb" }
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def require_preview_files
|
|
138
|
-
reset_files_data
|
|
125
|
+
@errors = []
|
|
139
126
|
preview_files.each do |file|
|
|
140
|
-
require_dependency
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}))
|
|
127
|
+
require_dependency file[:path]
|
|
128
|
+
rescue SyntaxError, StandardError => exception
|
|
129
|
+
@errors.push(
|
|
130
|
+
Lookbook::Error.new(exception,
|
|
131
|
+
title: "Preview #{exception.class}",
|
|
132
|
+
file_name: file[:rel_path],
|
|
133
|
+
file_path: file[:path])
|
|
134
|
+
)
|
|
149
135
|
end
|
|
150
136
|
end
|
|
151
137
|
|
|
152
138
|
def preview_files
|
|
153
139
|
files = Array(Lookbook.config.preview_paths).map do |preview_path|
|
|
154
|
-
Dir["#{preview_path}/**/*
|
|
140
|
+
Dir["#{preview_path}/**/*preview.rb"].map do |path|
|
|
155
141
|
{
|
|
156
142
|
path: path,
|
|
157
143
|
base_path: preview_path,
|
|
@@ -11,12 +11,12 @@ module Lookbook
|
|
|
11
11
|
opts = {}
|
|
12
12
|
opts[:layout] = nil
|
|
13
13
|
opts[:locals] = locals if locals.present?
|
|
14
|
-
render_to_string
|
|
14
|
+
render html: render_to_string(template, **opts)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def render_in_layout_to_string(template, locals, layout = nil)
|
|
18
18
|
append_view_path Lookbook::Engine.root.join("app/views")
|
|
19
|
-
render_to_string
|
|
19
|
+
render html: render_to_string(template, locals: locals, **determine_layout(layout))
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
data/lib/lookbook/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lookbook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.2.beta.
|
|
4
|
+
version: 0.7.2.beta.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Perkins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-03
|
|
11
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actioncable
|