Class: Pineapples::Actions::EmptyDirectory
- Defined in:
- lib/pineapples/actions/empty_directory.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Action
Instance Attribute Summary collapse
-
#skip ⇒ Object
readonly
Returns the value of attribute skip.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Attributes inherited from Action
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(generator, target, options = {}) ⇒ EmptyDirectory
constructor
A new instance of EmptyDirectory.
- #invoke! ⇒ Object
- #revoke! ⇒ Object
Methods inherited from Action
colors, inherited, #skip?, status_color
Constructor Details
#initialize(generator, target, options = {}) ⇒ EmptyDirectory
Returns a new instance of EmptyDirectory.
25 26 27 28 29 30 |
# File 'lib/pineapples/actions/empty_directory.rb', line 25 def initialize(generator, target, = {}) super(generator, ) @target = Target.new(target, generator) @skip = @target.skip? end |
Instance Attribute Details
#skip ⇒ Object (readonly)
Returns the value of attribute skip.
18 19 20 |
# File 'lib/pineapples/actions/empty_directory.rb', line 18 def skip @skip end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
18 19 20 |
# File 'lib/pineapples/actions/empty_directory.rb', line 18 def target @target end |
Instance Method Details
#exists? ⇒ Boolean
44 45 46 |
# File 'lib/pineapples/actions/empty_directory.rb', line 44 def exists? ::File.exist?(target.fullpath) end |
#invoke! ⇒ Object
32 33 34 35 36 |
# File 'lib/pineapples/actions/empty_directory.rb', line 32 def invoke! invoke_with_conflict_check do ::FileUtils.mkdir_p(target.fullpath) end end |
#revoke! ⇒ Object
38 39 40 41 42 |
# File 'lib/pineapples/actions/empty_directory.rb', line 38 def revoke! say_status :remove ::FileUtils.rm_rf(target.fullpath) if execute? && exists? given_target end |