Module: Pantry
- Extended by:
- Pantry
- Included in:
- Pantry
- Defined in:
- lib/pantry.rb,
lib/pantry/ui.rb,
lib/pantry/cli.rb,
lib/pantry/client.rb,
lib/pantry/config.rb,
lib/pantry/logger.rb,
lib/pantry/server.rb,
lib/pantry/command.rb,
lib/pantry/message.rb,
lib/pantry/version.rb,
lib/pantry/client_info.rb,
lib/pantry/file_editor.rb,
lib/pantry/command_line.rb,
lib/pantry/commands/echo.rb,
lib/pantry/communication.rb,
lib/pantry/multi_command.rb,
lib/pantry/client_registry.rb,
lib/pantry/command_handler.rb,
lib/pantry/commands/status.rb,
lib/pantry/commands/upload_file.rb,
lib/pantry/communication/client.rb,
lib/pantry/communication/server.rb,
lib/pantry/commands/create_client.rb,
lib/pantry/communication/security.rb,
lib/pantry/commands/sync_directory.rb,
lib/pantry/communication/wait_list.rb,
lib/pantry/commands/register_client.rb,
lib/pantry/commands/edit_application.rb,
lib/pantry/communication/send_socket.rb,
lib/pantry/communication/file_service.rb,
lib/pantry/commands/download_directory.rb,
lib/pantry/commands/update_application.rb,
lib/pantry/communication/client_filter.rb,
lib/pantry/communication/publish_socket.rb,
lib/pantry/communication/reading_socket.rb,
lib/pantry/communication/receive_socket.rb,
lib/pantry/communication/writing_socket.rb,
lib/pantry/communication/subscribe_socket.rb,
lib/pantry/communication/serialize_message.rb,
lib/pantry/communication/file_service/send_file.rb,
lib/pantry/communication/security/null_security.rb,
lib/pantry/communication/security/authentication.rb,
lib/pantry/communication/security/curve_security.rb,
lib/pantry/communication/security/curve_key_store.rb,
lib/pantry/communication/file_service/receive_file.rb,
lib/pantry/communication/file_service/file_progress.rb
Defined Under Namespace
Modules: Commands, Communication Classes: CLI, Client, ClientInfo, ClientRegistry, Command, CommandHandler, CommandLine, Config, DuplicateCommandError, FileEditor, InvalidCommandError, Logger, Message, MissingOption, MultiCommand, NullLogger, Server, UI
Constant Summary collapse
- SERVER_IDENTITY =
Default identity of a Server, so as to help differentiate where messages are coming from.
""
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.config ⇒ Object
Retrieve the current configuration set.
-
.logger ⇒ Object
Access Pantry’s logger.
- .logger=(logger) ⇒ Object
- .reset_config! ⇒ Object
- .reset_ui! ⇒ Object
-
.ui(input = $stdin, output = $stdout) ⇒ Object
Global access to Pantry’s UI handler.
Instance Method Summary collapse
-
#add_client_command(command_class) ⇒ Object
Register a command object class to be handled only by Clients.
-
#add_server_command(command_class) ⇒ Object
Register a command object class to be handled only by the Server.
-
#all_commands ⇒ Object
Return all known commands.
- #check_for_duplicates(command_list, command_class_to_add) ⇒ Object
-
#client_commands ⇒ Object
Return the list of known Client command classes.
- #ensure_proper_command_class(command_class) ⇒ Object
-
#file_checksum(file_path) ⇒ Object
Calculate the checksum of a file at the given path.
-
#load_plugins ⇒ Object
Find all installed Pantry plugin gems.
-
#root(config = Pantry.config) ⇒ Object
The root of all stored Pantry data for this Server/Client Uses Pantry.config.root_dir.
-
#server_commands ⇒ Object
Return the list of known Server command classes.
-
#set_proc_title(title) ⇒ Object
Update the process’s proc title with the given string.
Class Method Details
.config ⇒ Object
Retrieve the current configuration set
4 5 6 |
# File 'lib/pantry/config.rb', line 4 def self.config @@config ||= Config.new end |
.logger ⇒ Object
Access Pantry’s logger.
4 5 6 |
# File 'lib/pantry/logger.rb', line 4 def self.logger @@logger ||= Pantry::Logger.new end |
.logger=(logger) ⇒ Object
8 9 10 |
# File 'lib/pantry/logger.rb', line 8 def self.logger=(logger) @@logger = logger end |
.reset_config! ⇒ Object
8 9 10 |
# File 'lib/pantry/config.rb', line 8 def self.reset_config! @@config = nil end |
.reset_ui! ⇒ Object
9 10 11 |
# File 'lib/pantry/ui.rb', line 9 def self.reset_ui! @@ui = nil end |
Instance Method Details
#add_client_command(command_class) ⇒ Object
Register a command object class to be handled only by Clients
109 110 111 112 113 114 |
# File 'lib/pantry.rb', line 109 def add_client_command(command_class) ensure_proper_command_class(command_class) check_for_duplicates(client_commands, command_class) client_commands << command_class end |
#add_server_command(command_class) ⇒ Object
Register a command object class to be handled only by the Server
117 118 119 120 121 122 |
# File 'lib/pantry.rb', line 117 def add_server_command(command_class) ensure_proper_command_class(command_class) check_for_duplicates(server_commands, command_class) server_commands << command_class end |
#all_commands ⇒ Object
Return all known commands
135 136 137 |
# File 'lib/pantry.rb', line 135 def all_commands [client_commands, server_commands].flatten end |
#check_for_duplicates(command_list, command_class_to_add) ⇒ Object
149 150 151 152 153 154 |
# File 'lib/pantry.rb', line 149 def check_for_duplicates(command_list, command_class_to_add) known_commands = command_list.map(&:message_type) if known_commands.include?(command_class_to_add.) raise Pantry::DuplicateCommandError.new("Command with type #{command_class_to_add.} already registered") end end |
#client_commands ⇒ Object
Return the list of known Client command classes
125 126 127 |
# File 'lib/pantry.rb', line 125 def client_commands @client_commands ||= [] end |
#ensure_proper_command_class(command_class) ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'lib/pantry.rb', line 139 def ensure_proper_command_class(command_class) unless command_class.is_a?(Class) raise Pantry::InvalidCommandError.new("Expected a Class, got an #{command_class.class}") end unless command_class.ancestors.include?(Pantry::Command) raise Pantry::InvalidCommandError.new("Expected a class that's a subclass of Pantry::Command") end end |
#file_checksum(file_path) ⇒ Object
Calculate the checksum of a file at the given path
104 105 106 |
# File 'lib/pantry.rb', line 104 def file_checksum(file_path) Digest::SHA256.file(file_path).hexdigest end |
#load_plugins ⇒ Object
Find all installed Pantry plugin gems. Plugins are defined as gems who contain a file named “pantry/init.rb”.
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/pantry.rb', line 158 def load_plugins Gem.find_latest_files("pantry/init.rb").each do |path| begin gem_path = path.gsub("#{Gem.dir}/gems/", '') Pantry.logger.debug("Installing plugin from #{gem_path}") require path rescue Exception => ex Pantry.logger.warn("Unable to load plugin at #{gem_path}, #{ex.}") end end end |
#root(config = Pantry.config) ⇒ Object
The root of all stored Pantry data for this Server/Client Uses Pantry.config.root_dir
94 95 96 |
# File 'lib/pantry.rb', line 94 def root(config = Pantry.config) Pathname.new(config.root_dir) end |
#server_commands ⇒ Object
Return the list of known Server command classes
130 131 132 |
# File 'lib/pantry.rb', line 130 def server_commands @server_commands ||= [] end |
#set_proc_title(title) ⇒ Object
Update the process’s proc title with the given string
99 100 101 |
# File 'lib/pantry.rb', line 99 def set_proc_title(title) $0 = title end |