lookbook 0.7.2.beta.4 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fade881318cf86e1a2531169e35458632e7822647de9707103b3875c4e6c2305
4
- data.tar.gz: 776e91f2fe6cb3d2175d4f29d135731198406cf4c4529b6b9bb8ba392ad5ae45
3
+ metadata.gz: 40ea30d04c53c14779624094908938ce4c795a75a773f24226c7905e12afcdca
4
+ data.tar.gz: 15b596f54edd9cff72d28cf2c3b88a5d28e05b3a323f69033bd44c50c890c3c2
5
5
  SHA512:
6
- metadata.gz: 73249cfe3598621f8ccb60c57d2516801e2cd5574c45f043ed777b7b3d9502df554b883a3f9822c31fa8046768c064506358c5e7281cd2f240df5b073400b5e3
7
- data.tar.gz: 83d7478bdde7ceb4845ee6729e5a5280c8b144082d01d31be3012e405567ad6a9e3cd68973f2b8aa66d3479100f8787ea70f921c8ef006b26a57c56c5d44c95e
6
+ metadata.gz: 2c998b17b156fae344b99131d7487ba74052d1aeaba6ac9ff2cd2c13371f6aa0f3fb1cea6d47b806d4cd3479d93e678fd165b8f85bc30b2c7e35bac1b2685ea5
7
+ data.tar.gz: f347430b5596aaefc63c24a1db82758a86f317cc728bd7c8cb1eefe9efd243e3072186b33fc0144fd7f0fea148d584d3b350b2da09b59ba37be37e41b706f4b2
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  Lookbook::Engine.routes.draw do
2
2
  if Lookbook.config.auto_refresh
3
- mount Lookbook::Engine.websocket => Lookbook.config.cable.mount_path
3
+ mount Lookbook::Engine.websocket => Lookbook.config.cable_mount_path
4
4
  end
5
5
 
6
6
  root to: "application#index", as: :home
@@ -10,7 +10,7 @@ module Lookbook
10
10
  end
11
11
 
12
12
  def logger
13
- @logger ||= config.debug == true ? Rails.logger : Lookbook::NullLogger.new
13
+ @logger ||= Rails.logger
14
14
  end
15
15
 
16
16
  def version
@@ -54,10 +54,8 @@ module Lookbook
54
54
  options.listen_paths << (vc_options.view_component_path || Rails.root.join("app/components"))
55
55
  options.listen_paths.filter! { |path| Dir.exist? path }
56
56
 
57
- options.cable = ActionCable::Server::Configuration.new
58
- options.cable.cable = {adapter: "async"}.with_indifferent_access
59
- options.cable.mount_path ||= "/lookbook-cable"
60
- options.cable.connection_class = -> { Lookbook::Connection }
57
+ options.cable_mount_path ||= "/lookbook-cable"
58
+ options.cable_logger ||= Rails.logger
61
59
 
62
60
  options.experimental_features = false unless options.experimental_features.present?
63
61
  end
@@ -73,43 +71,28 @@ module Lookbook
73
71
  )
74
72
  end
75
73
 
76
- initializer "lookbook.logging" do
77
- if config.lookbook.debug == true
78
- config.lookbook.cable.logger ||= Rails.logger
79
- else
80
- config.lookbook.cable.logger = Lookbook::NullLogger.new
81
- end
82
- end
83
-
84
74
  config.after_initialize do
85
75
  @preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(rb|html.*)$/) do |modified, added, removed|
86
76
  begin
87
77
  parser.parse
88
78
  rescue
89
79
  end
90
- if Lookbook::Engine.websocket
91
- if modified.any? || removed.any? || added.none?
92
- Lookbook::Engine.websocket.broadcast("reload", {
93
- modified: modified,
94
- removed: removed,
95
- added: added
96
- })
97
- end
98
- end
80
+ Lookbook::Preview.clear_cache
81
+ Lookbook::Engine.websocket&.broadcast("reload", {
82
+ modified: modified,
83
+ removed: removed,
84
+ added: added
85
+ })
99
86
  end
100
87
  @preview_listener.start
101
88
 
102
89
  if Lookbook::Features.enabled?(:pages)
103
90
  @page_listener = Listen.to(*config.lookbook.page_paths.filter { |dir| Dir.exist? dir }, only: /\.(html.*|md.*)$/) do |modified, added, removed|
104
- if Lookbook::Engine.websocket
105
- if modified.any? || removed.any? || added.any?
106
- Lookbook::Engine.websocket.broadcast("reload", {
107
- modified: modified,
108
- removed: removed,
109
- added: added
110
- })
111
- end
112
- end
91
+ Lookbook::Engine.websocket&.broadcast("reload", {
92
+ modified: modified,
93
+ removed: removed,
94
+ added: added
95
+ })
113
96
  end
114
97
  @page_listener.start
115
98
  end
@@ -125,18 +108,24 @@ module Lookbook
125
108
  class << self
126
109
  def websocket
127
110
  if config.lookbook.auto_refresh
111
+ cable = ActionCable::Server::Configuration.new
112
+ cable.cable = {adapter: "async"}.with_indifferent_access
113
+ cable.mount_path = config.lookbook.cable_mount_path
114
+ cable.connection_class = -> { Lookbook::Connection }
115
+ cable.logger = config.lookbook.cable_logger
116
+
128
117
  @websocket ||= if Rails.version.to_f >= 6.0
129
- ActionCable::Server::Base.new(config: config.lookbook.cable)
118
+ ActionCable::Server::Base.new(config: cable)
130
119
  else
131
120
  websocket ||= ActionCable::Server::Base.new
132
- websocket.config = config.lookbook.cable
121
+ websocket.config = cable
133
122
  websocket
134
123
  end
135
124
  end
136
125
  end
137
126
 
138
127
  def websocket_mount_path
139
- "#{mounted_path}#{config.lookbook.cable.mount_path}" if websocket
128
+ "#{mounted_path}#{config.lookbook.cable_mount_path}" if websocket
140
129
  end
141
130
 
142
131
  def mounted_path
@@ -96,9 +96,15 @@ module Lookbook
96
96
  !!find(path)
97
97
  end
98
98
 
99
+ def clear_cache
100
+ @previews = nil
101
+ end
102
+
99
103
  def all
100
104
  load_previews if preview_files.size > ViewComponent::Preview.descendants.size
101
105
 
106
+ return @previews if @previews.present?
107
+
102
108
  previews = ViewComponent::Preview.descendants.map do |p|
103
109
  new(p)
104
110
  rescue
@@ -112,7 +118,7 @@ module Lookbook
112
118
  end
113
119
 
114
120
  sorted_previews = previews.compact.sort_by { |preview| [preview.position, preview.label] }
115
- PreviewCollection.new(sorted_previews)
121
+ @previews ||= PreviewCollection.new(sorted_previews)
116
122
  end
117
123
 
118
124
  def errors
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "0.7.2.beta.4"
2
+ VERSION = "0.7.3"
3
3
  end
data/lib/lookbook.rb CHANGED
@@ -20,7 +20,6 @@ module Lookbook
20
20
  autoload :PreviewExample, "lookbook/preview_example"
21
21
  autoload :PreviewGroup, "lookbook/preview_group"
22
22
  autoload :CodeInspector, "lookbook/code_inspector"
23
- autoload :NullLogger, "lookbook/null_logger"
24
23
  autoload :CodeFormatter, "lookbook/code_formatter"
25
24
  autoload :Markdown, "lookbook/markdown"
26
25
 
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
4
+ version: 0.7.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-04-03 00:00:00.000000000 Z
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -290,7 +290,6 @@ files:
290
290
  - lib/lookbook/features.rb
291
291
  - lib/lookbook/lang.rb
292
292
  - lib/lookbook/markdown.rb
293
- - lib/lookbook/null_logger.rb
294
293
  - lib/lookbook/page.rb
295
294
  - lib/lookbook/page_collection.rb
296
295
  - lib/lookbook/params.rb
@@ -325,9 +324,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
325
324
  version: '0'
326
325
  required_rubygems_version: !ruby/object:Gem::Requirement
327
326
  requirements:
328
- - - ">"
327
+ - - ">="
329
328
  - !ruby/object:Gem::Version
330
- version: 1.3.1
329
+ version: '0'
331
330
  requirements: []
332
331
  rubygems_version: 3.2.22
333
332
  signing_key:
@@ -1,47 +0,0 @@
1
- module Lookbook
2
- class NullLogger
3
- def unknown(*)
4
- nil
5
- end
6
-
7
- def fatal(*)
8
- nil
9
- end
10
-
11
- def fatal?
12
- false
13
- end
14
-
15
- def error(*)
16
- nil
17
- end
18
-
19
- def error?
20
- false
21
- end
22
-
23
- def warn(*)
24
- nil
25
- end
26
-
27
- def warn?
28
- false
29
- end
30
-
31
- def info(*)
32
- nil
33
- end
34
-
35
- def info?
36
- false
37
- end
38
-
39
- def debug(*)
40
- nil
41
- end
42
-
43
- def debug?
44
- false
45
- end
46
- end
47
- end