device_detector_regexes 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +18 -2
- data/bin/console +5 -3
- data/device_detector_regexes.gemspec +21 -18
- data/lib/device_detector_regexes.rb +21 -21
- data/lib/device_detector_regexes/version.rb +3 -1
- metadata +16 -2
- data/lib/device_detector_regexes/device_detector.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa92b28e6542f50833c1ea09bc983cd68a1a1bf81432769cf363ca1f7e35039
|
4
|
+
data.tar.gz: 26e4ce16e1e5fb4220531911b526b39025b2512acb30b5e52c369401969eb18e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 606a041f2257a535298fd6ee3924d93e1edace18fc99e655adb0a4d173acab91c5f4c920d61a252bf1aaba9db7deb07fba6d2aaa4dd9f2d315a43771b95d9ea0
|
7
|
+
data.tar.gz: 51e5e8c098816dd0bf12e3eb4ed6011d30ad2e2392760d206d72cd727e552d377d2937bb6ce3fbc1326c4ea99048200458407968930bd347e37756eb5c1c6019
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,15 +7,31 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
ast (2.4.0)
|
10
11
|
device_detector (1.0.3)
|
11
|
-
|
12
|
+
jaro_winkler (1.5.4)
|
13
|
+
parallel (1.19.1)
|
14
|
+
parser (2.7.0.4)
|
15
|
+
ast (~> 2.4.0)
|
16
|
+
rainbow (3.0.0)
|
17
|
+
rexml (3.2.4)
|
18
|
+
rubocop (0.80.1)
|
19
|
+
jaro_winkler (~> 1.5.1)
|
20
|
+
parallel (~> 1.10)
|
21
|
+
parser (>= 2.7.0.1)
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
23
|
+
rexml
|
24
|
+
ruby-progressbar (~> 1.7)
|
25
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
26
|
+
ruby-progressbar (1.10.1)
|
27
|
+
unicode-display_width (1.6.1)
|
12
28
|
|
13
29
|
PLATFORMS
|
14
30
|
ruby
|
15
31
|
|
16
32
|
DEPENDENCIES
|
17
33
|
device_detector_regexes!
|
18
|
-
|
34
|
+
rubocop
|
19
35
|
|
20
36
|
BUNDLED WITH
|
21
37
|
1.17.2
|
data/bin/console
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'device_detector_regexes'
|
5
7
|
|
6
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
9
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +12,5 @@ require "device_detector_regexes"
|
|
10
12
|
# require "pry"
|
11
13
|
# Pry.start
|
12
14
|
|
13
|
-
require
|
15
|
+
require 'irb'
|
14
16
|
IRB.start(__FILE__)
|
@@ -1,30 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/device_detector_regexes/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name
|
5
|
-
spec.version
|
6
|
-
spec.authors
|
7
|
-
spec.email
|
6
|
+
spec.name = 'device_detector_regexes'
|
7
|
+
spec.version = DeviceDetectorRegexes::VERSION
|
8
|
+
spec.authors = ['Kirill Karpinovsky']
|
9
|
+
spec.email = ['karpinovsky@gmail.com']
|
8
10
|
|
9
|
-
spec.summary
|
10
|
-
spec.description
|
11
|
-
spec.homepage
|
12
|
-
spec.license
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = 'device_detector regexes extender'
|
12
|
+
spec.description = 'DeviceDetectorRegexes is an extension for device_detector gem that makes it easy to add new regular expressions'
|
13
|
+
spec.homepage = 'https://github.com/karpinovsky/device_detector_regexes'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
16
|
|
15
|
-
spec.metadata[
|
16
|
-
spec.metadata[
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/karpinovsky/device_detector_regexes/issues'
|
19
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/karpinovsky/device_detector_regexes/blob/master/CHANGELOG.md'
|
19
21
|
|
20
|
-
spec.extra_rdoc_files = Dir[
|
22
|
+
spec.extra_rdoc_files = Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt']
|
21
23
|
|
22
|
-
spec.files
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
26
|
end
|
25
|
-
spec.bindir =
|
27
|
+
spec.bindir = 'exe'
|
26
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
29
|
+
spec.require_paths = ['lib']
|
28
30
|
|
29
|
-
spec.add_dependency
|
31
|
+
spec.add_dependency 'device_detector'
|
32
|
+
spec.add_development_dependency 'rubocop'
|
30
33
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'device_detector'
|
2
4
|
|
3
5
|
module DeviceDetectorRegexes; end
|
4
6
|
|
@@ -14,32 +16,30 @@ class DeviceDetector
|
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
class
|
20
|
-
|
21
|
-
|
20
|
+
class Parser
|
21
|
+
def filepaths
|
22
|
+
filenames.each_with_object([]) do |filename, filenames|
|
23
|
+
# push custom files first due to higher precedence lookup than default files
|
24
|
+
custom_file_path = File.expand_path(filename, File.join(DeviceDetector.config.dir, 'regexes'))
|
25
|
+
filenames << [filename.to_sym, custom_file_path] if File.exist?(custom_file_path)
|
22
26
|
|
23
|
-
|
24
|
-
custom_file_path = File.expand_path(filename, File.join(DeviceDetector.config.dir, "regexes"))
|
25
|
-
if File.exists?(custom_file_path)
|
26
|
-
filenames << [filename.to_sym, custom_file_path]
|
27
|
+
filenames << [filename.to_sym, File.join(ROOT, 'regexes', filename)]
|
27
28
|
end
|
28
|
-
|
29
|
-
filenames << [filename.to_sym, File.join(ROOT, "regexes", filename)]
|
30
29
|
end
|
31
|
-
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
def parse_regexes(path, raw_regexes)
|
32
|
+
raw_regexes.map do |meta|
|
33
|
+
raise "invalid device spec: #{meta.inspect}" unless meta[:regex].is_a? String
|
34
|
+
|
35
|
+
meta[:regex] = build_regex(meta[:regex], meta[:prefix])
|
36
|
+
meta[:path] = path
|
37
|
+
meta
|
38
|
+
end
|
39
39
|
end
|
40
|
-
end
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
def build_regex(src, prefix = true)
|
42
|
+
Regexp.new (prefix ? '(?:^|[^A-Z0-9\-_]|[^A-Z0-9\-]_|sprd-)(?:' + src + ')' : src), Regexp::IGNORECASE
|
43
|
+
end
|
44
44
|
end
|
45
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: device_detector_regexes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Karpinovsky
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: DeviceDetectorRegexes is an extension for device_detector gem that makes
|
28
42
|
it easy to add new regular expressions
|
29
43
|
email:
|
@@ -36,6 +50,7 @@ extra_rdoc_files:
|
|
36
50
|
- LICENSE.txt
|
37
51
|
files:
|
38
52
|
- ".gitignore"
|
53
|
+
- ".rubocop.yml"
|
39
54
|
- CHANGELOG.md
|
40
55
|
- CODE_OF_CONDUCT.md
|
41
56
|
- Gemfile
|
@@ -47,7 +62,6 @@ files:
|
|
47
62
|
- bin/setup
|
48
63
|
- device_detector_regexes.gemspec
|
49
64
|
- lib/device_detector_regexes.rb
|
50
|
-
- lib/device_detector_regexes/device_detector.rb
|
51
65
|
- lib/device_detector_regexes/version.rb
|
52
66
|
homepage: https://github.com/karpinovsky/device_detector_regexes
|
53
67
|
licenses:
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# module DeviceDetectorRegexes
|
2
|
-
# def self.included(base)
|
3
|
-
# base.extend(Dry::Configurable)
|
4
|
-
# base.instance_eval do
|
5
|
-
# setting(:custom_dir, "/Users/kirill/Work/device_detector_regexes") { |dir| Pathname(dir) }
|
6
|
-
# end
|
7
|
-
# base.extend(ClassMethods)
|
8
|
-
# end
|
9
|
-
|
10
|
-
# module ClassMethods
|
11
|
-
# extend Dry::Configurable
|
12
|
-
# setting(:custom_dir, Dir.pwd) { |dir| Pathname(dir) }
|
13
|
-
# end
|
14
|
-
# end
|