lookbook 0.7.2.beta.2 → 0.7.2.beta.3
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 +1 -1
- data/app/helpers/lookbook/component_helper.rb +1 -1
- data/app/helpers/lookbook/page_helper.rb +1 -2
- data/lib/lookbook/engine.rb +0 -3
- data/lib/lookbook/page.rb +1 -1
- data/lib/lookbook/preview.rb +19 -33
- 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: 852092ae163c9f99f18df3ac6ccd9c54fa41050d9eab7c6ce193404af3a73978
|
4
|
+
data.tar.gz: 47b59f02f782fc536e68cb016ab9d8effe26c58957a6e273568deebdd00217cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1e15295d9ee395d05b2971f4441387219d99b358020ff4a83816229ce2ca63ac3c30f5d2c74938c37bcff579abc34105caa37ed38183f7e3888b176c62f0fb9
|
7
|
+
data.tar.gz: 8ac54bd1cf4d4044c9ff037cc1ccf44fd6d674fbb643e35aa1b98e729eaa5dbc8636233bc7461ab0670ecdfc1cfd5ed9251dd03d86ede5595a0274f3db01581a
|
@@ -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
|
@@ -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
@@ -83,9 +83,6 @@ module Lookbook
|
|
83
83
|
|
84
84
|
config.after_initialize do
|
85
85
|
@preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(rb|html.*)$/) do |modified, added, removed|
|
86
|
-
if Lookbook::Preview.errors.any?
|
87
|
-
Lookbook::Preview.reload
|
88
|
-
end
|
89
86
|
begin
|
90
87
|
parser.parse
|
91
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
|
-
@loaded_files.push(file[:rel_path])
|
127
|
+
require_dependency file[:path]
|
142
128
|
rescue => exception
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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,
|
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.3
|
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-
|
11
|
+
date: 2022-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actioncable
|