Class: Nifty::CommandExecutioner
- Inherits:
-
Thor
- Object
- Thor
- Nifty::CommandExecutioner
- Defined in:
- lib/nifty/command_executioner.rb
Class Method Summary collapse
-
.available_backends ⇒ Array
List all available backends.
-
.available_transfer_methods(backend) ⇒ Array
List all available transfer methods for the backend.
-
.exit_on_failure? ⇒ TrueClass, FalseClass
Force Thor to exit with a non-zero return value on failure (after ‘exit` is called).
Instance Method Summary collapse
Class Method Details
.available_backends ⇒ Array
List all available backends
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nifty/command_executioner.rb', line 36 def available_backends constants = Nifty::Backends.constants.map { |sym| sym.to_s.downcase } constants.select! do |constant| unknown = Nifty::Backends.const_get(constant.camelize) unknown.respond_to?('backend?') && unknown.backend? end constants.sort end |
.available_transfer_methods(backend) ⇒ Array
List all available transfer methods for the backend
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nifty/command_executioner.rb', line 17 def available_transfer_methods(backend) unless Nifty::TransferMethods.constants.include? backend.camelize.to_sym fail Nifty::CommandExecutionError, "No backend with name '#{backend}'" end clazz = "Nifty::TransferMethods::#{backend.camelize}".constantize constants = clazz.constants.map { |sym| sym.to_s.downcase } constants.select! do |constant| unknown = clazz.const_get(constant.camelize) unknown.respond_to?('transfer_method?') && unknown.transfer_method? end constants.sort end |
.exit_on_failure? ⇒ TrueClass, FalseClass
Force Thor to exit with a non-zero return value on failure (after ‘exit` is called).
9 10 11 |
# File 'lib/nifty/command_executioner.rb', line 9 def exit_on_failure? true end |
Instance Method Details
#backends ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/nifty/command_executioner.rb', line 94 def backends backends = self.class.available_backends longest = backends.map { |backend| backend.length }.sort.last backends.each do |backend| $stdout.puts "%-#{longest + 2}s" % "#{backend}" + "# #{Nifty::Backends.const_get(backend.camelize).description}" end end |
#version ⇒ Object
89 90 91 |
# File 'lib/nifty/command_executioner.rb', line 89 def version $stdout.puts Nifty::VERSION end |