browserslist_useragent 0.1.0 → 0.1.1
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 +4 -4
- data/.travis.yml +6 -1
- data/README.md +26 -10
- data/browserslist_useragent.gemspec +1 -1
- data/docker-compose.yml +18 -0
- data/lib/browserslist_useragent/resolver.rb +2 -2
- data/lib/browserslist_useragent/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d48db8ff1d8d84bf67f6a70366e6eb2a5f4bc3852e001a2455d085ad598abfec
|
4
|
+
data.tar.gz: 9ad0bc2e1a0000543940d16fe78deb81b55f424272381d0ebff6eef5bc5c129a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf5239b8cef74c83668615998bc8463d8f802c313252f87a61a49fe7666fbc997ed9e85d2c89b7b6d205337cef656a517dd59de39f31d70f8f9dc65944d65873
|
7
|
+
data.tar.gz: 38c9cc1ed88b1f2c6efe86c565278699b58f1424506fe9e97fdf7dd6f62354d765a5b03fbb282570b937a7cf0311fd6e7fb78c88bc645198219f9ac7bf6b4b19
|
data/.travis.yml
CHANGED
@@ -2,6 +2,11 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
4
|
- 2.5.1
|
5
|
-
|
6
5
|
notifications:
|
7
6
|
email: false
|
7
|
+
deploy:
|
8
|
+
provider: rubygems
|
9
|
+
api_key:
|
10
|
+
secure: 247ZARRKlVJb77qEQbzDNNIrFkVMfzWR2VvXu3Bgc/GjvreYkSmYxHgWRiq1RLlDNU8ug58/WFq4ZkIs5SolvlGO3jiD5NPrNRIW3T7WmGUEtOY7102nmlKlrLTttJloH61aeEamIfjMEvwl5y1gtBB2jxGmygYEfJ61J+gu3TInpYYpOI6AKM6DHC6lwvhsozixKAMBclKsmg3EOr/HQvVbgr1FPDzwNhZUQWQ6oXQF58PM7Rm19iwliiXFeCjM8y4V+ljO1RHUTrcMQ+h77Qy+vp9WJUxpqGsexS54QZHsQ59xw51F0Hap8Xq0vX6TmGrLFLZgfWutmI9JVNSk0/WOumMxiu4MMVPuvvgd0jj7sl7TjjHfkcFPzXUxsn4M2X8ILAm/yMCdS5fF0A94AcL8oICTYup7vmb0NgwgpRgLu6uzlOWmHDAytmdPtcExFmkD0KH9g+/Pv3aJf+qWRAIipCJlYcWrBAD7mBwbIM4mlE8HRYbS4TwgXBmtdH4BrZh1+73TnaBFD7DzzDVAFFza0uI3rafrB6MxccWdRya9KmbGUxK0kGnK24zXdVmC4pr7LJ4t8zldp87siq4p99vTNJw+amw7Yk/7a4MzwIWbmBE0lj1Qklq8pkiOf1oOt7J1zlum1TkhAOwqt4vhoXYcpka9fGU6uURlN/6iKco=
|
11
|
+
on:
|
12
|
+
tags: true
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# browserslist_useragent gem
|
1
|
+
# browserslist_useragent gem
|
2
|
+
[](https://badge.fury.io/rb/browserslist_useragent)
|
3
|
+
[](https://travis-ci.org/browserslist/browserslist-useragent-ruby)
|
2
4
|
|
3
5
|
<img align="right" width="120" height="120"
|
4
|
-
|
6
|
+
src="https://cdn.rawgit.com/pastelsky/browserslist-useragent/master/logo.svg" alt="Browserslist Useragent logo (original by Anton Lovchikov)" />
|
5
7
|
|
6
8
|
Find if a given user agent string satisfies a [Browserslist](https://github.com/ai/browserslist) browsers.
|
7
9
|
|
@@ -43,21 +45,21 @@ Run `bundle install`.
|
|
43
45
|
Define new helper in `app/helpers/application_helper.rb`:
|
44
46
|
|
45
47
|
```ruby
|
46
|
-
def
|
48
|
+
def supported_browser?
|
47
49
|
@browsers ||= JSON.parse(File.read(PATH_TO_BROWSERS_JSON))
|
48
50
|
matcher = BrowserslistUseragent::Match.new(@browsers, request.user_agent)
|
49
|
-
matcher.browser? &&
|
51
|
+
matcher.browser? && matcher.version?(allow_higher: true)
|
50
52
|
end
|
51
53
|
```
|
52
54
|
|
53
55
|
### 4. Use helper in template
|
54
56
|
|
55
|
-
Put
|
57
|
+
Put a warning message for users with an unsupported browser in `app/views/layouts/_unsupported_browser_warning` and add this check in application layout:
|
56
58
|
|
57
59
|
```haml
|
58
60
|
body
|
59
|
-
- if
|
60
|
-
render '
|
61
|
+
- if !supported_browser?
|
62
|
+
render 'layouts/unsupported_browser_warning'
|
61
63
|
```
|
62
64
|
|
63
65
|
### Separated projects
|
@@ -122,11 +124,25 @@ PRs to add more _browserslist supported_ browsers are welcome 👋
|
|
122
124
|
transpiling / autoprefixing for browsers, this behaviour is what's intended in most cases, but might surprise you otherwise.
|
123
125
|
* Right now, Chrome for Android and Firefox for Android are resolved to their desktop equivalents. The `caniuse` database does not currently store historical data for these browsers separately (except the last version) See [#156](https://github.com/ai/browserslist/issues/156)
|
124
126
|
|
125
|
-
## Development
|
127
|
+
## Development (with Docker))))
|
126
128
|
|
127
|
-
After checking out the repo, run
|
129
|
+
After checking out the repo, run:
|
128
130
|
|
129
|
-
|
131
|
+
```bash
|
132
|
+
docker-compose run app bundle install
|
133
|
+
```
|
134
|
+
|
135
|
+
Run tests with:
|
136
|
+
|
137
|
+
```bash
|
138
|
+
docker-compose run app bundle exec rspec
|
139
|
+
```
|
140
|
+
|
141
|
+
Run RuboCop with:
|
142
|
+
|
143
|
+
```bash
|
144
|
+
docker-compose run app bundle exec rubocop
|
145
|
+
```
|
130
146
|
|
131
147
|
## Contributing
|
132
148
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = 'Find if a given user agent string satisfies a browserslist query.'
|
13
13
|
spec.description = 'Provides easy way to match browser user agent string with specified set of rules (from browserslist tool)'
|
14
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.homepage = 'https://github.com/browserslist/browserlist-useragent-ruby'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
version: '3.4'
|
2
|
+
|
3
|
+
services:
|
4
|
+
app:
|
5
|
+
image: ruby:2.5.1
|
6
|
+
environment:
|
7
|
+
- BUNDLE_PATH=/bundle
|
8
|
+
- BUNDLE_CONFIG=/app/.bundle/config
|
9
|
+
command: bash
|
10
|
+
working_dir: /app
|
11
|
+
volumes:
|
12
|
+
- .:/app:cached
|
13
|
+
- bundler_data:/bundle
|
14
|
+
tmpfs:
|
15
|
+
- /tmp
|
16
|
+
|
17
|
+
volumes:
|
18
|
+
bundler_data:
|
@@ -17,9 +17,9 @@ module BrowserslistUseragent
|
|
17
17
|
family = agent.family
|
18
18
|
version = VersionNormalizer.new(agent.version.to_s).call
|
19
19
|
|
20
|
-
# Case A: For Safari, Chrome and others browsers
|
20
|
+
# Case A: For Safari, Chrome and others browsers on iOS
|
21
21
|
# that report as Safari after stripping tags
|
22
|
-
family = 'iOS' if agent.family.include?('Safari')
|
22
|
+
family = 'iOS' if agent.family.include?('Safari') && agent.os.family == 'iOS'
|
23
23
|
|
24
24
|
# Case B: The browser on iOS didn't report as safari,
|
25
25
|
# so we use the iOS version as a proxy to the browser
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browserslist_useragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salahutdinov Dmitry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|
@@ -127,13 +127,14 @@ files:
|
|
127
127
|
- bin/console
|
128
128
|
- bin/setup
|
129
129
|
- browserslist_useragent.gemspec
|
130
|
+
- docker-compose.yml
|
130
131
|
- lib/browserslist_useragent.rb
|
131
132
|
- lib/browserslist_useragent/match.rb
|
132
133
|
- lib/browserslist_useragent/query_normalizer.rb
|
133
134
|
- lib/browserslist_useragent/resolver.rb
|
134
135
|
- lib/browserslist_useragent/version.rb
|
135
136
|
- lib/browserslist_useragent/version_normalizer.rb
|
136
|
-
homepage: https://github.com/
|
137
|
+
homepage: https://github.com/browserslist/browserlist-useragent-ruby
|
137
138
|
licenses:
|
138
139
|
- MIT
|
139
140
|
metadata: {}
|
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
156
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.7.
|
157
|
+
rubygems_version: 2.7.7
|
157
158
|
signing_key:
|
158
159
|
specification_version: 4
|
159
160
|
summary: Find if a given user agent string satisfies a browserslist query.
|