view_component 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ac6dfbc2cb2fb7bbad0aac55de41cfbdc782dac0eb14f1e4b18784e15db02a9
4
- data.tar.gz: 294bd6faac8d95b0db842ab67139e141117058148c24d503647960e31c19ef21
3
+ metadata.gz: bc3f38e0c12dafc80bf6c2c9b74d09d3a3f019ee4d4a9dfa59d1a638a1228898
4
+ data.tar.gz: 48f1df9b4f54a0049b96e37b1ca16de5125ef13163838aa94cba4fb5cb6f8a1f
5
5
  SHA512:
6
- metadata.gz: 4d2da7f6d4ff599ea9b92408dc632eecb7629d7bf7cda9484eab20b0f02dd1a78ba3669fc5f9107f2b6388d2f5634258a14b806d58327c716a8339b819ef8aa7
7
- data.tar.gz: 50b86ff9e697608ae063352c8a55430763b5762016c3512dfa103f5df7a2fbb4875a993e319783f2e1e077c4ca157152a4314d3a106b0fc0a84186926044f917
6
+ metadata.gz: 7efa511f6cc6b76fed913823eb54d3ec709e3d8ca99adbcbc6cf6a667c407be4885701b68fc174fa2af3908d6da708c77c9cffa58de23f3f11307510e7cceb57
7
+ data.tar.gz: 238f0fd897c7125652cf80df6c59dcaa5d8bf5a1eb39d994a48a876be49cf0c43d5274eed3b2fbcf8915461ef1334dec9f92835b886e152e7eb64ab320b7049f
@@ -1,5 +1,11 @@
1
1
  # master
2
2
 
3
+ # 2.9.0
4
+
5
+ * Cache components per-request in development, preventing unnecessary recompilation during a single request.
6
+
7
+ *Felipe Sateler*
8
+
3
9
  # 2.8.0
4
10
 
5
11
  * Add `before_render`, deprecating `before_render_check`.
@@ -10,7 +16,7 @@
10
16
 
11
17
  * Add `rendered_component` method to `ViewComponent::TestHelpers` which exposes the raw output of the rendered component.
12
18
 
13
- *Richard Macklin*
19
+ *Richard Macklin*
14
20
 
15
21
  * Support sidecar directories for views and other assets.
16
22
 
data/README.md CHANGED
@@ -778,10 +778,10 @@ ViewComponent is built by:
778
778
  |@blakewilliams|@seanpdoyle|@tclem|@nashby|@jaredcwhite|
779
779
  |Boston, MA|New York, NY|San Francisco, CA|Minsk|Portland, OR|
780
780
 
781
- |<img src="https://avatars.githubusercontent.com/simonrand?s=256" alt="simonrand" width="128" />|<img src="https://avatars.githubusercontent.com/fugufish?s=256" alt="fugufish" width="128" />|<img src="https://avatars.githubusercontent.com/cover?s=256" alt="cover" width="128" />|<img src="https://avatars.githubusercontent.com/franks921?s=256" alt="franks921" width="128" />|
782
- |:---:|:---:|:---:|:---:|
783
- |@simonrand|@fugufish|@cover|@franks921|
784
- |Dublin, Ireland|Salt Lake City, Utah|Barcelona|South Africa|
781
+ |<img src="https://avatars.githubusercontent.com/simonrand?s=256" alt="simonrand" width="128" />|<img src="https://avatars.githubusercontent.com/fugufish?s=256" alt="fugufish" width="128" />|<img src="https://avatars.githubusercontent.com/cover?s=256" alt="cover" width="128" />|<img src="https://avatars.githubusercontent.com/franks921?s=256" alt="franks921" width="128" />|<img src="https://avatars.githubusercontent.com/fsateler?s=256" alt="fsateler" width="128" />|
782
+ |:---:|:---:|:---:|:---:|:---:|
783
+ |@simonrand|@fugufish|@cover|@franks921|@fsateler|
784
+ |Dublin, Ireland|Salt Lake City, Utah|Barcelona|South Africa|Chile|
785
785
 
786
786
  ## License
787
787
 
@@ -3,6 +3,7 @@
3
3
  require "action_view"
4
4
  require "active_support/configurable"
5
5
  require "view_component/collection"
6
+ require "view_component/compile_cache"
6
7
  require "view_component/previewable"
7
8
 
8
9
  module ViewComponent
@@ -192,9 +193,7 @@ module ViewComponent
192
193
  end
193
194
 
194
195
  def compiled?
195
- @compiled ||= false
196
-
197
- @compiled && ActionView::Base.cache_template_loading
196
+ CompileCache.compiled?(self)
198
197
  end
199
198
 
200
199
  # Compile templates to instance methods, assuming they haven't been compiled already.
@@ -270,7 +269,7 @@ module ViewComponent
270
269
  RUBY
271
270
  end
272
271
 
273
- @compiled = true
272
+ CompileCache.register self
274
273
  end
275
274
 
276
275
  # we'll eventually want to update this to support other types
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViewComponent
4
+ # Keeps track of which templates have already been compiled
5
+ # This is not part of the public API
6
+ module CompileCache
7
+ mattr_accessor :cache, instance_reader: false, instance_accessor: false do
8
+ Set.new
9
+ end
10
+ module_function
11
+
12
+ def register(klass)
13
+ cache << klass
14
+ end
15
+
16
+ def compiled?(klass)
17
+ cache.include? klass
18
+ end
19
+
20
+ def invalidate!
21
+ cache.clear
22
+ end
23
+ end
24
+ end
@@ -69,6 +69,10 @@ module ViewComponent
69
69
  get "#{options.preview_route}/*path", to: "view_components#previews", as: :preview_view_component, internal: true
70
70
  end
71
71
  end
72
+
73
+ app.executor.to_run :before do
74
+ CompileCache.invalidate! unless ActionView::Base.cache_template_loading
75
+ end
72
76
  end
73
77
  end
74
78
  end
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 8
6
+ MINOR = 9
7
7
  PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -200,6 +200,7 @@ files:
200
200
  - lib/view_component.rb
201
201
  - lib/view_component/base.rb
202
202
  - lib/view_component/collection.rb
203
+ - lib/view_component/compile_cache.rb
203
204
  - lib/view_component/engine.rb
204
205
  - lib/view_component/preview.rb
205
206
  - lib/view_component/previewable.rb