New upstream release.
Debian Janitor
11 months ago
12 | 12 | fail-fast: false |
13 | 13 | matrix: |
14 | 14 | ruby: |
15 | - '3.2' | |
15 | 16 | - '3.1' |
16 | 17 | - '3.0' |
17 | - '2.7' | |
18 | - '2.6' | |
19 | - '2.5' | |
20 | - 'jruby' | |
18 | - 'jruby-9.3.8.0' | |
21 | 19 | include: |
22 | - ruby: '3.1' | |
23 | coverage: 'true' | |
20 | - ruby: '3.2' | |
21 | coverage: '1' | |
24 | 22 | steps: |
25 | - uses: actions/checkout@v2 | |
23 | - uses: actions/checkout@v3 | |
26 | 24 | with: |
27 | 25 | submodules: true |
28 | 26 | - name: Setup Ruby |
32 | 30 | - name: Update rubygems |
33 | 31 | run: | |
34 | 32 | gem update --system |
35 | - uses: actions/cache@v2 | |
33 | - uses: actions/cache@v3 | |
36 | 34 | with: |
37 | 35 | path: vendor/bundle |
38 | 36 | key: bundle-use-ruby-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }} |
44 | 42 | bundle install --jobs 4 --retry 3 |
45 | 43 | - name: Run specs |
46 | 44 | env: |
47 | GITHUB_COVERAGE: ${{ matrix.coverage }} | |
45 | SIMPLECOV: ${{ matrix.coverage }} | |
48 | 46 | run: | |
49 | 47 | bundle exec rake test |
50 | 48 |
0 | 0 | # master |
1 | ||
2 | # 2.15.0 (2023-04-12) | |
3 | * Expose `parse_os`, `parse_device` and `parse_ua` methods on `Parser` | |
4 | ||
5 | # 2.14.0 (2023-01-31) | |
6 | * Sync with https://github.com/ua-parser/uap-core/commit/1ef0926f2b489cc929589c00f8b8a3efce25acc3 | |
1 | 7 | |
2 | 8 | # 2.13.0 (2022-10-21) |
3 | 9 | * Support loading multiple database files (via #70) (@misdoro) |
0 | 0 | PATH |
1 | 1 | remote: . |
2 | 2 | specs: |
3 | user_agent_parser (2.13.0) | |
3 | user_agent_parser (2.15.0) | |
4 | 4 | |
5 | 5 | GEM |
6 | 6 | remote: https://rubygems.org/ |
7 | 7 | specs: |
8 | coveralls_reborn (0.25.0) | |
9 | simplecov (>= 0.18.1, < 0.22.0) | |
10 | term-ansicolor (~> 1.6) | |
11 | thor (>= 0.20.3, < 2.0) | |
12 | tins (~> 1.16) | |
8 | coveralls_reborn (0.27.0) | |
9 | simplecov (~> 0.22.0) | |
10 | term-ansicolor (~> 1.7) | |
11 | thor (~> 1.2) | |
12 | tins (~> 1.32) | |
13 | 13 | docile (1.4.0) |
14 | minitest (5.16.3) | |
14 | minitest (5.18.0) | |
15 | 15 | rake (13.0.6) |
16 | simplecov (0.21.2) | |
16 | simplecov (0.22.0) | |
17 | 17 | docile (~> 1.1) |
18 | 18 | simplecov-html (~> 0.11) |
19 | 19 | simplecov_json_formatter (~> 0.1) |
23 | 23 | term-ansicolor (1.7.1) |
24 | 24 | tins (~> 1.0) |
25 | 25 | thor (1.2.1) |
26 | tins (1.31.1) | |
26 | tins (1.32.1) | |
27 | 27 | sync |
28 | 28 | |
29 | 29 | PLATFORMS |
37 | 37 | user_agent_parser! |
38 | 38 | |
39 | 39 | BUNDLED WITH |
40 | 2.3.24 | |
40 | 2.4.10 |
3 | 3 | |
4 | 4 | ## Supported Rubies |
5 | 5 | |
6 | * Ruby 3.2 | |
7 | * Ruby 3.1 | |
6 | 8 | * Ruby 3.0 |
7 | * Ruby 2.7 | |
8 | * Ruby 2.6 | |
9 | * Ruby 2.5 | |
10 | 9 | * JRuby |
11 | 10 | |
12 | 11 | ## Installation |
0 | ruby-user-agent-parser (2.13.0-1) UNRELEASED; urgency=low | |
0 | ruby-user-agent-parser (2.15.0-1) UNRELEASED; urgency=low | |
1 | 1 | |
2 | 2 | * Set field Upstream-Contact in debian/copyright. |
3 | 3 | * Remove obsolete field Contact from debian/upstream/metadata (already present |
5 | 5 | * Bump debhelper from old 12 to 13. |
6 | 6 | * Update standards version to 4.5.1, no changes needed. |
7 | 7 | * New upstream release. |
8 | * New upstream release. | |
8 | 9 | |
9 | -- Debian Janitor <janitor@jelmer.uk> Fri, 20 Jan 2023 06:31:54 -0000 | |
10 | -- Debian Janitor <janitor@jelmer.uk> Thu, 25 May 2023 05:28:54 -0000 | |
10 | 11 | |
11 | 12 | ruby-user-agent-parser (2.5.1-2) unstable; urgency=medium |
12 | 13 |
38 | 38 | parse_ua(user_agent, os, device) |
39 | 39 | end |
40 | 40 | |
41 | def parse_os(user_agent) | |
42 | pattern, match = first_pattern_match(@os_patterns, user_agent) | |
43 | ||
44 | if match | |
45 | os_from_pattern_match(pattern, match) | |
46 | else | |
47 | OperatingSystem.new | |
48 | end | |
49 | end | |
50 | ||
51 | def parse_device(user_agent) | |
52 | pattern, match = first_pattern_match(@device_patterns, user_agent) | |
53 | ||
54 | if match | |
55 | device_from_pattern_match(pattern, match) | |
56 | else | |
57 | Device.new | |
58 | end | |
59 | end | |
60 | ||
61 | def parse_ua(user_agent, os = nil, device = nil) | |
62 | pattern, match = first_pattern_match(@ua_patterns, user_agent) | |
63 | ||
64 | if match | |
65 | user_agent_from_pattern_match(pattern, match, os, device) | |
66 | else | |
67 | UserAgent.new(nil, nil, os, device) | |
68 | end | |
69 | end | |
70 | ||
41 | 71 | def patterns_path |
42 | 72 | patterns_paths.first |
43 | 73 | end |
72 | 102 | pattern = pattern.dup |
73 | 103 | pattern[:regex] = Regexp.new(pattern.delete('regex'), pattern.delete('regex_flag') == 'i') |
74 | 104 | pattern |
75 | end | |
76 | end | |
77 | ||
78 | def parse_ua(user_agent, os = nil, device = nil) | |
79 | pattern, match = first_pattern_match(@ua_patterns, user_agent) | |
80 | ||
81 | if match | |
82 | user_agent_from_pattern_match(pattern, match, os, device) | |
83 | else | |
84 | UserAgent.new(nil, nil, os, device) | |
85 | end | |
86 | end | |
87 | ||
88 | def parse_os(user_agent) | |
89 | pattern, match = first_pattern_match(@os_patterns, user_agent) | |
90 | ||
91 | if match | |
92 | os_from_pattern_match(pattern, match) | |
93 | else | |
94 | OperatingSystem.new | |
95 | end | |
96 | end | |
97 | ||
98 | def parse_device(user_agent) | |
99 | pattern, match = first_pattern_match(@device_patterns, user_agent) | |
100 | ||
101 | if match | |
102 | device_from_pattern_match(pattern, match) | |
103 | else | |
104 | Device.new | |
105 | 105 | end |
106 | 106 | end |
107 | 107 |
16 | 16 | file_to_yaml(file)['test_cases'].map do |test_case| |
17 | 17 | { |
18 | 18 | 'user_agent_string' => test_case['user_agent_string'], |
19 | 'family' => test_case['family'], | |
20 | 'major' => test_case['major'], | |
21 | 'minor' => test_case['minor'], | |
22 | 'patch' => test_case['patch'], | |
23 | 'patch_minor' => test_case['patch_minor'], | |
24 | 'brand' => test_case['brand'], | |
25 | 'model' => test_case['model'] | |
19 | 'family' => test_case['family'], | |
20 | 'major' => test_case['major'], | |
21 | 'minor' => test_case['minor'], | |
22 | 'patch' => test_case['patch'], | |
23 | 'patch_minor' => test_case['patch_minor'], | |
24 | 'brand' => test_case['brand'], | |
25 | 'model' => test_case['model'] | |
26 | 26 | } |
27 | 27 | end.reject do |test_case| |
28 | 28 | # We don't do the hacky javascript user agent overrides |
176 | 176 | end |
177 | 177 | end |
178 | 178 | end |
179 | ||
180 | describe '#parse_os' do | |
181 | operating_system_test_cases.each do |test_case| | |
182 | it "parses OS for #{test_case_to_test_name(test_case)}" do | |
183 | operating_system = PARSER.parse_os(test_case['user_agent_string']) | |
184 | ||
185 | if test_case['family'] | |
186 | _(operating_system.family).must_equal_test_case_property(test_case, 'family') | |
187 | end | |
188 | ||
189 | if test_case['major'] | |
190 | _(operating_system.version.major).must_equal_test_case_property(test_case, 'major') | |
191 | end | |
192 | ||
193 | if test_case['minor'] | |
194 | _(operating_system.version.minor).must_equal_test_case_property(test_case, 'minor') | |
195 | end | |
196 | ||
197 | if test_case['patch'] | |
198 | _(operating_system.version.patch).must_equal_test_case_property(test_case, 'patch') | |
199 | end | |
200 | ||
201 | if test_case['patch_minor'] | |
202 | _(operating_system.version.patch_minor).must_equal_test_case_property(test_case, 'patch_minor') | |
203 | end | |
204 | end | |
205 | end | |
206 | end | |
207 | ||
208 | describe '#parse_device' do | |
209 | device_test_cases.each do |test_case| | |
210 | it "parses device for #{test_case_to_test_name(test_case)}" do | |
211 | device = PARSER.parse_device(test_case['user_agent_string']) | |
212 | ||
213 | if test_case['family'] | |
214 | _(device.family).must_equal_test_case_property(test_case, 'family') | |
215 | end | |
216 | ||
217 | if test_case['model'] | |
218 | _(device.model).must_equal_test_case_property(test_case, 'model') | |
219 | end | |
220 | ||
221 | if test_case['brand'] | |
222 | _(device.brand).must_equal_test_case_property(test_case, 'brand') | |
223 | end | |
224 | end | |
225 | end | |
226 | end | |
227 | ||
228 | describe '#parse_ua' do | |
229 | user_agent_test_cases.each do |test_case| | |
230 | it "parses UA for #{test_case_to_test_name(test_case)}" do | |
231 | user_agent = PARSER.parse_ua(test_case['user_agent_string']) | |
232 | ||
233 | assert_nil user_agent.os | |
234 | assert_nil user_agent.device | |
235 | ||
236 | if test_case['family'] | |
237 | _(user_agent.family).must_equal_test_case_property(test_case, 'family') | |
238 | end | |
239 | ||
240 | if test_case['major'] | |
241 | _(user_agent.version.major).must_equal_test_case_property(test_case, 'major') | |
242 | end | |
243 | ||
244 | if test_case['minor'] | |
245 | _(user_agent.version.minor).must_equal_test_case_property(test_case, 'minor') | |
246 | end | |
247 | ||
248 | if test_case['patch'] | |
249 | _(user_agent.version.patch).must_equal_test_case_property(test_case, 'patch') | |
250 | end | |
251 | end | |
252 | end | |
253 | end | |
254 | ||
179 | 255 | end |
0 | 0 | # frozen_string_literal: true |
1 | 1 | |
2 | require 'coveralls' | |
3 | require 'simplecov' | |
2 | if ENV['SIMPLECOV'] == '1' | |
3 | require 'coveralls' | |
4 | require 'simplecov' | |
4 | 5 | |
5 | SimpleCov.formatter = Coveralls::SimpleCov::Formatter | |
6 | SimpleCov.start do | |
7 | add_filter '/.bundle/' | |
8 | add_filter '/doc/' | |
9 | add_filter '/spec/' | |
10 | add_filter '/config/' | |
11 | merge_timeout 600 | |
6 | SimpleCov.formatter = Coveralls::SimpleCov::Formatter | |
7 | SimpleCov.start do | |
8 | add_filter '/.bundle/' | |
9 | add_filter '/doc/' | |
10 | add_filter '/spec/' | |
11 | add_filter '/config/' | |
12 | merge_timeout 600 | |
13 | end | |
12 | 14 | end |
13 | 15 | |
14 | 16 | require 'minitest/autorun' |