crawler_detect 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 673437c210276238f1622c6dee5d01546da01cfa84b24fb8cf2daab2b8de94cf
4
- data.tar.gz: 8a3e9b62efee0be6030022bdd2bfa2d029d278e0423f8cd30f19a6cae0ae4446
3
+ metadata.gz: abc20006d901205f658b54f78a94acb2480f3efbbc80213540381a1f956ce9d8
4
+ data.tar.gz: 53a3959effd4a78f93afa1d438ea06b6db567a3f3227311f24bbc7a1ea0d89fc
5
5
  SHA512:
6
- metadata.gz: 9cf065939aa5fd30f5b295f42a38095648abaaa17de39ec17eb483d0eef14e3be01d56e6ac334b567a0640b87f0a514be11922bdc612066d29610104d85a992b
7
- data.tar.gz: f6cae54635ef3224ba6b0289a5c9f199bd5630ca06c6a0d0b7efce8ce7df65d53ac179c1a23dd309ebf3d32348365e3e835f2484780f2a9f148e4934f7ed43b4
6
+ metadata.gz: '018d27fba7246b394e3cb5444cd8c0862e4ea08bf1b9e1fa12adb46d887b8753820ecbc103030c89af0b0e8ab05fa2c1d42ee33466685eaadfbc61b3185ef32f'
7
+ data.tar.gz: 02536c1035099e35961fafc9877a3d29d72ff5ed20848f2f4eb183d4fbbc300d6d5d7d68d23282e49e2a19ad589c04bc6ffb8dd8200e14b81a602286af924261
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  This changelog **does not contain** raw data updates
4
4
  but only major changes.
5
5
 
6
+ 1.2.0
7
+ ---------
8
+ - Speed up crawler detection by caching Regexp objects [#38]
9
+
6
10
  1.1.0
7
11
  ---------
8
12
  - Moves to Ruby's Stdlib JSON implementation to reduce dependencies
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crawler_detect (1.1.1)
4
+ crawler_detect (1.1.2)
5
5
  qonfig (~> 0.24)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.3.1)
10
+ activesupport (6.0.4.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
@@ -19,31 +19,31 @@ GEM
19
19
  rubocop-rails (= 2.5.2)
20
20
  rubocop-rake (= 0.5.1)
21
21
  rubocop-rspec (= 1.38.1)
22
- ast (2.4.0)
23
- awesome_print (1.8.0)
24
- byebug (11.1.2)
25
- coderay (1.1.2)
26
- concurrent-ruby (1.1.6)
27
- diff-lcs (1.3)
28
- fuubar (2.5.0)
22
+ ast (2.4.2)
23
+ awesome_print (1.9.2)
24
+ byebug (11.1.3)
25
+ coderay (1.1.3)
26
+ concurrent-ruby (1.1.9)
27
+ diff-lcs (1.4.4)
28
+ fuubar (2.5.1)
29
29
  rspec-core (~> 3.0)
30
30
  ruby-progressbar (~> 1.4)
31
- i18n (1.8.2)
31
+ i18n (1.8.10)
32
32
  concurrent-ruby (~> 1.0)
33
33
  jaro_winkler (1.5.4)
34
34
  method_source (1.0.0)
35
- minitest (5.14.1)
36
- parallel (1.19.1)
35
+ minitest (5.14.4)
36
+ parallel (1.20.1)
37
37
  parallel_tests (2.32.0)
38
38
  parallel
39
- parser (2.7.1.2)
40
- ast (~> 2.4.0)
41
- pry (0.13.1)
39
+ parser (3.0.2.0)
40
+ ast (~> 2.4.1)
41
+ pry (0.14.1)
42
42
  coderay (~> 1.1)
43
43
  method_source (~> 1.0)
44
- pry-byebug (3.9.0)
44
+ pry-byebug (3.8.0)
45
45
  byebug (~> 11.0)
46
- pry (~> 0.13.0)
46
+ pry (~> 0.10)
47
47
  pry-meta (0.0.10)
48
48
  awesome_print
49
49
  pry
@@ -52,26 +52,26 @@ GEM
52
52
  pry-remote (0.1.8)
53
53
  pry (~> 0.9)
54
54
  slop (~> 3.0)
55
- qonfig (0.24.1)
55
+ qonfig (0.26.0)
56
56
  rack (2.2.3)
57
57
  rack-test (1.1.0)
58
58
  rack (>= 1.0, < 3)
59
59
  rainbow (3.0.0)
60
- rake (13.0.1)
61
- rexml (3.2.4)
62
- rspec (3.9.0)
63
- rspec-core (~> 3.9.0)
64
- rspec-expectations (~> 3.9.0)
65
- rspec-mocks (~> 3.9.0)
66
- rspec-core (3.9.1)
67
- rspec-support (~> 3.9.1)
68
- rspec-expectations (3.9.1)
60
+ rake (13.0.6)
61
+ rexml (3.2.5)
62
+ rspec (3.10.0)
63
+ rspec-core (~> 3.10.0)
64
+ rspec-expectations (~> 3.10.0)
65
+ rspec-mocks (~> 3.10.0)
66
+ rspec-core (3.10.1)
67
+ rspec-support (~> 3.10.0)
68
+ rspec-expectations (3.10.1)
69
69
  diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.9.0)
71
- rspec-mocks (3.9.1)
70
+ rspec-support (~> 3.10.0)
71
+ rspec-mocks (3.10.2)
72
72
  diff-lcs (>= 1.2.0, < 2.0)
73
- rspec-support (~> 3.9.0)
74
- rspec-support (3.9.2)
73
+ rspec-support (~> 3.10.0)
74
+ rspec-support (3.10.2)
75
75
  rubocop (0.82.0)
76
76
  jaro_winkler (~> 1.5.1)
77
77
  parallel (~> 1.10)
@@ -90,13 +90,13 @@ GEM
90
90
  rubocop
91
91
  rubocop-rspec (1.38.1)
92
92
  rubocop (>= 0.68.1)
93
- ruby-progressbar (1.10.1)
93
+ ruby-progressbar (1.11.0)
94
94
  slop (3.6.0)
95
95
  thread_safe (0.3.6)
96
- tzinfo (1.2.7)
96
+ tzinfo (1.2.9)
97
97
  thread_safe (~> 0.1)
98
98
  unicode-display_width (1.7.0)
99
- zeitwerk (2.3.0)
99
+ zeitwerk (2.4.2)
100
100
 
101
101
  PLATFORMS
102
102
  ruby
@@ -5,12 +5,16 @@ module CrawlerDetect
5
5
  module Library
6
6
  DATA_CLASSES = [Library::Headers, Library::Exclusions, Library::Crawlers].freeze
7
7
 
8
+ @regexp_cache = {}
9
+
8
10
  class << self
9
11
  # @param param [String] Name of raw data
10
12
  # @return [Regexp]
11
13
  def get_regexp(param)
12
- data = get_array(param)
13
- %r{#{data.join('|')}}i
14
+ @regexp_cache[param] ||= begin
15
+ data = get_array(param)
16
+ %r{#{data.join('|')}}i
17
+ end
14
18
  end
15
19
 
16
20
  # @param param [String] Name of raw data
@@ -18,6 +22,12 @@ module CrawlerDetect
18
22
  def get_array(param)
19
23
  const_get("CrawlerDetect::Library::#{param.capitalize}").send(:data)
20
24
  end
25
+
26
+ # @return [void]
27
+ def reset_cache
28
+ DATA_CLASSES.each(&:reload_data)
29
+ @regexp_cache = {}
30
+ end
21
31
  end
22
32
  end
23
33
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # @since 0.1.0
4
4
  module CrawlerDetect
5
- VERSION = "1.1.2"
5
+ VERSION = "1.2.0"
6
6
  end
@@ -32,7 +32,7 @@ module CrawlerDetect
32
32
  # @param config [Proc]
33
33
  def setup!(&config)
34
34
  @config = CrawlerDetect::Config.new(&config)
35
- Library::DATA_CLASSES.each(&:reload_data)
35
+ Library.reset_cache
36
36
  end
37
37
 
38
38
  # @since 1.0.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crawler_detect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kozlov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-10 00:00:00.000000000 Z
11
+ date: 2021-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: qonfig