html-proofer 3.12.0 → 3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/html-proofer/cache.rb +23 -8
- data/lib/html-proofer/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04d2b18950f5d8c6b2bcfadb24dec58d50d7c2fd8997977506a79a22d24aeeef
|
4
|
+
data.tar.gz: f33be2af98f5a199b563eb78aef31518c94b304c1fd120985dc3ee2febee233f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9fd7e64a8c76c74351128fd63a25c1c56ce11351fc8cd4ce0e91ee793586ab71609ae247d3fa66615b089546887a330cb2eeec9550888ebbf9f8abb59b628d
|
7
|
+
data.tar.gz: bed4a30375077f6bfd35900f75976e9f960deb316421e113b65b33ad7d61f9084be427f5241c3700aa1d8fbd717d4104389855db71a43f60f846af58c3a6694b
|
data/lib/html-proofer/cache.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'utils'
|
4
|
-
|
4
|
+
require 'date'
|
5
5
|
require 'json'
|
6
|
-
require 'timerizer'
|
7
6
|
|
8
7
|
module HTMLProofer
|
9
8
|
class Cache
|
@@ -18,6 +17,9 @@ module HTMLProofer
|
|
18
17
|
@logger = logger
|
19
18
|
@cache_log = {}
|
20
19
|
|
20
|
+
@cache_datetime = DateTime.now
|
21
|
+
@cache_time = @cache_datetime.to_time
|
22
|
+
|
21
23
|
if options.nil? || options.empty?
|
22
24
|
define_singleton_method('use_cache?') { false }
|
23
25
|
else
|
@@ -25,8 +27,6 @@ module HTMLProofer
|
|
25
27
|
setup_cache!(options)
|
26
28
|
@parsed_timeframe = parsed_timeframe(options[:timeframe])
|
27
29
|
end
|
28
|
-
|
29
|
-
@cache_time = Time.now
|
30
30
|
end
|
31
31
|
|
32
32
|
def within_timeframe?(time)
|
@@ -46,13 +46,13 @@ module HTMLProofer
|
|
46
46
|
time = time.to_i
|
47
47
|
case date
|
48
48
|
when 'M'
|
49
|
-
time
|
49
|
+
time_ago(time, :months)
|
50
50
|
when 'w'
|
51
|
-
time
|
51
|
+
time_ago(time, :weeks)
|
52
52
|
when 'd'
|
53
|
-
time
|
53
|
+
time_ago(time, :days)
|
54
54
|
when 'h'
|
55
|
-
time
|
55
|
+
time_ago(time, :hours)
|
56
56
|
else
|
57
57
|
raise ArgumentError, "#{date} is not a valid timeframe!"
|
58
58
|
end
|
@@ -162,5 +162,20 @@ module HTMLProofer
|
|
162
162
|
contents = File.read(cache_file)
|
163
163
|
@cache_log = contents.empty? ? {} : JSON.parse(contents)
|
164
164
|
end
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def time_ago(measurement, unit)
|
169
|
+
case unit
|
170
|
+
when :months
|
171
|
+
@cache_datetime >> -measurement
|
172
|
+
when :weeks
|
173
|
+
@cache_datetime - measurement * 7
|
174
|
+
when :days
|
175
|
+
@cache_datetime - measurement
|
176
|
+
when :hours
|
177
|
+
@cache_datetime - Rational(measurement/24.0)
|
178
|
+
end.to_time
|
179
|
+
end
|
165
180
|
end
|
166
181
|
end
|
data/lib/html-proofer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.12.
|
4
|
+
version: 3.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.3'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: timerizer
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.3'
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.3'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: redcarpet
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|