view_component-fragment_caching 0.3.1 → 0.3.2

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: 0452e841d32831dd2a0b12d0fd85e04f1a840cf32baaee2764e8e72520374e64
4
- data.tar.gz: 69fbca8579b6bb24a0a4eb8dd5bd79c46deb0edb78e431067e42bf5fd1f1ef75
3
+ metadata.gz: 21103a5d9df674efecebb73f125a10625180fb3b87e5fccd59f9ed3e67956fda
4
+ data.tar.gz: cd03c59b1c3fb16f6b87e3a0a4e586674961e3dc6dc339a29e86c608bab1944f
5
5
  SHA512:
6
- metadata.gz: 14eae94fe010d908682a418b92db5d73738f3f8650ed4b43ed8d9e4422f6bd8211c44da1c1c938af3676e4d7960655de8ac203b98456764c855cea8b23b08451
7
- data.tar.gz: f2836c3d3fd4928c9e412c2b2d773e590abf98db211d3e1f09bfc4a1a15e874af3198a132c7514823013d0483c85e9d7571e03daab67fbbefd9a3d98f2a0e6b9
6
+ metadata.gz: ebaf8c548694121e1eccfaef06211957ed10c9bb562f9bdee6d4c975c0dca908aeae37ac640b6c8aad8755d186f7566c18b2baba2ccb8a952d1bd3fcc8af7901
7
+ data.tar.gz: 23af3729cd0ae8eda74f87ed9fb6d7b2aaa5a6f30e7ffd178796cc8619471be87c2e7364ab1d9dc065e08ddf09d14fcc9177c12975c1f4d72fd8398ceb55686e
@@ -9,38 +9,46 @@ module ViewComponent
9
9
 
10
10
  class PathParser < ActionView::Resolver::PathParser
11
11
  class MatchedAttributes
12
- FORMATS = (ActionView::Template::Types.symbols | %i(rb)).map(&Regexp.method(:escape)).join('|').freeze
13
- private_constant :FORMATS
14
-
15
- HANDLERS = ActionView::Template::Handlers.extensions.map(&Regexp.method(:escape)).join('|').freeze
16
- private_constant :HANDLERS
17
-
18
- LOCALES = '(?!rb)[a-z]{2}(?:-[A-Z]{2})?'.freeze
19
- private_constant :LOCALES
20
-
21
- VARIANTS = '[^.]*'.freeze
22
- private_constant :VARIANTS
23
-
24
- MATCH_NAMES = %i(prefix partial action locale format variant handler).freeze
25
- private_constant :MATCH_NAMES
26
-
27
- REGEX = %r{
28
- \A
29
- (?:(?<prefix>.*)/)?
30
- (?<partial>_)?
31
- (?<action>.*?)
32
- (?:\.(?<locale>#{LOCALES}))??
33
- (?:\.(?<format>#{FORMATS}))??
34
- (?:\+(?<variant>#{VARIANTS}))??
35
- (?:\.(?<handler>#{HANDLERS}))?
36
- \z
37
- }x.freeze
38
- private_constant :REGEX
12
+ class << self
13
+ def formats
14
+ @formats ||= (ActionView::Template::Types.symbols | %i(rb)).map(&Regexp.method(:escape)).join('|').freeze
15
+ end
16
+
17
+ def handlers
18
+ @handlers ||= ActionView::Template::Handlers.extensions.map(&Regexp.method(:escape)).join('|').freeze
19
+ end
20
+
21
+ def locales
22
+ @locales ||= '(?!rb)[a-z]{2}(?:-[A-Z]{2})?'.freeze
23
+ end
24
+
25
+ def variants
26
+ @variants ||= '[^.]*'.freeze
27
+ end
28
+
29
+ def match_names
30
+ @match_names ||= %i(prefix partial action locale format variant handler).freeze
31
+ end
32
+
33
+ def regex
34
+ @regex ||= %r{
35
+ \A
36
+ (?:(?<prefix>.*)/)?
37
+ (?<partial>_)?
38
+ (?<action>.*?)
39
+ (?:\.(?<locale>#{locales}))??
40
+ (?:\.(?<format>#{formats}))??
41
+ (?:\+(?<variant>#{variants}))??
42
+ (?:\.(?<handler>#{handlers}))?
43
+ \z
44
+ }x.freeze
45
+ end
46
+ end
39
47
 
40
48
  delegate :[], to: :match
41
49
 
42
50
  def initialize(path)
43
- @match = REGEX.match path
51
+ @match = self.class.regex.match path
44
52
  end
45
53
 
46
54
  def format
@@ -60,11 +68,11 @@ module ViewComponent
60
68
  end
61
69
 
62
70
  def method_missing(method_name, *)
63
- match[method_name] if MATCH_NAMES.include? method_name
71
+ match[method_name] if self.class.match_names.include? method_name
64
72
  end
65
73
 
66
74
  def respond_to_missing?(method_name)
67
- MATCH_NAMES.include? method_name
75
+ self.class.match_names.include? method_name
68
76
  end
69
77
 
70
78
  private
@@ -1,6 +1,6 @@
1
1
  module ViewComponent
2
2
  module FragmentCaching
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.3.2'.freeze
4
4
  public_constant :VERSION
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component-fragment_caching
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Arnett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-12 00:00:00.000000000 Z
11
+ date: 2024-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails