actionview_precompiler 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c8e4204b2ff2f95e85606497693d399460c4c31a8f946706a503be04b03d5f8
4
- data.tar.gz: 8aa824e50eaa357b9f0084756c9399f928b8ead2e2a04fe24ab2bbbe4b611400
3
+ metadata.gz: 54648a555675269d325f654f8bf2b607d84b6eaff4ec2f44d9f5181a8e285f5f
4
+ data.tar.gz: 965ac39efad07eee3e8dc32b0533e979bc39ffa55c0042ac38719107cdbe9720
5
5
  SHA512:
6
- metadata.gz: dbfa31585cea6678aec9b4e0b7fa592f439e4d2f3aa9428faa7583a9c32a701a880343e66843c8ef7afa9d146b8a2542a078c2de622211750fe8c516ddbe0bed
7
- data.tar.gz: b1655ba9a3639df1ac3d26b15297d3909e1fbfb6f323152f3a8bf3aca956d229d7d848bbc291a438c2aa5069a0d889f4f1c4b14280868ab33011160611847219
6
+ metadata.gz: 1b16a4512fae780cdc43f4494886c882f3eb9ac7625e84beb7958a46fdc58c78d809607277de9806b6cbd9a1e35b1667f71a86237483f755fe5cd013e5c7244e
7
+ data.tar.gz: 2baad1d37a76b09c9752c1a74249a9ec0566aeb8699a56340f94e7ee126d3733b925f276faa4db4f3a7543afc8457e4e40e7f34fc14c41c121a95cecba2d99e5
data/README.md CHANGED
@@ -1,6 +1,27 @@
1
1
  # ActionviewPrecompiler
2
2
 
3
- Precompiles ActionView templates at app boot.
3
+ Provides eager loading of ActionView templates.
4
+
5
+ This optimization aims to improve cold render times and to allow more memory to be shared via CoW on forking web servers.
6
+
7
+ For more information see:
8
+
9
+ * https://www.johnhawthorn.com/2019/09/precompiling-rails-templates/
10
+ * Aaron Patterson's [RailsConf 2019 Keynote](https://www.youtube.com/watch?v=8Dld5kFWGCc)
11
+ * John Hawthorn's ["Parsing and Rewriting Ruby Templates" (slides)](https://www.slideshare.net/JohnHawthorn4/parsing-and-rewriting-ruby-templates)
12
+
13
+ ## Should I use this?
14
+
15
+ You probably don't need to.
16
+
17
+ This gem provides a place to test out an optimization we hope to eventually include in Rails where everyone can gain this benefit without any additional work or configuration :hugs:.
18
+ Right now I would love help validating that it (at least somewhat) accurately detects rendered views in your application :heart:.
19
+
20
+ That said, it shows [promising results](https://www.johnhawthorn.com/2019/09/precompiling-rails-templates/) today :chart_with_downwards_trend: so if you've measured that view compilation is an issue this should help! Please let me know!
21
+
22
+ The most likely downside of using this is that if this mispredicts render calls it will waste a little memory (somewhat ironically, since one goal is to save memory).
23
+
24
+ ## How it works
4
25
 
5
26
  The main challenge in precompiling these templates is determining the locals they're going to be passed.
6
27
  Without the initialization, local vars look the same as method calls, so we need to compile separate copies for each different set of local variable passed in.
@@ -27,13 +48,21 @@ And then execute:
27
48
 
28
49
  ## Usage
29
50
 
51
+ To precompile views on app boot, create an initializer to perform precompilation
52
+
30
53
  ``` ruby
54
+ # config/initializers/actionview_precompiler.rb
31
55
  ActionviewPrecompiler.precompile
32
56
  ```
33
57
 
58
+ It can also be run in verbose mode, which I use to tell which views it has detected. I usually run this in a console
59
+
60
+ ``` ruby
61
+ ActionviewPrecompiler.precompile(verbose: true)
62
+ ```
63
+
34
64
  ## TODO
35
65
 
36
- * Doesn't understand (common) relative renders: `render "form"`
37
66
  * Support more `render` invocations
38
67
  * Parse controllers/helpers for more renders
39
68
  * Cache detected locals to avoid parsing cost
@@ -28,7 +28,7 @@ module ActionviewPrecompiler
28
28
  end
29
29
 
30
30
  def array?
31
- type == :ARRAY
31
+ type == :ARRAY || type == :LIST
32
32
  end
33
33
 
34
34
  def fcall?
@@ -1,3 +1,3 @@
1
1
  module ActionviewPrecompiler
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview_precompiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-25 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -84,7 +84,8 @@ files:
84
84
  - lib/actionview_precompiler/template_parser.rb
85
85
  - lib/actionview_precompiler/version.rb
86
86
  homepage: https://github.com/jhawthorn/actionview_precompiler
87
- licenses: []
87
+ licenses:
88
+ - MIT
88
89
  metadata: {}
89
90
  post_install_message:
90
91
  rdoc_options: []
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  - !ruby/object:Gem::Version
102
103
  version: '0'
103
104
  requirements: []
104
- rubygems_version: 3.0.3
105
+ rubygems_version: 3.1.0.pre3
105
106
  signing_key:
106
107
  specification_version: 4
107
108
  summary: Precompiles ActionView templates