Class: Jenkins::Plugin::Tools::Manifest::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins/plugin/tools/manifest.rb

Constant Summary collapse

MAX_LENGTH =
72.to_i

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Writer

Returns a new instance of Writer.



54
55
56
# File 'lib/jenkins/plugin/tools/manifest.rb', line 54

def initialize(io)
  @io = io
end

Instance Method Details

#manifest_truncate(message) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/jenkins/plugin/tools/manifest.rb', line 62

def manifest_truncate(message)
  if message.length < MAX_LENGTH
    return message
  end

  line = message[0 ... MAX_LENGTH] + "\n"
  offset = MAX_LENGTH

  while offset < message.length
    line += " #{message[offset ... (offset + MAX_LENGTH - 1)]}\n"
    offset += (MAX_LENGTH - 1)
  end
  return line
end

#put(key, value) ⇒ Object



58
59
60
# File 'lib/jenkins/plugin/tools/manifest.rb', line 58

def put(key, value)
  @io.puts "#{key}: #{manifest_truncate(value)}"
end