Class: ScraperWiki::API::Matchers::LastRunMatcher

Inherits:
ScraperInfoMatcher show all
Defined in:
lib/scraperwiki-api/matchers.rb

Instance Method Summary collapse

Methods inherited from CustomMatcher

#does_not_match?, #initialize

Constructor Details

This class inherits a constructor from ScraperWiki::API::Matchers::CustomMatcher

Instance Method Details

#daysObject Also known as: day



187
188
189
190
# File 'lib/scraperwiki-api/matchers.rb', line 187

def days
  @multiplier = 86400
  self
end

#failure_messageObject



222
223
224
# File 'lib/scraperwiki-api/matchers.rb', line 222

def failure_message
  "expected #{@actual['short_name']} to have run within #{span} seconds"
end

#hoursObject Also known as: hour



193
194
195
196
# File 'lib/scraperwiki-api/matchers.rb', line 193

def hours
  @multiplier = 3600
  self
end

#matches?(actual) ⇒ Boolean

TODO:

last_run seems to follow British Summer Time, in which case it will be 00, not 01, for part of the year.

Returns:

  • (Boolean)


213
214
215
216
# File 'lib/scraperwiki-api/matchers.rb', line 213

def matches?(actual)
  super
  Time.now - Time.parse("#{@actual['last_run']}+01") < span
end

#minutesObject Also known as: minute



199
200
201
202
# File 'lib/scraperwiki-api/matchers.rb', line 199

def minutes
  @multiplier = 60
  self
end

#monthsObject Also known as: month



175
176
177
178
# File 'lib/scraperwiki-api/matchers.rb', line 175

def months
  @multiplier = 2592000 # 30 days
  self
end

#negative_failure_messageObject



226
227
228
# File 'lib/scraperwiki-api/matchers.rb', line 226

def negative_failure_message
  "expected #{@actual['short_name']} to not have run within #{span} seconds"
end

#secondsObject Also known as: second



205
206
207
208
# File 'lib/scraperwiki-api/matchers.rb', line 205

def seconds
  @multiplier = 3600
  self
end

#spanObject



218
219
220
# File 'lib/scraperwiki-api/matchers.rb', line 218

def span
  @expected * (@multiplier || 1)
end

#weeksObject Also known as: week



181
182
183
184
# File 'lib/scraperwiki-api/matchers.rb', line 181

def weeks
  @multiplier = 604800
  self
end