Skip to content

Commit

Permalink
Merge pull request #38 from sam0x17/master
Browse files Browse the repository at this point in the history
fix warnings for Crystal 0.35.1
  • Loading branch information
straight-shoota authored Oct 26, 2020
2 parents 4fb8df7 + fb3091b commit fb07911
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/baked_file_system.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "base64"
require "gzip"
require "compress/gzip"
require "./baked_file_system/*"

# A `BakedFileSystem` allows to include ("bake") static files into a compiled
Expand Down Expand Up @@ -49,7 +49,7 @@ module BakedFileSystem
def initialize(@path, @size, @compressed, @slice : Bytes)
@path = "/" + @path unless @path.starts_with? '/'
@memory_io = IO::Memory.new(@slice)
@wrapped_io = compressed? ? @memory_io : Gzip::Reader.new(@memory_io)
@wrapped_io = compressed? ? @memory_io : Compress::Gzip::Reader.new(@memory_io)
end

def read(slice : Bytes)
Expand All @@ -63,17 +63,17 @@ module BakedFileSystem
@slice.bytesize
end

def write(slice : Bytes)
def write(slice : Bytes) : Nil
raise "Can't write to BakedFileSystem::BakedFile"
end

def rewind
@memory_io.rewind
@wrapped_io = compressed? ? @memory_io : Gzip::Reader.new(@memory_io)
@wrapped_io = compressed? ? @memory_io : Compress::Gzip::Reader.new(@memory_io)
end

# Returns a `Bytes` holding the (compressed) content of this virtual file.
# This data needs to be extracted using a `Gzip::Reader` unless `#compressed?` is true.
# This data needs to be extracted using a `Compress::Gzip::Reader` unless `#compressed?` is true.
def to_slice : Bytes
@slice
end
Expand Down
4 changes: 2 additions & 2 deletions src/loader/loader.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "base64"
require "gzip"
require "compress/gzip"
require "./string_encoder"

module BakedFileSystem
Expand Down Expand Up @@ -39,7 +39,7 @@ module BakedFileSystem
if compressed
IO.copy file, encoder
else
Gzip::Writer.open(encoder) do |writer|
Compress::Gzip::Writer.open(encoder) do |writer|
IO.copy file, writer
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/loader/string_encoder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BakedFileSystem::StringEncoder < IO
raise "Can't read from StringEncoder"
end

def write(slice : Bytes)
def write(slice : Bytes) : Nil
slice.each do |byte|
case byte
when 34_u8, 35_u8, 92_u8, 123_u8
Expand All @@ -36,7 +36,7 @@ class BakedFileSystem::StringEncoder < IO
else
@io << "\\x"
@io << '0' if byte < 0x10_u8
byte.to_s(16, @io, upcase: true)
byte.to_s(@io, 16, upcase: true)
end
end
end
Expand Down

0 comments on commit fb07911

Please sign in to comment.