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

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

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#daysObject Also known as: day



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

def days
  @multiplier = 86400
  self
end

#failure_messageObject



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

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

#hoursObject Also known as: hour



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

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)


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

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

#minutesObject Also known as: minute



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

def minutes
  @multiplier = 60
  self
end

#monthsObject Also known as: month



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

def months
  @multiplier = 2592000 # 30 days
  self
end

#negative_failure_messageObject



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

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

#secondsObject Also known as: second



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

def seconds
  @multiplier = 3600
  self
end

#spanObject



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

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

#weeksObject Also known as: week



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

def weeks
  @multiplier = 604800
  self
end