Class: Dockerize::DocumentWriter
- Inherits:
-
Object
- Object
- Dockerize::DocumentWriter
- Defined in:
- lib/dockerize/document_writer.rb
Constant Summary collapse
- CREATE_WORD =
'created '.green
- REPLACE_WORD =
'replaced '.red
- IGNORE_WORD =
'ignored '.yellow
Instance Attribute Summary collapse
-
#document_name ⇒ Object
writeonly
Sets the attribute document_name.
Instance Method Summary collapse
- #inform_of_write(type) ⇒ Object
-
#initialize(document_name = nil, stream = $out) ⇒ DocumentWriter
constructor
A new instance of DocumentWriter.
- #output_target ⇒ Object
- #write(contents = nil, executable = false) ⇒ Object
Constructor Details
#initialize(document_name = nil, stream = $out) ⇒ DocumentWriter
Returns a new instance of DocumentWriter.
14 15 16 17 |
# File 'lib/dockerize/document_writer.rb', line 14 def initialize(document_name = nil, stream = $out) @stream = stream @document_name = document_name end |
Instance Attribute Details
#document_name=(value) ⇒ Object
Sets the attribute document_name
12 13 14 |
# File 'lib/dockerize/document_writer.rb', line 12 def document_name=(value) @document_name = value end |
Instance Method Details
#inform_of_write(type) ⇒ Object
31 32 33 |
# File 'lib/dockerize/document_writer.rb', line 31 def inform_of_write(type) $out.puts ' ' << type << document_name end |
#output_target ⇒ Object
27 28 29 |
# File 'lib/dockerize/document_writer.rb', line 27 def output_target "#{Dockerize::Config.project_dir}/#{document_name}" end |
#write(contents = nil, executable = false) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/dockerize/document_writer.rb', line 19 def write(contents = nil, executable = false) @invalid_content = true unless contents ensure_containing_dir do_backup! if should_backup? inform_of_write(status_word) do_write!(contents, executable) if should_write? end |