view_component-fragment_caching 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0452e841d32831dd2a0b12d0fd85e04f1a840cf32baaee2764e8e72520374e64
4
- data.tar.gz: 69fbca8579b6bb24a0a4eb8dd5bd79c46deb0edb78e431067e42bf5fd1f1ef75
3
+ metadata.gz: 3a1c057781473b74710361b0d7f7a69ac3421ae589d840b5357e5948724e5964
4
+ data.tar.gz: 3fbe0a2e10c14a78668831d7a2d72c98e589638fe66cbf14a01eec8aaff2f578
5
5
  SHA512:
6
- metadata.gz: 14eae94fe010d908682a418b92db5d73738f3f8650ed4b43ed8d9e4422f6bd8211c44da1c1c938af3676e4d7960655de8ac203b98456764c855cea8b23b08451
7
- data.tar.gz: f2836c3d3fd4928c9e412c2b2d773e590abf98db211d3e1f09bfc4a1a15e874af3198a132c7514823013d0483c85e9d7571e03daab67fbbefd9a3d98f2a0e6b9
6
+ metadata.gz: af7016d7cbdaf4c1c4f821e47801fd82e3eb7f41868e57130afdf0b7e54cd70d77e7c3fb22574fbcdcf3a72c887b9c34122f13704d1604482ce392992692548a
7
+ data.tar.gz: b01a95791f920a2b934e67e5a46c7727ae572bdd6f51cc8a7192a9a30136715470b10e66688b58a6c101d371b07ecd52a0f26c6b6f90b1553835665ff0e0d53a
@@ -9,38 +9,45 @@ 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))
15
+ .map(&Regexp.method(:escape))
16
+ .join('|')
17
+ .freeze
18
+ end
19
+
20
+ def handlers
21
+ @handlers ||= ActionView::Template::Handlers.extensions.map(&Regexp.method(:escape)).join('|').freeze
22
+ end
23
+
24
+ def locales
25
+ @locales ||= '(?!rb)[a-z]{2}(?:-[A-Z]{2})?'.freeze
26
+ end
27
+
28
+ def variants
29
+ @variants ||= '[^.]*'.freeze
30
+ end
31
+
32
+ def match_names
33
+ @match_names ||= %i(prefix partial action locale format variant handler).freeze
34
+ end
35
+
36
+ def regex
37
+ @regex ||= %r{
38
+ \A
39
+ (?:(?<prefix>.*)/)?(?<partial>_)?(?<action>.*?)
40
+ (?:\.(?<locale>#{locales}))??(?:\.(?<format>#{formats}))??
41
+ (?:\+(?<variant>#{variants}))??(?:\.(?<handler>#{handlers}))?
42
+ \z
43
+ }x.freeze
44
+ end
45
+ end
39
46
 
40
47
  delegate :[], to: :match
41
48
 
42
49
  def initialize(path)
43
- @match = REGEX.match path
50
+ @match = self.class.regex.match path
44
51
  end
45
52
 
46
53
  def format
@@ -60,11 +67,11 @@ module ViewComponent
60
67
  end
61
68
 
62
69
  def method_missing(method_name, *)
63
- match[method_name] if MATCH_NAMES.include? method_name
70
+ match[method_name] if self.class.match_names.include? method_name
64
71
  end
65
72
 
66
73
  def respond_to_missing?(method_name)
67
- MATCH_NAMES.include? method_name
74
+ self.class.match_names.include? method_name
68
75
  end
69
76
 
70
77
  private
@@ -11,7 +11,7 @@ module ViewComponent
11
11
  MODULE_NAME = /(?:((::)?#{CAMEL_PHRASE}+)+)/.freeze
12
12
  private_constant :MODULE_NAME
13
13
 
14
- VIEW_COMPONENT_NAME = /(?:#{MODULE_NAME}Component)/.freeze
14
+ VIEW_COMPONENT_NAME = /(?:#{MODULE_NAME}?(::)?Component)/.freeze
15
15
  private_constant :VIEW_COMPONENT_NAME
16
16
 
17
17
  MODULE_NAME_END = /(?:\b[^:])/.freeze
@@ -1,6 +1,6 @@
1
1
  module ViewComponent
2
2
  module FragmentCaching
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.4.0'.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.4.0
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-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubygems_version: 3.4.10
166
+ rubygems_version: 3.4.19
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: Bust fragment caches when view components update