humid 0.0.1 → 0.0.2

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: 331e268f4bfc9f9b46e4246a9fb1af56245616bedecfb13a9b220040fca74636
4
- data.tar.gz: 87631778cddbd5511202a0a3aaaa54fb6827b8aee8bdae29f80297ee6764cd55
3
+ metadata.gz: 3cd194cc5fb744d074ef3d6e8599399e67badcf850c2d499ab13b7e6a642b3fd
4
+ data.tar.gz: 181241a3e3cf678560deb8c053dcb43f7ab5dae4257b735e2582e9ecadac16e1
5
5
  SHA512:
6
- metadata.gz: 5161834e3f6b0a8d6cb9e991965df392491e204373c0ec54773cf114f8c489be88f435a5d6ba90c226dc6a698ea053ca3ccaf64581cb01399272057ecb600990
7
- data.tar.gz: a545a0ffb5c7f1dfdf333bb960566a28fb355fd3dfc60ede7ed88f3210f507ca21e7b389138c07b2a773903110df66b7e60df844a57815c0a87fb624a15ee44c
6
+ metadata.gz: 25db74cf8176dc280e2739b61995969a91eb893063020b7c455553ab2a5d571b4f402c96943bc9e8bb66541612e535e9a030e1ab28e7ca849baf1f9e77c0208e
7
+ data.tar.gz: 39ca3a3b46f5426e81c3811591d6e6a6f54fde304e9531f5a37490c380dd4272bfac9b3afa44997391fe6987e9927d3ac1ff3b52a51131841f6ae84bc12fe66d
data/README.md CHANGED
@@ -36,8 +36,8 @@ Humid.configure do |config|
36
36
  # name of your webpacker pack. Defaults to "server_rendering.js"
37
37
  config.server_rendering_source = "server_rendering.js"
38
38
 
39
- # name of your webpacker pack source map. Defaults to `nil`
40
- config.server_rendering_source_map = "server_rendering.js.map"
39
+ # name of your webpacker pack source map. Defaults to `false`
40
+ config.use_source_map = true
41
41
 
42
42
  # The logger instance. Defaults to `Logger.new(STDOUT)`
43
43
  # `console.log` and friends (`warn`, `error`) are delegated to
@@ -56,7 +56,7 @@ end
56
56
  ```
57
57
 
58
58
  If you'd like support for source map support, you will need to
59
- 1. Ensure `config.server_rendering_source_map` has a value
59
+ 1. Ensure `config.use_source_map` is set to `true`
60
60
  2. Add the following to your `server_rendering.js` pack.
61
61
 
62
62
  ```javascript
data/lib/humid.rb CHANGED
@@ -15,8 +15,8 @@ module Humid
15
15
  "server_rendering.js"
16
16
  end
17
17
 
18
- config_accessor :server_rendering_source_map do
19
- nil
18
+ config_accessor :use_source_map do
19
+ false
20
20
  end
21
21
 
22
22
  config_accessor :logger do
@@ -84,12 +84,16 @@ module Humid
84
84
  ctx.eval(js)
85
85
 
86
86
  public_path = Webpacker.config.public_path
87
- asset_path = public_path.join(Webpacker.manifest.lookup(config.server_rendering_file)[1..-1])
88
- filename = File.basename(asset_path.to_s)
89
- ctx.eval(File.read(asset_path), filename: filename)
87
+ server_rendering_file = config.server_rendering_file
88
+ server_rendering_map = "#{config.server_rendering_file}.map"
90
89
 
91
- if config.server_rendering_source_map
92
- map_path = public_path.join(Webpacker.manifest.lookup(config.server_rendering_source_map)[1..-1])
90
+ source_path = public_path.join(Webpacker.manifest.lookup(server_rendering_file)[1..-1])
91
+ map_path = public_path.join(Webpacker.manifest.lookup(server_rendering_map)[1..-1])
92
+
93
+ filename = File.basename(source_path.to_s)
94
+ ctx.eval(File.read(source_path), filename: filename)
95
+
96
+ if config.use_source_map
93
97
  ctx.attach("readSourceMap", proc { File.read(map_path) })
94
98
  end
95
99
 
data/lib/humid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Humid
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.2".freeze
3
3
  end
data/spec/render_spec.rb CHANGED
@@ -119,9 +119,7 @@ RSpec.describe "Humid" do
119
119
 
120
120
  it "can use source maps to see errors" do
121
121
  allow(Humid.config).to receive("server_rendering_file") { "reporting.js" }
122
- allow(Humid.config).to receive("server_rendering_source_map") {
123
- "reporting.js.map"
124
- }
122
+ allow(Humid.config).to receive("use_source_map") { true }
125
123
 
126
124
  Humid.create_context
127
125
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johny Ho