Class: Strobe::Deploy::Multipart

Inherits:
Object
  • Object
show all
Defined in:
lib/strobe/deploy.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Multipart

Returns a new instance of Multipart.

Yields:

  • (_self)

Yield Parameters:



73
74
75
76
77
78
# File 'lib/strobe/deploy.rb', line 73

def initialize
  @name  = nil
  @url   = nil
  @files = []
  yield self if block_given?
end

Instance Method Details

#bodyObject



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/strobe/deploy.rb', line 96

def body
  b  = "--#{boundary}\r\n"
  b << part("metadata", "application/json", )
  b << "--#{boundary}\r\n"

  @files.each do |path, type, body|
    b << part("files[]", type, body)
    b << "--#{boundary}\r\n"
  end

  b
end

#file(path, content_type, body) ⇒ Object



88
89
90
# File 'lib/strobe/deploy.rb', line 88

def file(path, content_type, body)
  @files << [path, content_type, body]
end

#headersObject



92
93
94
# File 'lib/strobe/deploy.rb', line 92

def headers
  { "Content-Type" => %[multipart/form-data; boundary="#{boundary}"] }
end

#name(name) ⇒ Object



80
81
82
# File 'lib/strobe/deploy.rb', line 80

def name(name)
  @name = name
end

#url(url) ⇒ Object



84
85
86
# File 'lib/strobe/deploy.rb', line 84

def url(url)
  @url = url
end