sewing_kit 0.95.0 → 0.95.1

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: 6b602141d9384dbe196746242130707db37ed8cc877f50b36364b3c8e15a018f
4
- data.tar.gz: b9669c5e2666ae28ae2f3ad6228cff9b6e969e73da05855224ba8acc837cf437
3
+ metadata.gz: 41ebcd8335cbea9ad813df8116ee2d9eb628ae279a01ad072d167980a534e932
4
+ data.tar.gz: cc99f63e71559984cf6616b5594f2dcba064916bfa452bdd623fc9152ee7b04e
5
5
  SHA512:
6
- metadata.gz: e05bd301abc39d37c44b660cc56d35874de2a4d527012e872a6bf76f46b88079d8e683a8dd983ea3eadd267a3a7f054f4ad65685f823dac5784d2f655e39672c
7
- data.tar.gz: 53129c412805f4a5cc602566d0add516693a1e5f723045def7826498884dbaa314f8338b9ae887ae095b6b3182586c117a68af68d3c1f8d4214e3cc573399e9a
6
+ metadata.gz: f525e31bf2ac93cd30c426cc89c0db275d8126d99a370cc883b913dc70868e4bfea26b674365984bedfe9cc08d2afd97d1fec7544db9758d461e404babe6b614
7
+ data.tar.gz: 5aa0cc16500aa6a98404da3ac96402d04ea0f85b453581f83a3b996914955467587d120f4ddca4d2d89a3598f51e1bb09eb41713c152b6f5e25b8ae9d03ecf08
data/README.md CHANGED
@@ -229,11 +229,17 @@ By moving everything into `package.json#dependencies`. This is necessary because
229
229
  Ideally, by deploying to a `staging` environment. If that is not possible, a production-like local development experience is available via:
230
230
 
231
231
  ```sh
232
- NODE_ENV=production bundle exec rake assets:precompile
232
+ NODE_ENV=production SK_SIMULATE_PRODUCTION=1 bundle exec rake assets:precompile
233
233
  NODE_ENV=production SK_SIMULATE_PRODUCTION=1 dev run
234
234
  ```
235
235
 
236
- Note that code changes will not be automatically recompiled in this state. After verifying production behaviour, run `bundle exec rake assets:clobber` to get back to development mode.
236
+ Note:
237
+
238
+ - Code changes will not be automatically recompiled in this state
239
+ - `SK_SIMULATE_PRODUCTION` does not make Rails itself run in production mode
240
+ - The most accurate way to gauge performance of the production version of an application is via a `staging` environment
241
+
242
+ After verifying production behaviour, run `bundle exec rake assets:clobber` to get back to development mode.
237
243
 
238
244
  ### My project is using `sprockets-commoner`, can I use sewing_kit too?
239
245
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.95.0"
3
+ VERSION = "0.95.1"
4
4
  end
@@ -1,13 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
  require 'sewing_kit/webpack/manifest/base'
3
+ require 'benchmark'
3
4
  require 'browserslist_useragent'
4
5
 
5
6
  module SewingKit
6
7
  module Webpack
7
8
  class Manifest
8
9
  class Production < Base
9
- @metadata = nil
10
- @metadata_path = nil
10
+ def initialize
11
+ @cache_by_user_agent = {}
12
+ @metadata = nil
13
+ @metadata_path = nil
14
+ end
11
15
 
12
16
  def asset_bundle_name(user_agent)
13
17
  metadata_for(user_agent)['name']
@@ -25,14 +29,20 @@ module SewingKit
25
29
  private
26
30
 
27
31
  def metadata_for(user_agent)
28
- if metadata.is_a?(Array)
29
- find_matching_metadata(metadata, user_agent)
30
- else
31
- metadata
32
+ time = Benchmark.realtime do
33
+ @cache_by_user_agent[user_agent] ||= find_matching_metadata(metadata, user_agent)
32
34
  end
35
+
36
+ Rails.logger.debug(
37
+ "[sewing_kit] found asset metadata for #{user_agent} in #{time * 1000} milliseconds"
38
+ )
39
+
40
+ @cache_by_user_agent[user_agent]
33
41
  end
34
42
 
35
43
  def find_matching_metadata(consolidated_metadata, user_agent)
44
+ return metadata unless metadata.is_a?(Array)
45
+
36
46
  found = consolidated_metadata.find do |metadata|
37
47
  return nil if metadata["resolvedBrowsers"].nil?
38
48
  matcher = BrowserslistUseragent::Match.new(metadata["resolvedBrowsers"], user_agent)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sewing_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.95.0
4
+ version: 0.95.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sauve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties