lib/omnibus/compressors/tgz.rb in omnibus-5.4.0 vs lib/omnibus/compressors/tgz.rb in omnibus-5.5.0
- old
+ new
@@ -12,12 +12,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'rubygems/package'
-require 'zlib'
+require "rubygems/package"
+require "zlib"
module Omnibus
class Compressor::TGZ < Compressor::Base
id :tgz
@@ -49,15 +49,15 @@
def compression_level(val = NULL)
if null?(val)
@compression_level || Zlib::BEST_COMPRESSION
else
unless val.is_a?(Integer)
- raise InvalidValue.new(:compression_level, 'be an Integer')
+ raise InvalidValue.new(:compression_level, "be an Integer")
end
unless val.between?(1, 9)
- raise InvalidValue.new(:compression_level, 'be between 1-9')
+ raise InvalidValue.new(:compression_level, "be between 1-9")
end
@compression_level = val
end
end
@@ -83,11 +83,11 @@
def write_tgz
# Grab the contents of the gzipped tarball for reading
contents = gzipped_tarball
# Write the .tar.gz into the staging directory
- File.open("#{staging_dir}/#{package_name}", 'wb') do |tgz|
+ File.open("#{staging_dir}/#{package_name}", "wb") do |tgz|
while chunk = contents.read(1024)
tgz.write(chunk)
end
end
@@ -101,18 +101,18 @@
# Create an in-memory tarball from the given packager.
#
# @return [StringIO]
#
def tarball
- tarfile = StringIO.new('')
+ tarfile = StringIO.new("")
Gem::Package::TarWriter.new(tarfile) do |tar|
path = "#{staging_dir}/#{packager.package_name}"
name = packager.package_name
mode = File.stat(path).mode
tar.add_file(name, mode) do |tf|
- File.open(path, 'rb') do |file|
+ File.open(path, "rb") do |file|
tf.write(file.read)
end
end
end
@@ -126,10 +126,10 @@
# specifies a different compression level.
#
# @return [StringIO]
#
def gzipped_tarball
- gz = StringIO.new('')
+ gz = StringIO.new("")
z = Zlib::GzipWriter.new(gz, compression_level)
z.write(tarball.string)
z.close
# z was closed to write the gzip footer, so