Skip to content

Commit 3f53a40

Browse files
committed
Updated for Crystal 0.35.0
1 parent a36e71b commit 3f53a40

File tree

7 files changed

+20
-23
lines changed

7 files changed

+20
-23
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Crystal bindings to the XZ (lzma) compression library.
2020
require "xz"
2121
```
2222

23-
`XZ` shard provides both `XZ::Reader` and `XZ::Writer`.
23+
`XZ` shard provides both `Compress::XZ::Reader` and `Compress::XZ::Writer`.
2424

2525
## Example: decompress an xz file
2626
#
2727
```crystal
2828
require "xz"
2929
3030
string = File.open("file.xz") do |file|
31-
XZ::Reader.open(file) do |xz|
31+
Compress::XZ::Reader.open(file) do |xz|
3232
xz.gets_to_end
3333
end
3434
end
@@ -44,17 +44,13 @@ File.write("file.txt", "abcd")
4444
4545
File.open("./file.txt", "r") do |input_file|
4646
File.open("./file.xz", "w") do |output_file|
47-
XZ::Writer.open(output_file) do |xz|
47+
Compress::XZ::Writer.open(output_file) do |xz|
4848
IO.copy(input_file, xz)
4949
end
5050
end
5151
end
5252
```
5353

54-
## Development
55-
56-
TODO: Write development instructions here
57-
5854
## Contributing
5955

6056
1. Fork it (<https://github.com/naqvis/xz.cr/fork>)

shard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: xz
2-
version: 0.1.1
2+
version: 0.1.2
33

44
authors:
55
- Ali Naqvi <[email protected]>
66
description: |
77
Crystal bindings to the XZ (lzma) compression library.
88
9-
crystal: 0.34.0
9+
crystal: 0.35.0
1010

1111
license: MIT

spec/xz_spec.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require "./spec_helper"
22
require "file_utils"
3-
describe XZ do
3+
describe Compress::XZ do
44
it "Test Round Trip" do
55
compressed_io = IO::Memory.new
66
str = "The quick brown fox jumps over the lazy dog."
7-
XZ::Writer.open(compressed_io) do |zw|
7+
Compress::XZ::Writer.open(compressed_io) do |zw|
88
zw.write str.to_slice
99
end
1010
compressed_io.rewind
11-
uncompressed = XZ::Reader.open(compressed_io) do |zr|
11+
uncompressed = Compress::XZ::Reader.open(compressed_io) do |zr|
1212
zr.gets_to_end
1313
end
1414
uncompressed.should eq(str)
@@ -17,14 +17,14 @@ describe XZ do
1717
it "Test write/Read file" do
1818
File.open("./LICENSE", "r") do |input_file|
1919
File.open("./LICENSE.xz", "w") do |output_file|
20-
XZ::Writer.open(output_file) do |xz|
20+
Compress::XZ::Writer.open(output_file) do |xz|
2121
IO.copy(input_file, xz)
2222
end
2323
end
2424
end
2525
expected = File.read("./LICENSE")
2626
got = File.open("./LICENSE.xz") do |file|
27-
XZ::Reader.open(file) do |xz|
27+
Compress::XZ::Reader.open(file) do |xz|
2828
xz.gets_to_end
2929
end
3030
end

src/xz.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# XZ Crystal Wrapper
22
require "semantic_version"
33

4-
module XZ
5-
VERSION = "0.1.1"
4+
module Compress::XZ
5+
VERSION = "0.1.2"
66

77
LZMA_VERSION = SemanticVersion.parse String.new(LZMA.version_string)
88
LZMA_VERSION_MINIMUM = SemanticVersion.parse("5.2.4")

src/xz/lib.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module XZ
1+
module Compress::XZ
22
@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs liblzma 2> /dev/null|| printf %s '--llzma'`")]
33
lib LZMA
44
alias Uint8T = UInt8

src/xz/reader.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
# require "xz"
99

1010
# string = File.open("file.xz") do |file|
11-
# XZ::Reader.open(file) do |xz|
11+
# Compress::XZ::Reader.open(file) do |xz|
1212
# xz.gets_to_end
1313
# end
1414
# end
1515
# pp string
1616
# ```
1717

18-
class XZ::Reader < IO
18+
class Compress::XZ::Reader < IO
1919
LZMA_CONCATENATED = 0x08
2020
include IO::Buffered
2121

src/xz/writer.cr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
#
1616
# File.open("./file.txt", "r") do |input_file|
1717
# File.open("./file.xz", "w") do |output_file|
18-
# XZ::Writer.open(output_file) do |xz|
18+
# Compress::XZ::Writer.open(output_file) do |xz|
1919
# IO.copy(input_file, xz)
2020
# end
2121
# end
2222
# end
2323
# ```
24-
class XZ::Writer < IO
24+
class Compress::XZ::Writer < IO
2525
# If `#sync_close?` is `true`, closing this IO will close the underlying IO.
2626
property? sync_close : Bool
2727

@@ -80,14 +80,15 @@ class XZ::Writer < IO
8080
end
8181

8282
# See `IO#write`.
83-
def write(slice : Bytes) : Nil
83+
def write(slice : Bytes) : Int64
8484
check_open
8585

86-
return if slice.empty?
86+
return 0i64 if slice.empty?
8787

8888
@stream.next_in = slice.to_unsafe
8989
@stream.avail_in = slice.size
9090
do_action LZMA::Action::Run
91+
slice.size.to_i64
9192
end
9293

9394
# See `IO#flush`.

0 commit comments

Comments
 (0)