rails-minify 0.1.0 → 0.1.1

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: 32a43a0b86ec6d79152580e59ed32f5468ddd3d1a4e0865716f404bd542b566c
4
- data.tar.gz: fa640778b9324a8737ff1e809af7a101ff2e10b910677611de081b033678c983
3
+ metadata.gz: debbde5867be2f422c20756ebf3c08185983f80f1f94b1f9be9ffa5f29283989
4
+ data.tar.gz: d42eca099bc0278d05c81a868ec03eccd844635799e0d826900680324fd56558
5
5
  SHA512:
6
- metadata.gz: d078aaa82950d4407b91e82fcde444264496d72551db08177d629cdb61d5928ff23381462f23388cbf5db91c138cca78d1f79a870f0eeca794d178b0e8427af9
7
- data.tar.gz: e6ee0e7f39335eaba0d2adf4718a89dbdf52e8d1a8b993539ddfa3081631714bac16c5fc899b6f8dea5fd3cf12d667875843a1d73ccc524ecc72735c9e42834d
6
+ metadata.gz: 835c2eb9c3a2b1210977d40eaaafc28fe399d7755c3681d6c0adaef25b3063c6f43e699f4924015d404deb083ae9e26324e7f524bd51687b937866fc3d10c08b
7
+ data.tar.gz: 1a04e068acaaa2991c5e8c8f0ea4ec51145acde7d7285ef2c05d422b05754b733f776e269398449b8b6675f8b647aa2d95df9eb077cc55084851d5844045eae3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1 (2026-10-18)
4
+
5
+ - `:omniauth` isn't installed when OmniAuth already skips requests that can't be the strategy's (a public `Strategy#passthrough?`, as in the version proposed upstream); its own helper no longer shares that name.
6
+
3
7
  ## 0.1.0 (2026-10-18)
4
8
 
5
9
  First release.
data/README.md CHANGED
@@ -57,7 +57,7 @@ For parts of Rails and common gems that redo work on every request.
57
57
  Attachments that are Active Storage blobs, remote images or inline content
58
58
  are cached too: a blob without a caption contributes its filename, which a
59
59
  hit checks in one query (renamed or deleted: computed again). Other
60
- attachables aren't cached. In golf-buddy, 13% of all allocations on its
60
+ attachables aren't cached. In [Japan Voyage](https://japanvoyage.jp), 13% of all allocations on its
61
61
  pages came from it, and guides with images another 4.5%.
62
62
  * `:request_host`: `ActionDispatch::Request#host` runs a regexp substitution
63
63
  on every call, port or not, and Rails reads it several times per request.
@@ -67,11 +67,13 @@ For parts of Rails and common gems that redo work on every request.
67
67
  options on every request before looking at the path. Requests that can't
68
68
  be OmniAuth's go straight to the app. Only when that's certain up front:
69
69
  a session is present, not in test mode, no `other_phase` or callable
70
- paths, and the strategy doesn't override how paths are matched.
70
+ paths, and the strategy doesn't override how paths are matched. Not
71
+ installed when OmniAuth already does this itself (it then has a public
72
+ `Strategy#passthrough?`, as in the version proposed upstream).
71
73
 
72
74
  ## Numbers
73
75
 
74
- golf-buddy, 132 production pages, with everything on (strict mode after
76
+ Japan Voyage, 132 production pages, with everything on (strict mode after
75
77
  rubocop-minify's rewrites, all patches): identical HTML, and
76
78
  1,561,283 → 1,224,141 allocations per pass (−21.6%). The machine was too
77
79
  loaded for wall-clock times to mean much.
@@ -4,9 +4,9 @@ module RailsMinify
4
4
  module Patches
5
5
  # ActionText::Content#to_plain_text walks the whole HTML tree with
6
6
  # Nokogiri on every call, and looks up the record behind every attachment:
7
- # in golf-buddy, 13% of all allocations on its pages came from it
8
- # (excerpts, meta descriptions, cards). The text is computed once per
9
- # distinct HTML and kept, up to MAX_BYTES of HTML.
7
+ # on Japan Voyage (japanvoyage.jp), 13% of all allocations on its pages
8
+ # came from it (excerpts, meta descriptions, cards). The text is computed
9
+ # once per distinct HTML and kept, up to MAX_BYTES of HTML.
10
10
  #
11
11
  # Without attachments the text depends on the HTML alone. An attachment
12
12
  # adds its record's text: for Active Storage blobs "[caption]" (from the
@@ -3,20 +3,29 @@
3
3
  module RailsMinify
4
4
  module Patches
5
5
  # Every OmniAuth strategy is a middleware that, on every request, dups
6
- # itself (and its Hashie::Mash options) before looking at the path: in
7
- # golf-buddy about 35k allocations per pass over its pages, none of them
8
- # on a login path. Requests that can't be OmniAuth's go straight to the
9
- # app; anything that might be (or that the strategy decides at runtime:
10
- # callable paths, other_phase, overridden path methods, test mode, a
11
- # missing session, which OmniAuth reports) runs OmniAuth as before.
6
+ # itself (and its Hashie::Mash options) before looking at the path: on
7
+ # Japan Voyage (japanvoyage.jp) about 35k allocations per pass over its
8
+ # pages, none of them on a login path. Requests that can't be OmniAuth's
9
+ # go straight to the app; anything that might be (or that the strategy
10
+ # decides at runtime: callable paths, other_phase, overridden path
11
+ # methods, test mode, a missing session, which OmniAuth reports) runs
12
+ # OmniAuth as before.
12
13
  module OmniAuthPassthrough
13
14
  # What decides whether a request is the strategy's. A strategy that
14
15
  # overrides any of these decides for itself: always run it.
15
16
  PATH_METHODS = %i[call! on_auth_path? on_request_path? on_callback_path? on_path? request_path
16
17
  callback_path current_path path_prefix script_name].freeze
17
18
 
18
- def self.install!
19
- OmniAuth::Strategy.prepend(self) unless OmniAuth::Strategy < self
19
+ def self.install!(strategy = OmniAuth::Strategy)
20
+ return if upstream?(strategy) # OmniAuth does this itself
21
+
22
+ strategy.prepend(self) unless strategy < self
23
+ end
24
+
25
+ # The same check in OmniAuth (sampokuokkanen/omniauth@skip-dup-off-auth-paths,
26
+ # proposed upstream) defines a public Strategy#passthrough?.
27
+ def self.upstream?(strategy = OmniAuth::Strategy)
28
+ strategy.public_method_defined?(:passthrough?) && !(strategy < self)
20
29
  end
21
30
 
22
31
  # Per strategy class: are all of PATH_METHODS OmniAuth's own?
@@ -28,14 +37,14 @@ module RailsMinify
28
37
  end
29
38
 
30
39
  def call(env)
31
- return super unless passthrough?(env)
40
+ return super unless minify_passthrough?(env)
32
41
 
33
42
  @app.call(env)
34
43
  end
35
44
 
36
45
  private
37
46
 
38
- def passthrough?(env)
47
+ def minify_passthrough?(env)
39
48
  return false if OmniAuth.config.test_mode || !env["rack.session"] || respond_to?(:other_phase)
40
49
  return false unless OmniAuthPassthrough.standard_paths?(self.class)
41
50
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMinify
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-minify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen