Class: SolrMakr::Commands::Buffer Private
- Inherits:
-
Object
- Object
- SolrMakr::Commands::Buffer
- Defined in:
- lib/solr_makr/commands/buffer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Captures output for buffers
Instance Attribute Summary collapse
- #context ⇒ Object readonly private
- #exit_status ⇒ Object private
- #logger ⇒ Object readonly private
- #output ⇒ Object readonly private
Instance Method Summary collapse
- #default_formatter ⇒ Proc private
- #error!(status: 1, message: nil) ⇒ Object private
- #failure(message) ⇒ Object private
- #import(buffer) ⇒ Object private
-
#initialize(context: nil, **options) ⇒ Buffer
constructor
private
A new instance of Buffer.
- #issue(message) ⇒ Object private
- #ok(message = 'OK') ⇒ Object (also: #success) private
- #print(*lines) ⇒ Object private
- #separator! ⇒ Object private
- #success? ⇒ Boolean private
- #to_s ⇒ Object private
Constructor Details
#initialize(context: nil, **options) ⇒ Buffer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Buffer.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/solr_makr/commands/buffer.rb', line 7 def initialize(context: nil, **) @context = context @output = StringIO.new @logger = Logger.new @output @logger.formatter = default_formatter @exit_status = 0 end |
Instance Attribute Details
#context ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/solr_makr/commands/buffer.rb', line 19 def context @context end |
#exit_status ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/solr_makr/commands/buffer.rb', line 22 def exit_status @exit_status end |
#logger ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/solr_makr/commands/buffer.rb', line 21 def logger @logger end |
#output ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/solr_makr/commands/buffer.rb', line 20 def output @output end |
Instance Method Details
#default_formatter ⇒ Proc
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/solr_makr/commands/buffer.rb', line 84 def default_formatter proc do |severity, time, progname, | context_name = progname.presence || context.presence || SolrMakr::BIN_NAME [].tap do |parts| parts << severity parts << "[#{time.iso8601}]" unless STDOUT.tty? parts << "[#{context_name}]" if context_name.present? parts << end.join(' ') + "\n" end end |
#error!(status: 1, message: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 45 |
# File 'lib/solr_makr/commands/buffer.rb', line 37 def error!(status: 1, message: nil) if .present? logger.error end if exit_status != status self.exit_status = status end end |
#failure(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/solr_makr/commands/buffer.rb', line 53 def failure() print "\u2717 #{}" end |
#import(buffer) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 |
# File 'lib/solr_makr/commands/buffer.rb', line 27 def import(buffer) write buffer.to_s unless buffer.success? self.exit_status = buffer.exit_status end return self end |
#issue(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/solr_makr/commands/buffer.rb', line 57 def issue() print "\u2757 #{}" end |
#ok(message = 'OK') ⇒ Object Also known as: success
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/solr_makr/commands/buffer.rb', line 47 def ok( = 'OK') print "\u2713 #{}" end |
#print(*lines) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 |
# File 'lib/solr_makr/commands/buffer.rb', line 65 def print(*lines) lines.each { |line| write line } write "\n" end |
#separator! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/solr_makr/commands/buffer.rb', line 61 def separator! write "\n\n" end |
#success? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 |
# File 'lib/solr_makr/commands/buffer.rb', line 75 def success? @exit_status.zero? end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/solr_makr/commands/buffer.rb', line 79 def to_s output.string end |