Class: Arli::Actions::Action
- Inherits:
-
Object
- Object
- Arli::Actions::Action
- Extended by:
- Forwardable
- Includes:
- Helpers::Inherited, Helpers::Output
- Defined in:
- lib/arli/actions/action.rb
Overview
Represents an abstract action related to the library
Direct Known Subclasses
Constant Summary
Constants included from Helpers::Output
Helpers::Output::CHAR_FAILURE, Helpers::Output::CHAR_SUCCESS
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#library ⇒ Object
Returns the value of attribute library.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(library, config: Arli.config) ⇒ Action
constructor
A new instance of Action.
- #mv(from, to) ⇒ Object
- #run! ⇒ Object
- #supported? ⇒ Boolean
- #to_s ⇒ Object
Methods included from Helpers::Inherited
Methods included from Helpers::Output
#___, #__p, #__pf, #__pt, #abort?, #action_fail, #action_ok, #backup?, #cursor, #debug, #debug?, disable!, enable!, enabled?, #error, #fuck, #header, #hr, #indent_cursor, #info, #ok, #overwrite?, #print_action_failure, #print_action_starting, #print_action_success, #print_target_dir, #quiet?, #raise_invalid_arli_command!, #report_exception, #verbose?
Constructor Details
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
26 27 28 |
# File 'lib/arli/actions/action.rb', line 26 def config @config end |
#library ⇒ Object
Returns the value of attribute library.
26 27 28 |
# File 'lib/arli/actions/action.rb', line 26 def library @library end |
Class Method Details
Instance Method Details
#mv(from, to) ⇒ Object
48 49 50 |
# File 'lib/arli/actions/action.rb', line 48 def mv(from, to) FileUtils.mv(from, to) end |
#run! ⇒ Object
33 34 35 36 37 |
# File 'lib/arli/actions/action.rb', line 33 def run! execute rescue Exception => e action_fail(self, e) end |
#supported? ⇒ Boolean
39 40 41 42 43 44 45 46 |
# File 'lib/arli/actions/action.rb', line 39 def supported? return @supported if defined?(@supported) if self.class.check_command && self.class.check_pattern @supported = (`#{self.class.check_command} 2>/dev/null | grep "#{self.class.check_pattern}"`.chomp != '') else @supported = true end end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/arli/actions/action.rb', line 52 def to_s "<Action:#{(Arli::Actions.action_name(self) || 'unknown action').bold.blue}: lib=#{library.name}>" end |