Class: Kpigen::Message
- Inherits:
-
Object
- Object
- Kpigen::Message
- Defined in:
- lib/kpigen/message.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(app) ⇒ Message
constructor
A new instance of Message.
- #print_about_to_fetch_source(source) ⇒ Object
- #print_already_accessed_source(source, last_accessed, next_access) ⇒ Object
- #print_archive_deleted(archive) ⇒ Object
- #print_archives(archives, show_password) ⇒ Object
- #print_error(msg, e = nil) ⇒ Object
- #print_file_downloaded(source, source_filename, dest_filename) ⇒ Object
- #print_file_not_downloaded(source, source_filename, dest_filename) ⇒ Object
- #print_file_not_uploaded(target, source_filename, dest_filename) ⇒ Object
- #print_found_source(source, last_accessed, show_password) ⇒ Object
- #print_get_big_t(big_t) ⇒ Object
- #print_new_archive(archive) ⇒ Object
- #print_new_source(source) ⇒ Object
- #print_new_target(target) ⇒ Object
- #print_no_archive_format(archive, index) ⇒ Object
- #print_no_archives ⇒ Object
- #print_no_archives_for_gather ⇒ Object
- #print_no_files_to_download(next_check_time) ⇒ Object
- #print_no_sources ⇒ Object
- #print_no_target_format(target, index) ⇒ Object
- #print_no_targets ⇒ Object
- #print_no_targets_for_gather ⇒ Object
- #print_nothing_to_gather ⇒ Object
- #print_set_big_t(big_t) ⇒ Object
- #print_sorted_file(index, inputfilename, outputfilename, duration) ⇒ Object
- #print_source_deleted(source) ⇒ Object
- #print_source_touched(source, time) ⇒ Object
- #print_sources(sources, all_accesses, show_password) ⇒ Object
- #print_storage_files(storage, files) ⇒ Object
- #print_target_deleted(target) ⇒ Object
- #print_targets(targets, show_password) ⇒ Object
- #print_unable_create_archive(input) ⇒ Object
- #print_unable_create_source(input) ⇒ Object
- #print_unable_create_target(input) ⇒ Object
- #print_unable_to_access_data_storage(source, e = nil) ⇒ Object
- #print_unable_to_clean_file(source, target, e = nil) ⇒ Object
- #print_unable_to_download_file(source, source_filename, dest_filename, e = nil) ⇒ Object
- #print_unable_to_process_file(filename, e = nil) ⇒ Object
- #print_unable_to_sort_file(filename, e = nil) ⇒ Object
- #print_unable_to_upload_file(target, source_filename, dest_filename, e = nil) ⇒ Object
- #print_unable_to_upload_text(target, source_text, dest_filename, e = nil) ⇒ Object
- #print_unknown_format_file(storage, filename) ⇒ Object
- #print_unknown_storage_lookup(cmd, index) ⇒ Object
- #print_version ⇒ Object
Constructor Details
#initialize(app) ⇒ Message
Returns a new instance of Message.
7 8 9 |
# File 'lib/kpigen/message.rb', line 7 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/kpigen/message.rb', line 5 def app @app end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/kpigen/message.rb', line 5 def @message end |
Instance Method Details
#print_about_to_fetch_source(source) ⇒ Object
175 176 177 |
# File 'lib/kpigen/message.rb', line 175 def print_about_to_fetch_source(source) print "Looking for files in: #{source.storage_path}\n" end |
#print_already_accessed_source(source, last_accessed, next_access) ⇒ Object
199 200 201 |
# File 'lib/kpigen/message.rb', line 199 def print_already_accessed_source(source,last_accessed,next_access) print "Last checked #{source.storage_path} at #{last_accessed} will check again after #{next_access}.\n" end |
#print_archive_deleted(archive) ⇒ Object
191 192 193 |
# File 'lib/kpigen/message.rb', line 191 def print_archive_deleted(archive) print "Removed archive #{archive.storage_path}.\n" end |
#print_archives(archives, show_password) ⇒ Object
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/kpigen/message.rb', line 156 def print_archives(archives,show_password) if archives.empty? print_no_archives else msg = archives.size == 1 ? "The following archive is available:\n" : "The following #{archives.size} archives are available:\n" msg += archives.each_with_index.collect { |s,i| " -- [#{i}] #{s.storage_path(show_password)} (#{s.mode})" }.join("\n") msg += "\n" print msg end end |
#print_error(msg, e = nil) ⇒ Object
11 12 13 |
# File 'lib/kpigen/message.rb', line 11 def print_error(msg,e = nil) @app..print_error(msg,e) end |
#print_file_downloaded(source, source_filename, dest_filename) ⇒ Object
86 87 88 |
# File 'lib/kpigen/message.rb', line 86 def print_file_downloaded(source, source_filename, dest_filename) print " -- downloaded #{source_filename} (#{source.storage_server}) => #{dest_filename}\n" end |
#print_file_not_downloaded(source, source_filename, dest_filename) ⇒ Object
82 83 84 |
# File 'lib/kpigen/message.rb', line 82 def print_file_not_downloaded(source, source_filename, dest_filename) print "Cannot find downloaded file #{dest_filename} (from #{source_filename} on #{source.storage_server})\n" end |
#print_file_not_uploaded(target, source_filename, dest_filename) ⇒ Object
108 109 110 |
# File 'lib/kpigen/message.rb', line 108 def print_file_not_uploaded(target, source_filename, dest_filename) print "Cannot find uploaded file #{dest_filename} (from #{source_filename} on #{target.storage_server})\n" end |
#print_found_source(source, last_accessed, show_password) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/kpigen/message.rb', line 37 def print_found_source(source,last_accessed,show_password) msg = "The following source was found:\n" msg += " -- #{source.storage_path(show_password)} (#{source.mode}, #{source.update_frequency})#{last_accessed_to_s(last_accessed)}" msg += "\n" print msg end |
#print_get_big_t(big_t) ⇒ Object
171 172 173 |
# File 'lib/kpigen/message.rb', line 171 def print_get_big_t(big_t) print "Big T is #{big_t}" end |
#print_new_archive(archive) ⇒ Object
148 149 150 |
# File 'lib/kpigen/message.rb', line 148 def print_new_archive(archive) print "Added #{archive.mode} archive #{archive.storage_path}\n" end |
#print_new_source(source) ⇒ Object
29 30 31 |
# File 'lib/kpigen/message.rb', line 29 def print_new_source(source) print "Added #{source.mode} source #{source.storage_path} to be checked every #{source.update_frequency}\n" end |
#print_new_target(target) ⇒ Object
125 126 127 |
# File 'lib/kpigen/message.rb', line 125 def print_new_target(target) print "Added #{target.mode} target #{target.storage_path}\n" end |
#print_no_archive_format(archive, index) ⇒ Object
215 216 217 |
# File 'lib/kpigen/message.rb', line 215 def print_no_archive_format(archive,index) print "No format associated with #{archive.storage_path}. To add a format, run 'archive format #{index} <path-to-format-csv>'\n" end |
#print_no_archives ⇒ Object
112 113 114 |
# File 'lib/kpigen/message.rb', line 112 def print_no_archives print "No archives available. For example, 'archive add /a/b/c'\n" end |
#print_no_archives_for_gather ⇒ Object
121 122 123 |
# File 'lib/kpigen/message.rb', line 121 def print_no_archives_for_gather print "No archive provided -- nowhere to put collected files\nFor example, 'archive add /a/b/c'\n" end |
#print_no_files_to_download(next_check_time) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/kpigen/message.rb', line 90 def print_no_files_to_download(next_check_time) if next_check_time.nil? print " -- Nothing found.\n" else print " -- Nothing found, will check again at #{next_check_time}.\n" end end |
#print_no_sources ⇒ Object
55 56 57 |
# File 'lib/kpigen/message.rb', line 55 def print_no_sources print "No sources available. For example, 'source add ftp deployer:[email protected]:/a/b/c 5minutes'\n" end |
#print_no_target_format(target, index) ⇒ Object
219 220 221 |
# File 'lib/kpigen/message.rb', line 219 def print_no_target_format(target,index) print "No format associated with #{target.storage_path}. To add a format, run 'target format #{index} <path-to-format-csv>'\n" end |
#print_no_targets ⇒ Object
133 134 135 |
# File 'lib/kpigen/message.rb', line 133 def print_no_targets print "No targets available. For example, 'target add ftp deployer:[email protected]:/a/b/c'\n" end |
#print_no_targets_for_gather ⇒ Object
59 60 61 |
# File 'lib/kpigen/message.rb', line 59 def print_no_targets_for_gather print "No targets available -- nowhere to place collected files. For example, 'target add ftp deployer:[email protected]:/a/b/c'\n" end |
#print_nothing_to_gather ⇒ Object
68 69 70 |
# File 'lib/kpigen/message.rb', line 68 def print_nothing_to_gather print "No sources provided -- nothing to gather\nFor example, 'source add ftp deployer:[email protected]:/a/b/c 5minutes'\n" end |
#print_set_big_t(big_t) ⇒ Object
167 168 169 |
# File 'lib/kpigen/message.rb', line 167 def print_set_big_t(big_t) print "Setting Big T to #{big_t}" end |
#print_sorted_file(index, inputfilename, outputfilename, duration) ⇒ Object
208 209 210 211 212 213 |
# File 'lib/kpigen/message.rb', line 208 def print_sorted_file(index,inputfilename, outputfilename, duration) msg = "Sorted #{inputfilename} (column index #{index}) " msg += "into #{outputfilename} " if inputfilename != outputfilename msg += "in #{duration}\n" print msg end |
#print_source_deleted(source) ⇒ Object
183 184 185 |
# File 'lib/kpigen/message.rb', line 183 def print_source_deleted(source) print "Removed source #{source.storage_path}.\n" end |
#print_source_touched(source, time) ⇒ Object
195 196 197 |
# File 'lib/kpigen/message.rb', line 195 def print_source_touched(source,time) print "Source #{source.storage_path} last checked at #{Eve::Message.friendly_now(time)}.\n" end |
#print_sources(sources, all_accesses, show_password) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kpigen/message.rb', line 44 def print_sources(sources,all_accesses,show_password) if sources.empty? print_no_sources else msg = sources.size == 1 ? "The following source is available:\n" : "The following #{sources.size} sources are available:\n" msg += sources.each_with_index.collect { |s,i| " -- [#{i}] #{s.storage_path(show_password)} (#{s.mode}, #{s.update_frequency})#{last_accessed_to_s(all_accesses[i])}" }.join("\n") msg += "\n" print msg end end |
#print_storage_files(storage, files) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/kpigen/message.rb', line 19 def print_storage_files(storage,files) if files.empty? print "No files available at #{storage.storage_path}.\n" else msg = "The following files are available at #{storage.storage_path}:\n" files.each { |f| msg += " -- #{f}\n" } print msg end end |
#print_target_deleted(target) ⇒ Object
187 188 189 |
# File 'lib/kpigen/message.rb', line 187 def print_target_deleted(target) print "Removed target #{target.storage_path}.\n" end |
#print_targets(targets, show_password) ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/kpigen/message.rb', line 137 def print_targets(targets,show_password) if targets.empty? print_no_targets else msg = targets.size == 1 ? "The following target is available:\n" : "The following #{targets.size} targets are available:\n" msg += targets.each_with_index.collect { |s,i| " -- [#{i}] #{s.storage_path(show_password)} (#{s.mode})" }.join("\n") msg += "\n" print msg end end |
#print_unable_create_archive(input) ⇒ Object
152 153 154 |
# File 'lib/kpigen/message.rb', line 152 def print_unable_create_archive(input) print "Unable to add archive [#{input}]\n" end |
#print_unable_create_source(input) ⇒ Object
33 34 35 |
# File 'lib/kpigen/message.rb', line 33 def print_unable_create_source(input) print "Unable to add source [#{input}]\n" end |
#print_unable_create_target(input) ⇒ Object
129 130 131 |
# File 'lib/kpigen/message.rb', line 129 def print_unable_create_target(input) print "Unable to add target [#{input}]\n" end |
#print_unable_to_access_data_storage(source, e = nil) ⇒ Object
72 73 74 75 |
# File 'lib/kpigen/message.rb', line 72 def print_unable_to_access_data_storage(source,e = nil) msg = "Unable to access #{source.storage_path}" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unable_to_clean_file(source, target, e = nil) ⇒ Object
116 117 118 119 |
# File 'lib/kpigen/message.rb', line 116 def print_unable_to_clean_file(source,target,e = nil) msg = "Unable to clean #{source} (to be stored at #{target})." e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unable_to_download_file(source, source_filename, dest_filename, e = nil) ⇒ Object
77 78 79 80 |
# File 'lib/kpigen/message.rb', line 77 def print_unable_to_download_file(source, source_filename, dest_filename, e = nil) msg = "Unable to download #{source_filename} on #{source.storage_server} to #{dest_filename}" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unable_to_process_file(filename, e = nil) ⇒ Object
63 64 65 66 |
# File 'lib/kpigen/message.rb', line 63 def print_unable_to_process_file(filename,e = nil) msg = "Unable to process #{filename}" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unable_to_sort_file(filename, e = nil) ⇒ Object
203 204 205 206 |
# File 'lib/kpigen/message.rb', line 203 def print_unable_to_sort_file(filename, e = nil) msg = "Unable to sort #{filename}" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unable_to_upload_file(target, source_filename, dest_filename, e = nil) ⇒ Object
98 99 100 101 |
# File 'lib/kpigen/message.rb', line 98 def print_unable_to_upload_file(target, source_filename, dest_filename, e = nil) msg = "Unable to upload #{source_filename} on #{target.storage_server} to #{dest_filename}" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unable_to_upload_text(target, source_text, dest_filename, e = nil) ⇒ Object
103 104 105 106 |
# File 'lib/kpigen/message.rb', line 103 def print_unable_to_upload_text(target, source_text, dest_filename, e = nil) msg = "Unable to upload '#{source_text}' on #{target.storage_server} to #{dest_filename}" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_unknown_format_file(storage, filename) ⇒ Object
223 224 225 |
# File 'lib/kpigen/message.rb', line 223 def print_unknown_format_file(storage,filename) print "Unable to set format #{filename} to #{storage}.\n" end |
#print_unknown_storage_lookup(cmd, index) ⇒ Object
179 180 181 |
# File 'lib/kpigen/message.rb', line 179 def print_unknown_storage_lookup(cmd, index) print "Invalid index (#{index}), ignoring '#{cmd}' command.\n" end |