precompiled_assets 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +28 -0
- data/lib/precompiled_assets/manifest.rb +6 -1
- data/lib/precompiled_assets/version.rb +1 -1
- data/precompiled-assets.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f0320f9e06f583c9ef4ff7bbcd1aef431a96aec01aa6a45666545c4041af3f9
|
4
|
+
data.tar.gz: 46a10e8013605de64bc3e3f409249f0820df85290900b521d582408a9086e136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3758f0bc4631ea3bc7e1b0f32ca3d93591e01999715567e245f6f099fa8c4882e44291c898f5fa394308a9fdd8ac054c31e756a16585ce845632ee46c3e7f866
|
7
|
+
data.tar.gz: 7cff3b5686510acfda6d36c0bc3e7dde5347bdb3a25ebbb336a96908d0a331507c4e633cfab3a8b22845df59472b5cbbd9a04c6969d0608e7e0524d2eb71c68c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,8 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
+
### Configuration
|
25
|
+
|
24
26
|
In your `config/application.rb`, configure an `asset_path` which should be in your `public/` directory:
|
25
27
|
|
26
28
|
```ruby
|
@@ -45,6 +47,26 @@ Once that is set up, `javascript_include_tag('application.js')` or `image_path('
|
|
45
47
|
In the `development` Rails environment, the gem detects changes to the manifest and reloads the manifest automatically.
|
46
48
|
Hence, your development experience should be similar to other stacks, like with Propshaft or esbuild: You change assets, the manifest changes, Rails will then resolve to the updated asset paths. 🎉
|
47
49
|
|
50
|
+
### Accessing manifest or resolver manually
|
51
|
+
|
52
|
+
In views, you can use the helper method `asset_resolver` to access the (cached) resolver instance.
|
53
|
+
Otherwise, instantiate via `PrecompiledAssets::Resolver.new`.
|
54
|
+
|
55
|
+
To resolve an asset path, use `Resolver#resolve`:
|
56
|
+
```ruby
|
57
|
+
resolver = PrecompiledAssets::Resolver.new
|
58
|
+
resolver.resolve('application.js')
|
59
|
+
# => "/assets/application-HP2LS2UH.js"
|
60
|
+
```
|
61
|
+
|
62
|
+
If you want to know if assets were updated (e.g. when using etags), use `Manifest#updated_at`:
|
63
|
+
```ruby
|
64
|
+
resolver = PrecompiledAssets::Resolver.new
|
65
|
+
resolver.manifest.updated_at
|
66
|
+
# => (returns a Time instance)
|
67
|
+
```
|
68
|
+
|
69
|
+
Side note: `Manifest#updated_at` reads its motification time from the file system. If your production environments use a distributed file system, it is not recommended for etagging in production.
|
48
70
|
|
49
71
|
|
50
72
|
## Development
|
@@ -54,6 +76,12 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
|
|
54
76
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
55
77
|
|
56
78
|
|
79
|
+
## Roadmap
|
80
|
+
|
81
|
+
1. Add tests
|
82
|
+
2. Integrate into more existing applications to discover new features that we might need.
|
83
|
+
|
84
|
+
|
57
85
|
## Contributing
|
58
86
|
|
59
87
|
I am very eager to keep this gem lightweight and on topic.
|
@@ -19,9 +19,14 @@ module PrecompiledAssets
|
|
19
19
|
digested_paths.include?(path_or_pathname.to_s)
|
20
20
|
end
|
21
21
|
|
22
|
+
def updated_at
|
23
|
+
# Not intended for use in production environments.
|
24
|
+
@mtime || fetch_mtime
|
25
|
+
end
|
26
|
+
|
22
27
|
def expired?
|
23
28
|
# Not intended for use in production environments.
|
24
|
-
@
|
29
|
+
@time && @time != fetch_mtime
|
25
30
|
end
|
26
31
|
|
27
32
|
private
|
data/precompiled-assets.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
'rubygems_mfa_required' => 'true',
|
17
17
|
'homepage_uri' => spec.homepage,
|
18
18
|
'source_code_uri' => spec.homepage,
|
19
|
-
'changelog_uri' => "#{spec.homepage}/CHANGELOG.md",
|
19
|
+
'changelog_uri' => "#{spec.homepage}/blob/main/CHANGELOG.md",
|
20
20
|
}
|
21
21
|
|
22
22
|
spec.files = Dir.chdir(__dir__) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: precompiled_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arne Hartherz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -57,7 +57,7 @@ metadata:
|
|
57
57
|
rubygems_mfa_required: 'true'
|
58
58
|
homepage_uri: https://github.com/makandra/precompiled_assets
|
59
59
|
source_code_uri: https://github.com/makandra/precompiled_assets
|
60
|
-
changelog_uri: https://github.com/makandra/precompiled_assets/CHANGELOG.md
|
60
|
+
changelog_uri: https://github.com/makandra/precompiled_assets/blob/main/CHANGELOG.md
|
61
61
|
post_install_message:
|
62
62
|
rdoc_options: []
|
63
63
|
require_paths:
|