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, content_type, 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.
101 102 103 104 |
# File 'lib/strobe/resources/application.rb', line 101 def initialize(opts) @opts = opts @files = [] end |
Class Method Details
.build(opts) {|inst| ... } ⇒ Object
95 96 97 98 99 |
# File 'lib/strobe/resources/application.rb', line 95 def self.build(opts) inst = new(opts) yield inst inst end |
Instance Method Details
#each(*args, &blk) ⇒ Object
116 117 118 |
# File 'lib/strobe/resources/application.rb', line 116 def each(*args, &blk) to_io.each(*args, &blk) end |
#eof ⇒ Object Also known as: eof?
146 147 148 |
# File 'lib/strobe/resources/application.rb', line 146 def eof to_io.eof end |
#file(path, content_type, body) ⇒ Object
106 107 108 |
# File 'lib/strobe/resources/application.rb', line 106 def file(path, content_type, body) @files << [path, content_type, body] end |
#headers ⇒ Object
110 111 112 113 114 |
# File 'lib/strobe/resources/application.rb', line 110 def headers { 'Content-Type' => 'application/x-strobe-deploy', 'Content-Length' => size.to_s, 'Content-Encoding' => 'deflate' } end |
#pos ⇒ Object
138 139 140 |
# File 'lib/strobe/resources/application.rb', line 138 def pos to_io.pos end |
#read(*args) ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/strobe/resources/application.rb', line 120 def read(*args) ret = to_io.read(*args) if callback = @opts[:upload_callback] ret ? callback.call(pos.to_f / size.to_f) : callback.call(nil) end ret end |
#rewind ⇒ Object
130 131 132 |
# File 'lib/strobe/resources/application.rb', line 130 def rewind to_io.rewind end |
#seek(*args) ⇒ Object
134 135 136 |
# File 'lib/strobe/resources/application.rb', line 134 def seek(*args) to_io.seek(*args) end |
#size ⇒ Object
142 143 144 |
# File 'lib/strobe/resources/application.rb', line 142 def size to_io.size end |
#to_io ⇒ Object
152 153 154 |
# File 'lib/strobe/resources/application.rb', line 152 def to_io @to_io ||= StringIO.new(to_s) end |