Class: Quandl::Command::Tasks::Update

Inherits:
Base
  • Object
show all
Defined in:
lib/quandl/command/tasks/update.rb

Constant Summary collapse

PACKAGE_URL =
'http://s3.amazonaws.com/quandl-command/'

Instance Attribute Summary

Attributes inherited from Base

#args, #options, #request_timer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ask_yes_or_no, authenticated_users_only!, autoload_client_library, call, #call, command_name, configure, #current_user, #debug, description, disable!, disable_in_gem!, disabled?, #error, #fatal, #force_yes?, #info, inherited, #initialize, lang, language, #logger, options, #summarize, #summarize_hash, syntax, t, #table, #verbose?, warn_unauthenticated_users

Constructor Details

This class inherits a constructor from Quandl::Command::Tasks::Base

Class Method Details

.package_url(revision = nil) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/quandl/command/tasks/update.rb', line 23

def package_url(revision=nil)
  # are we on windows?
  platform = Quandl::Utility::Config.windows? ? 'windows' : nil
  # build filename
  filename = ['quandl-command', platform, revision, 'tar.gz'].compact.join(".")
  # append s3 url
  File.join(PACKAGE_URL, filename)
end

Instance Method Details

#backup_pathObject



83
84
85
# File 'lib/quandl/command/tasks/update.rb', line 83

def backup_path
  @backup_path ||= File.join( root_path, 'backup' )
end

#executeObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/quandl/command/tasks/update.rb', line 33

def execute
  # load libraries needed by this action
  require_dependencies
  info "Updating from #{Quandl::Command::VERSION} ... "
  # wipe update/ and backup/ folders
  prepare_for_update
  download_tarball
  # ensure package was downloaded
  return error("'#{package_url}' not found") unless File.exists?(tarball_path)
  # install
  extract_tarball
  copy_windows_specific_files if Quandl::Utility::Config.windows?
  install_update
  configure_update
  ensure_correct_permissions
  # success
  version = %x{quandl -v}.to_s.strip.rstrip
  info "You are up to date! ( #{version} )"
  
rescue => err
  # log error
  error(err)
  debug(err.backtrace.join("\n"))
  # report failure and rollback
  info("----\nAn error has occured! Rolling back to previous version ... ")
  info("If the problem persists reinstall with: #{installer_url}")
  rollback_update
end

#installer_urlObject



62
63
64
65
# File 'lib/quandl/command/tasks/update.rb', line 62

def installer_url
  return File.join(PACKAGE_URL, "Quandl Setup.exe") if Quandl::Utility::Config.windows?
  return File.join(PACKAGE_URL, "quandl-toolbelt.pkg") if Quandl::Utility::Config.macosx?
end

#package_pathObject



67
68
69
# File 'lib/quandl/command/tasks/update.rb', line 67

def package_path
  @package_path ||= File.join(update_path, "quandl-command")
end

#package_urlObject



75
76
77
# File 'lib/quandl/command/tasks/update.rb', line 75

def package_url
  @package_url ||= self.class.package_url(args.first)
end

#root_pathObject



87
88
89
# File 'lib/quandl/command/tasks/update.rb', line 87

def root_path
  Quandl::Command::Tasks.root
end

#tarball_pathObject



71
72
73
# File 'lib/quandl/command/tasks/update.rb', line 71

def tarball_path
  @tarball_path ||= File.join(update_path, "update.tar.gz")
end

#update_pathObject



79
80
81
# File 'lib/quandl/command/tasks/update.rb', line 79

def update_path
  @update_path ||= File.join( root_path, 'update' )
end