Class: Vagrant::UI::Remote
- Defined in:
- lib/vagrant/ui/remote.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Attributes inherited from Interface
#opts, #stderr, #stdin, #stdout
Instance Method Summary collapse
- #ask(message, **opts) ⇒ Object
- #clear_line ⇒ Object
-
#initialize(client) ⇒ Remote
constructor
A new instance of Remote.
- #machine(type, *data) ⇒ Object
- #safe_puts(message, **opts) ⇒ Object
- #to_proto ⇒ Object
Methods inherited from Basic
#format_message, #report_progress, #say
Methods inherited from Interface
#color?, inherited, #initialize_copy, #rewriting
Constructor Details
#initialize(client) ⇒ Remote
Returns a new instance of Remote.
23 24 25 26 27 |
# File 'lib/vagrant/ui/remote.rb', line 23 def initialize(client) super() @client = client @logger = Log4r::Logger.new("vagrant::ui") end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
21 22 23 |
# File 'lib/vagrant/ui/remote.rb', line 21 def client @client end |
Instance Method Details
#ask(message, **opts) ⇒ Object
33 34 35 36 37 |
# File 'lib/vagrant/ui/remote.rb', line 33 def ask(, **opts) opts[:style] ||= :detail opts[:echo] = true if !opts.key?(:echo) @client.input(.gsub("%", "%%"), **opts) end |
#clear_line ⇒ Object
29 30 31 |
# File 'lib/vagrant/ui/remote.rb', line 29 def clear_line @client.clear_line end |
#machine(type, *data) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/vagrant/ui/remote.rb', line 51 def machine(type, *data) if !client.is_machine_readable @logger.info("Machine: #{type} #{data.inspect}") return end opts = {} opts = data.pop if data.last.kind_of?(Hash) target = opts[:target] || "" # Prepare the data by replacing characters that aren't outputted data.each_index do |i| data[i] = data[i].to_s.dup data[i].gsub!(",", "%!(VAGRANT_COMMA)") data[i].gsub!("\n", "\\n") data[i].gsub!("\r", "\\r") end table_data = { rows: [[Time.now.utc.to_i, target, type, data.join(",")]] } client.table(table_data, **opts) end |
#safe_puts(message, **opts) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant/ui/remote.rb', line 39 def safe_puts(, **opts) , extra_opts = opts = { new_line: opts[:printer] == :puts, style: extra_opts[:style], bold: extra_opts[:bold], color: extra_opts[:color] } client.output(.gsub("%", "%%"), **opts) end |
#to_proto ⇒ Object
75 76 77 |
# File 'lib/vagrant/ui/remote.rb', line 75 def to_proto @client.proto end |