asset_paths_from_manifest 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 77f7f718638154a291f2a7daeb4656be3e6d640b
4
- data.tar.gz: c622743de2625bae0403c6a510154269d458518b
3
+ metadata.gz: 534fb4aa8b559d6a35108dab782561beedf6d370
4
+ data.tar.gz: 36efc7dbe66584065b4e3f422528e66bf318dccc
5
5
  SHA512:
6
- metadata.gz: b1c0cf4fc35b24d32f210b85b8c97f27e0ab9d64f67536d8e7d13047eb4201c16d842492524da06f4bc9fc37071561a7a2bceed6d1fd02beb9b4d1857d29a8f9
7
- data.tar.gz: 305cf89ad991a866134c2bed2aaafc81284d49759bb94e093335ee5cea46ffa7c79b160ccd4d75148a444bf8c2290daf5d340967cbad7172aa42d57c7ebec9cf
6
+ metadata.gz: 43f8aad44872aac842eb9b84a47ee526d011ea7da3b3909cd85b5e682a9c90da1c34fa25143585c13e0fc6094725426d273f48cb23c2937e84213b2a8511b5b6
7
+ data.tar.gz: 88a85673f32eeaa46270b8ca25ec18654b6dc6c09e8351d8ab5fec73cec6f6772cee257d797d845033ae8573dcdf1b49d71718734ec9907230cc3ea737f5498a
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # AssetPathsFromManifest
2
+ [![Build Status](https://travis-ci.org/izumin5210/asset_paths_from_manifest.svg?branch=master)](https://travis-ci.org/izumin5210/asset_paths_from_manifest)
3
+ [![Gem Version](https://badge.fury.io/rb/asset_paths_from_manifest.svg)](https://badge.fury.io/rb/asset_paths_from_manifest)
4
+ [![license](https://img.shields.io/github/license/izumin5210/asset_paths_from_manifest.svg)](https://github.com/izumin5210/asset_paths_from_manifest/blob/master/LICENSE.txt)
2
5
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/asset_paths_from_manifest`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
+ Provides view helpers to compute full paths for assets from manifest json file.
6
7
 
7
8
  ## Installation
8
9
 
@@ -16,13 +17,45 @@ And then execute:
16
17
 
17
18
  $ bundle
18
19
 
19
- Or install it yourself as:
20
+ ## Usage
20
21
 
21
- $ gem install asset_paths_from_manifest
22
+ This module resolves asset paths using like following manifest json file.
22
23
 
23
- ## Usage
24
+ ```json
25
+ {
26
+ "client.js": "http://0.0.0.0:8080/client.js",
27
+ "client.js.map": "http://0.0.0.0:8080/client.js.map"
28
+ }
29
+ ```
30
+
31
+ ```json
32
+ {
33
+ "client.js": "/assets/client-8a4f666a18360aeafcfc.js"
34
+ }
35
+ ```
36
+
37
+ For instance, these json files can be generated `manifest.json` using webpack via [webpack-manifest-plugin](https://www.npmjs.com/package/webpack-manifest-plugin).
38
+
39
+ This module provides `javascript_include_tag_from_manifest`, `stylesheet_link_tag_from_manifest` and `asset_paths_from_manifest` view helpers.
40
+ You can use these helpers instead of `ActionView::Helpers::AssetTagHelper`'s helpers to resolve asset paths.
41
+
42
+ ```erb
43
+ <%= javascript_include_tag_from_manifest 'index' %>
44
+ <%= stylesheet_link_tag_from_manifest 'index' %>
45
+ ```
46
+
47
+ This module use `public/assets/manifest.json` in default.
48
+ You can modify manifest file path on initializer.
49
+
50
+ ```ruby
51
+ AssetPathsFromManifest.configure do |config|
52
+ config.manifest_json_path = Rails.root.join('public', 'client', 'manifest.json')
53
+ end
54
+ ```
24
55
 
25
- TODO: Write usage instructions here
56
+ ## Inspired
57
+ - [Squeezing Webpack into backend frameworks | Infinum](https://infinum.co/the-capsized-eight/squeezing-webpack-into-backend-frameworks)
58
+ - [webpacker/env.rb at master · rails/webpacker](https://github.com/rails/webpacker)
26
59
 
27
60
  ## Development
28
61
 
@@ -18,7 +18,7 @@ module AssetPathsFromManifest
18
18
  end
19
19
 
20
20
  def load
21
- @data = JSON.parse(File.read(@json_path))
21
+ @data = File.exist?(@json_path) ? JSON.parse(File.read(@json_path)) : {}.freeze
22
22
  end
23
23
 
24
24
  def lookup(name)
@@ -1,3 +1,3 @@
1
1
  module AssetPathsFromManifest
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_paths_from_manifest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - izumin5210