Module: Sym::App::Commands
- Defined in:
- lib/sym/app/commands.rb,
lib/sym/app/commands/command.rb,
lib/sym/app/commands/print_key.rb,
lib/sym/app/commands/show_help.rb,
lib/sym/app/commands/open_editor.rb,
lib/sym/app/commands/generate_key.rb,
lib/sym/app/commands/show_version.rb,
lib/sym/app/commands/show_examples.rb,
lib/sym/app/commands/encrypt_decrypt.rb,
lib/sym/app/commands/delete_keychain_item.rb,
lib/sym/app/commands/show_language_examples.rb
Defined Under Namespace
Classes: Command, DeleteKeychainItem, DependencyResolver, EncryptDecrypt, GenerateKey, OpenEditor, PrintKey, ShowExamples, ShowHelp, ShowLanguageExamples, ShowVersion
Class Attribute Summary collapse
-
.commands ⇒ Object
Returns the value of attribute commands.
-
.dependency ⇒ Object
Returns the value of attribute dependency.
Class Method Summary collapse
- .dependencies ⇒ Object
- .find_command_class(opts) ⇒ Object
- .order(command_class, after) ⇒ Object
- .register(command_class) ⇒ Object
-
.sorted_commands ⇒ Object
Sort commands based on the #dependencies array, which itself is sorted based on command dependencies.
Class Attribute Details
.commands ⇒ Object
Returns the value of attribute commands.
21 22 23 |
# File 'lib/sym/app/commands.rb', line 21 def commands @commands end |
.dependency ⇒ Object
Returns the value of attribute dependency.
21 22 23 |
# File 'lib/sym/app/commands.rb', line 21 def dependency @dependency end |
Class Method Details
.dependencies ⇒ Object
33 34 35 36 |
# File 'lib/sym/app/commands.rb', line 33 def dependencies @dependencies ||= self.dependency.tsort @dependencies end |
.find_command_class(opts) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/sym/app/commands.rb', line 45 def find_command_class(opts) self.sorted_commands.each do |command_class| return command_class if command_class.(opts) end nil end |
.order(command_class, after) ⇒ Object
28 29 30 31 |
# File 'lib/sym/app/commands.rb', line 28 def order(command_class, after) self.dependency[command_class.short_name].unshift(after) if after self.dependency[command_class.short_name].flatten! end |
.register(command_class) ⇒ Object
23 24 25 26 |
# File 'lib/sym/app/commands.rb', line 23 def register(command_class) self.commands << command_class self.dependency[command_class.short_name] ||= [] end |
.sorted_commands ⇒ Object
Sort commands based on the #dependencies array, which itself is sorted based on command dependencies.
40 41 42 43 |
# File 'lib/sym/app/commands.rb', line 40 def sorted_commands @sorted_commands ||= self.commands.to_a.sort_by{|klass| dependencies.index(klass.short_name) } @sorted_commands end |