Class: Thor::Actions::InjectIntoFile
- Inherits:
-
Object
- Object
- Thor::Actions::InjectIntoFile
- Defined in:
- lib/thor/actions/inject_into_file.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#flag ⇒ Object
readonly
Returns the value of attribute flag.
-
#relative_destination ⇒ Object
readonly
Returns the value of attribute relative_destination.
-
#replacement ⇒ Object
readonly
Returns the value of attribute replacement.
Instance Method Summary collapse
-
#initialize(base, destination, data, flag, log_status = true) ⇒ InjectIntoFile
constructor
A new instance of InjectIntoFile.
- #invoke! ⇒ Object
- #revoke! ⇒ Object
Constructor Details
#initialize(base, destination, data, flag, log_status = true) ⇒ InjectIntoFile
Returns a new instance of InjectIntoFile.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/thor/actions/inject_into_file.rb', line 39 def initialize(base, destination, data, flag, log_status=true) @base, @log_status = base, log_status behavior, @flag = flag.keys.first, flag.values.first self.destination = destination data = data.call if data.is_a?(Proc) @replacement = if behavior == :after @flag + data else data + @flag end end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
37 38 39 |
# File 'lib/thor/actions/inject_into_file.rb', line 37 def base @base end |
#destination ⇒ Object
Returns the value of attribute destination.
37 38 39 |
# File 'lib/thor/actions/inject_into_file.rb', line 37 def destination @destination end |
#flag ⇒ Object (readonly)
Returns the value of attribute flag.
37 38 39 |
# File 'lib/thor/actions/inject_into_file.rb', line 37 def flag @flag end |
#relative_destination ⇒ Object (readonly)
Returns the value of attribute relative_destination.
37 38 39 |
# File 'lib/thor/actions/inject_into_file.rb', line 37 def relative_destination @relative_destination end |
#replacement ⇒ Object (readonly)
Returns the value of attribute replacement.
37 38 39 |
# File 'lib/thor/actions/inject_into_file.rb', line 37 def replacement @replacement end |
Instance Method Details
#invoke! ⇒ Object
53 54 55 56 |
# File 'lib/thor/actions/inject_into_file.rb', line 53 def invoke! say_status :inject replace!(flag, replacement) end |
#revoke! ⇒ Object
58 59 60 61 |
# File 'lib/thor/actions/inject_into_file.rb', line 58 def revoke! say_status :deinject replace!(replacement, flag) end |