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!, call, #call, command_name, configure, #current_user, #debug, description, disable!, disabled?, #error, #fatal, #force_yes?, #info, #initialize, #logger, options, #summarize, #summarize_hash, syntax, #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



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

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



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

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

#executeObject



31
32
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
# File 'lib/quandl/command/tasks/update.rb', line 31

def execute
  # load libraries needed by this action
  require_dependencies
  return unless assert_update_requirements!
  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



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

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



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

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

#package_urlObject



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

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

#root_pathObject



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

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

#tarball_pathObject



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

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

#update_pathObject



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

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