lookbook 0.9.4 → 0.9.5

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: 5617747c0cc6eca338a14139a9bc770b155656496676d5bc1b1ffbc61f08a0c4
4
- data.tar.gz: ec66261ebd66850c9e30893825d3bd03096e2425c207dc449b12f0bb2489f9c6
3
+ metadata.gz: 0b46fc66383c91d07e598a8d2be4a8b8bf5d7d45c0155a8176f69f194aead1d2
4
+ data.tar.gz: 4e539b1fd03bacd9ad9df6d71802cd5a1d1ab95c7d9364797ecfe9af60843b55
5
5
  SHA512:
6
- metadata.gz: 9c9e23c5e73b16775efa80595fb06323f09417e62ece899aaae648c677ac30885e0dd354b7032cd74e85a04447754f55a88ef0f0ad62d9d69998958edb15d783
7
- data.tar.gz: b6c78c07414bbe524881cd04719d0b04c69b470a70862f09bdfe2804fe33ab36b658298a5807726a413f0ae20bddaadbc7c60fff3632f9ac04dfc524c9437564
6
+ metadata.gz: 833ff99b67b2367f379c0699cd5ef4f73fae26ac8dc6e27378f8f3f1ef5b830669caf2f6ebda07e4c150645438522ee7691de3582d898d1cabc54e75578bfd4e
7
+ data.tar.gz: 507225b27f5b2966c95da2f70eb936d5f6da1b92cdf59fa815a39f99c3478c6d37f9a08fbe1b6bf2df4acf020003a61d148f373465ce7e053a21153c49784a7c
@@ -2,6 +2,7 @@ require "rails"
2
2
  require "view_component"
3
3
  require "action_cable/engine"
4
4
  require "listen"
5
+ require "rake"
5
6
 
6
7
  module Lookbook
7
8
  class << self
@@ -83,10 +84,32 @@ module Lookbook
83
84
  @preview_controller = Lookbook.config.preview_controller.constantize
84
85
  @preview_controller.include(Lookbook::PreviewController)
85
86
 
87
+ if Rails.application&.server.present?
88
+ # Rails.application.server is only available for Rails >= v6.1.3.1
89
+ Rails.application.server { init_listeners }
90
+ else
91
+ # So fallback to not listening if running in a rake task
92
+ init_listeners unless File.basename($0) == "rake" || Rake.application.top_level_tasks.any?
93
+ end
94
+
95
+ if config.lookbook.runtime_parsing
96
+ Lookbook::Engine.parser.parse
97
+ else
98
+ unless File.exist?(config.lookbook.parser_registry_path)
99
+ Lookbook.logger.warn "
100
+ Runtime parsing is disabled but no registry file has been found.
101
+ Did you run `rake lookbook:preparse` before starting the app?
102
+ Expected to find registry file at #{config.lookbook.parser_registry_path}
103
+ "
104
+ end
105
+ end
106
+ end
107
+
108
+ def init_listeners
86
109
  if config.lookbook.listen
87
110
  @preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(#{config.lookbook.listen_extensions.join("|")})$/) do |modified, added, removed|
88
111
  begin
89
- parser.parse
112
+ Lookbook::Engine.parser.parse
90
113
  rescue
91
114
  end
92
115
  Lookbook::Preview.clear_cache
@@ -109,18 +132,6 @@ module Lookbook
109
132
  @page_listener.start
110
133
  end
111
134
  end
112
-
113
- if config.lookbook.runtime_parsing
114
- parser.parse
115
- else
116
- unless File.exist?(config.lookbook.parser_registry_path)
117
- Lookbook.logger.warn "
118
- Runtime parsing is disabled but no registry file has been found.
119
- Did you run `rake lookbook:preparse` before starting the app?
120
- Expected to find registry file at #{config.lookbook.parser_registry_path}
121
- "
122
- end
123
- end
124
135
  end
125
136
 
126
137
  at_exit do
@@ -141,9 +152,9 @@ module Lookbook
141
152
  @websocket ||= if Rails.version.to_f >= 6.0
142
153
  ActionCable::Server::Base.new(config: cable)
143
154
  else
144
- @websocket ||= ActionCable::Server::Base.new
145
- @websocket.config = cable
146
- @websocket
155
+ ws = ActionCable::Server::Base.new
156
+ ws.config = cable
157
+ ws
147
158
  end
148
159
  end
149
160
  end
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
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.9.4
4
+ version: 0.9.5
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-08-23 00:00:00.000000000 Z
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable