Class: Strobe::Resources::Application::PackFile
- Inherits:
-
Object
- Object
- Strobe::Resources::Application::PackFile
- Defined in:
- lib/strobe/resources/application.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each(*args, &blk) ⇒ Object
- #eof ⇒ Object (also: #eof?)
- #file(path, body) ⇒ Object
- #headers ⇒ Object
-
#initialize(opts) ⇒ PackFile
constructor
A new instance of PackFile.
- #pos ⇒ Object
- #read(*args) ⇒ Object
- #rewind ⇒ Object
- #seek(*args) ⇒ Object
- #size ⇒ Object
- #to_io ⇒ Object
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
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 |
#eof ⇒ Object 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 |
#headers ⇒ Object
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 |
#pos ⇒ Object
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 |
#rewind ⇒ Object
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 |
#size ⇒ Object
264 265 266 |
# File 'lib/strobe/resources/application.rb', line 264 def size to_io.size end |
#to_io ⇒ Object
274 275 276 |
# File 'lib/strobe/resources/application.rb', line 274 def to_io @to_io ||= StringIO.new(to_s) end |