Module: Xolo::Admin::ProgressHistory
- Defined in:
- lib/xolo/admin/progress_history.rb
Overview
Storage and access to a history of progress-data from long-running Xolo server processes.
E.g.. when you run ‘xadm delete-title’ you’ll get a live progress updates of everything happening. That log is stored for a while (3 days) on the server.
Later, esp if you used –quiet and didn’t see the progress or any errors initially you’ll be able to re-view the progress log, if it still exists on the server
Constant Summary collapse
- APP_SUPPORT_DIR =
Constants
'~/Library/Application Support/xadm/'- PROGRESS_HISTORY_FILENAME =
'com.pixar.xolo.admin.progress_history.yaml'- PROGRESS_FILE_LIFETIME =
prog files on the server last 3 days, add an extra to account for timing of daily cleanup on the server. if the file is already gone from the server, we’ll tell the user
4 * 24 * 3600
Class Method Summary collapse
-
.extended(extender) ⇒ Object
when this module is extended.
-
.included(includer) ⇒ Object
when this module is included.
Instance Method Summary collapse
-
#add_progress_history_entry(url_path) ⇒ void
Add an entry to the progress history.
-
#app_support_dir ⇒ Pathname
The expanded path tot he prog.
-
#progress_history ⇒ Hash
The current history of progress streams for this user keys are Time objects when the entry was created values are sub-hashes with :command, and :url keys the command being the xadm command, e.g.
-
#progress_history_file ⇒ Pathname
The prog.
Class Method Details
.extended(extender) ⇒ Object
when this module is extended
52 53 54 |
# File 'lib/xolo/admin/progress_history.rb', line 52 def self.extended(extender) Xolo.verbose_extend extender, self end |
.included(includer) ⇒ Object
when this module is included
47 48 49 |
# File 'lib/xolo/admin/progress_history.rb', line 47 def self.included(includer) Xolo.verbose_include includer, self end |
Instance Method Details
#add_progress_history_entry(url_path) ⇒ void
This method returns an undefined value.
Add an entry to the progress history
103 104 105 106 107 108 109 110 111 |
# File 'lib/xolo/admin/progress_history.rb', line 103 def add_progress_history_entry(url_path) history = progress_history history[Time.now] = { command: cli_cmd.command, url_path: url_path } progress_history_file.pix_atomic_write YAML.dump(history) end |
#app_support_dir ⇒ Pathname
Returns The expanded path tot he prog. history dir for this user.
62 63 64 65 66 67 68 |
# File 'lib/xolo/admin/progress_history.rb', line 62 def app_support_dir return @app_support_dir if @app_support_dir @app_support_dir = Pathname.new(APP_SUPPORT_DIR). @app_support_dir.mkpath @app_support_dir end |
#progress_history ⇒ Hash
The current history of progress streams for this user keys are Time objects when the entry was created values are sub-hashes with :command, and :url keys the command being the xadm command, e.g. ‘delete-version’ and the URL being the url to the progress stream file on the server.
before returning the hash, any expired entries are removed
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/xolo/admin/progress_history.rb', line 86 def progress_history progress_history_file.pix_touch history = YAML.safe_load progress_history_file.read, permitted_classes: [Symbol, Time] history ||= {} now = Time.now history.delete_if { |k, _v| now - k > PROGRESS_FILE_LIFETIME } history end |
#progress_history_file ⇒ Pathname
Returns The prog. history file for this user.
72 73 74 |
# File 'lib/xolo/admin/progress_history.rb', line 72 def progress_history_file @progress_history_file ||= (app_support_dir + PROGRESS_HISTORY_FILENAME) end |