Codebase list ruby-user-agent-parser / fresh-releases/main
New upstream release. Debian Janitor 10 months ago
10 changed file(s) with 154 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
1212 fail-fast: false
1313 matrix:
1414 ruby:
15 - '3.2'
1516 - '3.1'
1617 - '3.0'
17 - '2.7'
18 - '2.6'
19 - '2.5'
20 - 'jruby'
18 - 'jruby-9.3.8.0'
2119 include:
22 - ruby: '3.1'
23 coverage: 'true'
20 - ruby: '3.2'
21 coverage: '1'
2422 steps:
25 - uses: actions/checkout@v2
23 - uses: actions/checkout@v3
2624 with:
2725 submodules: true
2826 - name: Setup Ruby
3230 - name: Update rubygems
3331 run: |
3432 gem update --system
35 - uses: actions/cache@v2
33 - uses: actions/cache@v3
3634 with:
3735 path: vendor/bundle
3836 key: bundle-use-ruby-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
4442 bundle install --jobs 4 --retry 3
4543 - name: Run specs
4644 env:
47 GITHUB_COVERAGE: ${{ matrix.coverage }}
45 SIMPLECOV: ${{ matrix.coverage }}
4846 run: |
4947 bundle exec rake test
5048
0 3.1.2
0 3.2.2
00 # 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
17
28 # 2.13.0 (2022-10-21)
39 * Support loading multiple database files (via #70) (@misdoro)
00 PATH
11 remote: .
22 specs:
3 user_agent_parser (2.13.0)
3 user_agent_parser (2.15.0)
44
55 GEM
66 remote: https://rubygems.org/
77 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)
1313 docile (1.4.0)
14 minitest (5.16.3)
14 minitest (5.18.0)
1515 rake (13.0.6)
16 simplecov (0.21.2)
16 simplecov (0.22.0)
1717 docile (~> 1.1)
1818 simplecov-html (~> 0.11)
1919 simplecov_json_formatter (~> 0.1)
2323 term-ansicolor (1.7.1)
2424 tins (~> 1.0)
2525 thor (1.2.1)
26 tins (1.31.1)
26 tins (1.32.1)
2727 sync
2828
2929 PLATFORMS
3737 user_agent_parser!
3838
3939 BUNDLED WITH
40 2.3.24
40 2.4.10
33
44 ## Supported Rubies
55
6 * Ruby 3.2
7 * Ruby 3.1
68 * Ruby 3.0
7 * Ruby 2.7
8 * Ruby 2.6
9 * Ruby 2.5
109 * JRuby
1110
1211 ## 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
11
22 * Set field Upstream-Contact in debian/copyright.
33 * Remove obsolete field Contact from debian/upstream/metadata (already present
55 * Bump debhelper from old 12 to 13.
66 * Update standards version to 4.5.1, no changes needed.
77 * New upstream release.
8 * New upstream release.
89
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
1011
1112 ruby-user-agent-parser (2.5.1-2) unstable; urgency=medium
1213
3838 parse_ua(user_agent, os, device)
3939 end
4040
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
4171 def patterns_path
4272 patterns_paths.first
4373 end
72102 pattern = pattern.dup
73103 pattern[:regex] = Regexp.new(pattern.delete('regex'), pattern.delete('regex_flag') == 'i')
74104 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
105105 end
106106 end
107107
1616 file_to_yaml(file)['test_cases'].map do |test_case|
1717 {
1818 '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']
2626 }
2727 end.reject do |test_case|
2828 # We don't do the hacky javascript user agent overrides
176176 end
177177 end
178178 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
179255 end
00 # frozen_string_literal: true
11
2 require 'coveralls'
3 require 'simplecov'
2 if ENV['SIMPLECOV'] == '1'
3 require 'coveralls'
4 require 'simplecov'
45
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
1214 end
1315
1416 require 'minitest/autorun'
11
22 Gem::Specification.new do |gem|
33 gem.name = 'user_agent_parser'
4 gem.version = '2.13.0'
4 gem.version = '2.15.0'
55
66 gem.authors = 'Tim Lucas'
77 gem.email = 't@toolmantim.com'