sewing_kit 0.95.3 → 0.95.4

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: 5326345174261f199f09dd225bff39a8bff36211605f02e50023cb42599cbbf0
4
- data.tar.gz: 4ce1b74f45294fbe3b3a78756e032ed5663ee8de7349a1ab3664fd7a0d7fd01c
3
+ metadata.gz: 8847792f430ca9ff0b5d9e2da35b701392636af48ac0435f9e82f816e4d9b385
4
+ data.tar.gz: cb61d56de21e9ae5e4c937313d2acfc213e10790cb8139c5b3e432ec76759f25
5
5
  SHA512:
6
- metadata.gz: 46b6f646a80548019b2504bcded4bfa5a2c9341dc712c2a34d2f5d574fbd52c1520c7868c72aabf1e6e148381b40e6fce96d1df43154073f5b996cb453a28568
7
- data.tar.gz: b84efa8493dc8d172087001a3058bef87be22fa2a74f0be1a60327495f7a54fd18cffe8f388ba044c67a138d68e410071faba1aa7e0cb129f61330ed9e0a2474
6
+ metadata.gz: f956eb534703a3b6f1bc57013be323209fec34ff1d34377757067cf42b6364ed399b88e37fa8db81401cc63909c80efebf68077e08cfdfdd7c1c93745d648f3a
7
+ data.tar.gz: 7dd03739b8f4677e9e5e55834af4481027a4b23a85413bfbdb9d46f7122455956e04a95290ba71378aa056e253c5ee29f19b8f1ed11c178b9c2c0c49e33db6b4
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.95.3"
3
+ VERSION = "0.95.4"
4
4
  end
@@ -43,14 +43,28 @@ module SewingKit
43
43
  def find_matching_metadata(consolidated_metadata, user_agent)
44
44
  return metadata unless metadata.is_a?(Array)
45
45
 
46
- found = consolidated_metadata.find do |metadata|
47
- return nil if metadata["resolvedBrowsers"].nil?
48
- matcher = BrowserslistUseragent::Match.new(metadata["resolvedBrowsers"], user_agent)
49
-
50
- matcher.browser? && matcher.version?(allow_higher: true)
46
+ found = consolidated_metadata.find do |metadata_item|
47
+ metadata_matches?(metadata_item, user_agent)
51
48
  end
52
49
 
53
- found || consolidated_metadata.last
50
+ found || baseline(consolidated_metadata)
51
+ end
52
+
53
+ def metadata_matches?(metadata_item, user_agent)
54
+ return false if metadata_item["resolvedBrowsers"].nil?
55
+
56
+ matcher = BrowserslistUseragent::Match.new(metadata_item["resolvedBrowsers"], user_agent)
57
+ matcher.browser? && matcher.version?(allow_higher: true)
58
+ rescue ArgumentError
59
+ # Some user_agent strings have bad semver versions.
60
+ # In these cases the Semver gem ends up throwing an ArgumentError when we parse the user_agent.
61
+ # Since we cannot know what kind of browser the user has when parsing fails,
62
+ # the safest option is to just return false here and let the defaulting logic send the baseline manifest.
63
+ false
64
+ end
65
+
66
+ def baseline(consolidated_metadata)
67
+ consolidated_metadata.last
54
68
  end
55
69
 
56
70
  def load_metadata
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.3
4
+ version: 0.95.4
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-10-07 00:00:00.000000000 Z
11
+ date: 2019-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties