-
Notifications
You must be signed in to change notification settings - Fork 44
/
Rakefile
75 lines (58 loc) · 1.66 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
require 'rake/testtask'
require 'bundler'
task default: :test
desc 'Run tests'
Rake::TestTask.new do |t|
t.warning = true
t.verbose = true
t.pattern = 'spec/*_spec.rb'
end
Bundler::GemHelper.install_tasks
# Does not actually get all families, as some are only listed in the regexes,
# but gives you a pretty good idea of what will be returned.
desc 'Lists all unique family names for browsers and operating systems.'
task :families do
require 'pathname'
require 'pp'
root = Pathname(__FILE__).dirname
path = root.join('vendor', 'uap-core')
browser_families = paths_to_families(
[
# path.join('tests', 'test_ua.yaml'),
path.join('test_resources', 'firefox_user_agent_strings.yaml'),
path.join('test_resources', 'pgts_browser_list.yaml')
]
)
os_families = paths_to_families(
[
# path.join('tests', 'test_os.yaml'),
path.join('test_resources', 'additional_os_tests.yaml')
]
)
device_families = paths_to_families(
[
# path.join('tests', 'test_device.yaml'),
]
)
puts "\n\nBrowser Families"
puts browser_families.inspect
puts "\n\nOS Families"
puts os_families.inspect
puts "\n\nDevice Families"
puts device_families.inspect
puts "\n\n"
puts "Browser Family Count: #{browser_families.size}"
puts "OS Family Count: #{os_families.size}"
puts "Device Family Count: #{device_families.size}"
end
def paths_to_families(paths)
require 'yaml'
families = []
paths.each do |path|
data = YAML.load_file(path)
test_cases = data.fetch('test_cases')
families.concat test_cases.map { |row| row['family'] }
end
families.compact.uniq.sort
end