Class: Strobe::Resources::Application::PackFile

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ PackFile

Returns a new instance of PackFile.



217
218
219
220
221
# File 'lib/strobe/resources/application.rb', line 217

def initialize(opts)
  @opts  = opts
  @files = []
  @callback = opts[:callback]
end

Class Method Details

.build(opts) {|inst| ... } ⇒ Object

Yields:

  • (inst)


211
212
213
214
215
# File 'lib/strobe/resources/application.rb', line 211

def self.build(opts)
  inst = new(opts)
  yield inst
  inst
end

Instance Method Details

#each(*args, &blk) ⇒ Object



236
237
238
# File 'lib/strobe/resources/application.rb', line 236

def each(*args, &blk)
  to_io.each(*args, &blk)
end

#eofObject Also known as: eof?



268
269
270
# File 'lib/strobe/resources/application.rb', line 268

def eof
  to_io.eof
end

#file(path, body) ⇒ Object



223
224
225
# File 'lib/strobe/resources/application.rb', line 223

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

#headersObject



227
228
229
230
231
232
233
234
# File 'lib/strobe/resources/application.rb', line 227

def headers
  {
    'Content-Type'     => 'application/x-strobe-deploy',
    'Content-Length'   => size.to_s,
    'Content-Encoding' => 'deflate',
    'X-Strobe-Deploy-Protocol-Version' => '2'
  }
end

#posObject



260
261
262
# File 'lib/strobe/resources/application.rb', line 260

def pos
  to_io.pos
end

#read(*args) ⇒ Object



240
241
242
243
244
245
246
247
248
249
250
# File 'lib/strobe/resources/application.rb', line 240

def read(*args)
  ret = to_io.read(*args)

  if @callback && ret
    @callback.upload_progress(pos.to_f / size.to_f)
  elsif @callback
    @callback.upload_complete
  end

  ret
end

#rewindObject



252
253
254
# File 'lib/strobe/resources/application.rb', line 252

def rewind
  to_io.rewind
end

#seek(*args) ⇒ Object



256
257
258
# File 'lib/strobe/resources/application.rb', line 256

def seek(*args)
  to_io.seek(*args)
end

#sizeObject



264
265
266
# File 'lib/strobe/resources/application.rb', line 264

def size
  to_io.size
end

#to_ioObject



274
275
276
# File 'lib/strobe/resources/application.rb', line 274

def to_io
  @to_io ||= StringIO.new(to_s)
end