webpack_stats 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webpack_stats.rb +13 -15
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 476c287a597979cac309b55344a0f476f9b0b168
4
- data.tar.gz: 3ebc2d616d3cd7acbab52163ac72ab9c0d9a05c5
3
+ metadata.gz: d8623a3f007c05887c26231a507819042099d024
4
+ data.tar.gz: 0c2efbcd0fe7e535efc3c7189f9742b0c0dab9d8
5
5
  SHA512:
6
- metadata.gz: ed395086675f965c920e6f9f00ee392c9d909233a13eddc444b63ca2ab7dce8c130dfaa5e9dfcdc19961eff63dd00cfccb6cd49366850e30c21780e523b48289
7
- data.tar.gz: b99862ade978a7adf167ac8ebd8acde35cdd3ab52ab0e5c3b32a4f7433e42959b5f91b9fe44de8565e9474b360390f0d01ea23a26ef3977f621022cb8fe0f763
6
+ metadata.gz: 96f51cfb98c53704c674df7bef5020c96f3ebcf387ce1263a18d0b384e3b8ff319e26ce983c78921166ba26372b53b33c430221f5dd54a205217cb35ede3e96d
7
+ data.tar.gz: 906ec6ebb399977e46bebc2899b16cea08e437cf4b3cce1933d998ba47c78f1c8c747000fa9318ae9ed288691e1f748438d2700f098a8b347de936db9a6a8752
data/lib/webpack_stats.rb CHANGED
@@ -15,25 +15,22 @@ module WebpackStats
15
15
  end
16
16
 
17
17
  def assets
18
- @reload ? load_assets : @assets ||= load_assets
18
+ load! if @reload || !@assets
19
+ @assets
19
20
  end
20
21
 
21
22
  def stats
22
- @reload ? load_stats : @stats ||= load_stats
23
+ load! if @reload || !@stats
24
+ @stats
23
25
  end
24
26
 
25
- def load_stats
26
- JSON.parse File.read @stats_path
27
- end
28
-
29
- def load_assets
30
- ret = {}
31
- _stats = stats
32
- _stats['assets'].each do |asset|
33
- key, value = split_asset_name(_stats, asset['name'])
34
- ret[key] = value
27
+ def load!
28
+ @stats = JSON.parse File.read @stats_path
29
+ @assets = {}
30
+ @stats['assets'].each do |asset|
31
+ key, value = split_asset_name(@stats, asset['name'])
32
+ @assets[key] = value
35
33
  end
36
- ret
37
34
  end
38
35
 
39
36
  def split_asset_name stats, asset_name
@@ -62,8 +59,9 @@ begin
62
59
 
63
60
  ActiveSupport.on_load(:after_initialize) do
64
61
  WebpackStats.configure do |config|
65
- config.reload = Rails.env.production? ? false : true
62
+ config.reload = !Rails.env.production?
66
63
  config.stats_path = Rails.root.join('stats.json')
67
64
  end
68
65
  end
69
- end
66
+ rescue LoadError
67
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpack_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jian Weihang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler