rack-no_animations 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rack/no_animations.rb +54 -56
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2af60553d7c7d347d2d4d66aa3eddacb1b12da8d
4
- data.tar.gz: 5309ef6a55cd81bf30bf29c161deb48d83fb86fb
3
+ metadata.gz: 832687d48795c59f7569ca4520d8e64dafd799cf
4
+ data.tar.gz: 8d90bb6322ae7d3b82f616ca1afa499145e0a89c
5
5
  SHA512:
6
- metadata.gz: 148b23b3e89465485a925315bb2de3a663863caae6f3370bcd86bb2c572eaf700967fd9e0e89b82b61698837515eb18b6e0d7d8dbf89e3317e6fa1ae900e84c0
7
- data.tar.gz: 43812713a328df524c3c72e66691940849dc00f81c45ea33f50fcd08b41f2c40445dee63fbfa56632e48c1df7e5482c7f68bf978cfa09939c21c761fd93c2e15
6
+ metadata.gz: fee751ee83337170891f54ef23fa1ab546bc18b67bfef806806649521dff4f544df99d0ac1b8ce2303186bcfd900bc4c5d7f29ce9cea48155fab436bb1e2bdf5
7
+ data.tar.gz: b8bacb1c941e817316cd624a3adcb47d7bdc99a4f879bb43a33adca92cfe7c280519623e0bc59f5b5241d0c847e9ab097a31f23931bc7791d620522d8e2a4dd8
@@ -1,80 +1,78 @@
1
1
  module Rack
2
- module NoAnimations
3
- class NoAnimations
4
- TEXT_HTML = %r{text/html}.freeze
5
- CONTENT_LENGTH = 'Content-Length'.freeze
2
+ class NoAnimations
3
+ TEXT_HTML = %r{text/html}.freeze
4
+ CONTENT_LENGTH = 'Content-Length'.freeze
6
5
 
7
- DISABLE_ANIMATIONS_SNIPPET = <<-EOF
6
+ DISABLE_ANIMATIONS_SNIPPET = <<-EOF
8
7
  <scrip>if (typeof jQuery !== 'undefined') { jQuery.fx.off = true }</script>
9
8
  <style>
10
- * {
11
- -o-transition: none !important;
12
- -moz-transition: none !important;
13
- -ms-transition: none !important;
14
- -webkit-transition: none !important;
15
- transition: none !important;
16
- -o-transform: none !important;
17
- -moz-transform: none !important;
18
- -ms-transform: none !important;
19
- -webkit-transform: none !important;
20
- transform: none !important;
21
- -webkit-animation: none !important;
22
- -moz-animation: none !important;
23
- -o-animation: none !important;
24
- -ms-animation: none !important;
25
- animation: none !important;
26
- }
9
+ * {
10
+ -o-transition: none !important;
11
+ -moz-transition: none !important;
12
+ -ms-transition: none !important;
13
+ -webkit-transition: none !important;
14
+ transition: none !important;
15
+ -o-transform: none !important;
16
+ -moz-transform: none !important;
17
+ -ms-transform: none !important;
18
+ -webkit-transform: none !important;
19
+ transform: none !important;
20
+ -webkit-animation: none !important;
21
+ -moz-animation: none !important;
22
+ -o-animation: none !important;
23
+ -ms-animation: none !important;
24
+ animation: none !important;
25
+ }
27
26
  </style>
28
- EOF
29
- SNIPPET_LENGTH = DISABLE_ANIMATIONS_SNIPPET.length
27
+ EOF
28
+ SNIPPET_LENGTH = DISABLE_ANIMATIONS_SNIPPET.length
30
29
 
31
- def initialize(app)
32
- @app = app
33
- end
30
+ def initialize(app)
31
+ @app = app
32
+ end
34
33
 
35
- def call(env)
36
- status, headers, body = env = @app.call(env)
34
+ def call(env)
35
+ status, headers, body = env = @app.call(env)
37
36
 
38
- return env unless is_html?(headers)
37
+ return env unless is_html?(headers)
39
38
 
40
- response(status, headers, body)
41
- end
39
+ response(status, headers, body)
40
+ end
42
41
 
43
- protected
42
+ protected
44
43
 
45
- def response(status, headers, body)
46
- changed, body = disable_animations(body)
44
+ def response(status, headers, body)
45
+ changed, body = disable_animations(body)
47
46
 
48
- update_length(headers) if changed
47
+ update_length(headers) if changed
49
48
 
50
- [status, headers, body]
51
- end
49
+ [status, headers, body]
50
+ end
52
51
 
53
- def is_html?(headers)
54
- headers['Content-Type'.freeze] =~ TEXT_HTML
55
- end
52
+ def is_html?(headers)
53
+ headers['Content-Type'.freeze] =~ TEXT_HTML
54
+ end
56
55
 
57
- def update_length(headers)
58
- content_length = headers[CONTENT_LENGTH]
59
- length = content_length.to_i
56
+ def update_length(headers)
57
+ content_length = headers[CONTENT_LENGTH]
58
+ length = content_length.to_i
60
59
 
61
- if length.to_s == content_length
62
- headers[CONTENT_LENGTH] = (length + SNIPPET_LENGTH).to_s
63
- end
60
+ if length.to_s == content_length
61
+ headers[CONTENT_LENGTH] = (length + SNIPPET_LENGTH).to_s
64
62
  end
63
+ end
65
64
 
66
65
 
67
- def disable_animations(response, body = '')
68
- response.each do |s|
69
- body << s.to_s# read the whole body
70
- end
71
-
72
- if (body_index = body.rindex('</body>'.freeze))
73
- body.insert(body_index - 7, DISABLE_ANIMATIONS_SNIPPET)
74
- end
66
+ def disable_animations(response, body = '')
67
+ response.each do |s|
68
+ body << s.to_s# read the whole body
69
+ end
75
70
 
76
- [ body_index, [ body ] ]
71
+ if (body_index = body.rindex('</body>'.freeze))
72
+ body.insert(body_index - 7, DISABLE_ANIMATIONS_SNIPPET)
77
73
  end
74
+
75
+ [ body_index, [ body ] ]
78
76
  end
79
77
  end
80
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-no_animations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Cichra