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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a537508d8fd48a9ff72b2fcaa670e060228947772948ad13e2af35207d299fb4
4
- data.tar.gz: 86f13c7b403a1f2ba9ae2394da32bf2a625d88784be14d4bdfc1467509b936b8
3
+ metadata.gz: 04d2b18950f5d8c6b2bcfadb24dec58d50d7c2fd8997977506a79a22d24aeeef
4
+ data.tar.gz: f33be2af98f5a199b563eb78aef31518c94b304c1fd120985dc3ee2febee233f
5
5
  SHA512:
6
- metadata.gz: 279f41c4472ddeb829cde63ba2497fe88dfdc52298bda5098b79b813a3710abdcf6a62b6d879c367724394d129685b9463ae1eab610e9b569fb0dbb76ed8da21
7
- data.tar.gz: 48e32a23f8e94952c55659bb080b2dadcd5ff550a92b9733bd8b8a5707f6dda66362b854b5e088da644a1f297b1c0da54336b22f010f8aeb22b28fb8c6ecc5e9
6
+ metadata.gz: 1e9fd7e64a8c76c74351128fd63a25c1c56ce11351fc8cd4ce0e91ee793586ab71609ae247d3fa66615b089546887a330cb2eeec9550888ebbf9f8abb59b628d
7
+ data.tar.gz: bed4a30375077f6bfd35900f75976e9f960deb316421e113b65b33ad7d61f9084be427f5241c3700aa1d8fbd717d4104389855db71a43f60f846af58c3a6694b
@@ -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.months.ago
49
+ time_ago(time, :months)
50
50
  when 'w'
51
- time.weeks.ago
51
+ time_ago(time, :weeks)
52
52
  when 'd'
53
- time.days.ago
53
+ time_ago(time, :days)
54
54
  when 'h'
55
- time.hours.ago
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTMLProofer
4
- VERSION = '3.12.0'.freeze
4
+ VERSION = '3.12.1'.freeze
5
5
  end
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.0
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-03 00:00:00.000000000 Z
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