Module: Quandl::Command::Task::Updatable

Extended by:
ActiveSupport::Concern
Included in:
Quandl::Command::Task
Defined in:
lib/quandl/command/task/updatable.rb

Constant Summary collapse

VERSION_URL =
"https://s3.amazonaws.com/quandl-command/VERSION"

Instance Method Summary collapse

Instance Method Details

#check_for_updateObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/quandl/command/task/updatable.rb', line 29

def check_for_update
  # notify user of impending update check
  print("# Checking for updates ... ")
  # lazy load dependencies since this happens infrequently
  require_check_for_update_dependencies
  # build request
  http, request = prepare_update_request
  # send request
  response = send_update_request(http, request)
  # handle output
  handle_update_response(response)
rescue => err
  info("An unexpected error occured while checking for updates ... #{err}")
  info err.backtrace.join("\n") if trace?
ensure
  config.last_checked_for_update = Time.now
end

#check_for_update_once_dailyObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/quandl/command/task/updatable.rb', line 15

def check_for_update_once_daily
  # short circuit
  return if options.sandbox
  # onwards
  check_time = config.last_checked_for_update
  # check time present?
  if check_time.present? && check_time.is_a?(Time)
    # has it been more than one day?  
    check_for_update if Time.now - 1.day > check_time || check_time > Time.now
  else
    check_for_update
  end
end