Skip to content

Commit 5fe0bcd

Browse files
committed
Misc doc changes
Besides other fixes, this commit allows the generated HTML doc for HexDocs.pm will become the main doc source for this Elixir module. List of changes: * Use common source url * Set readme as main html doc * Use and set ex_doc to latest version * Add license section * Update gitignore * Add code formatter * Fix markdown and typos * Badges and more badges! * Tally minimum Elixir requirement version with CI
1 parent 40778e6 commit 5fe0bcd

File tree

10 files changed

+94
-77
lines changed

10 files changed

+94
-77
lines changed

.formatter.exs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

.gitignore

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# The directory Mix downloads your dependencies sources to.
88
/deps/
99

10-
# Where 3rd-party dependencies like ExDoc output generated docs.
10+
# Where third-party dependencies like ExDoc output generated docs.
1111
/doc/
1212

1313
# Ignore .fetch files in case you like to edit your project deps locally.
@@ -19,4 +19,8 @@ erl_crash.dump
1919
# Also ignore archive artifacts (built via "mix archive.build").
2020
*.ez
2121

22-
.elixir_ls
22+
# Ignore package tarball (built via "mix hex.build").
23+
zstream-*.tar
24+
25+
# Temporary files for e.g. tests.
26+
/tmp

README.md

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
# Zstream
22

3-
[![Hex.pm](https://img.shields.io/hexpm/v/zstream.svg)](https://hex.pm/packages/zstream)
3+
[![CI](https://github.com/ananthakumaran/zstream/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/ananthakumaran/zstream/actions?query=workflow%3A.github%2Fworkflows%2Fci.yml)
4+
[![Module Version](https://img.shields.io/hexpm/v/zstream.svg)](https://hex.pm/packages/zstream)
5+
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/zstream/)
6+
[![Total Download](https://img.shields.io/hexpm/dt/zstream.svg)](https://hex.pm/packages/zstream)
7+
[![License](https://img.shields.io/hexpm/l/zstream.svg)](https://github.com/ananthakumaran/zstream/blob/master/LICENSE)
8+
[![Last Updated](https://img.shields.io/github/last-commit/ananthakumaran/zstream.svg)](https://github.com/ananthakumaran/zstream/commits/master)
49

5-
An elixir library to read and write ZIP file in a streaming
10+
An Elixir library to read and write ZIP file in a streaming
611
fashion. It could consume data from any stream and write to any stream
7-
with constant memory overhead
12+
with constant memory overhead.
813

9-
## Example
14+
## Installation
15+
16+
The package can be installed by adding `:zstream` to your list of dependencies
17+
in `mix.exs`:
18+
19+
```elixir
20+
def deps do
21+
[
22+
{:zstream, "~> 0.5.0"}
23+
]
24+
end
25+
```
26+
27+
## Examples
1028

1129
```elixir
1230
Zstream.zip([
@@ -40,4 +58,8 @@ end)
4058
* compression (deflate, stored)
4159
* zip64
4260

43-
see [documenation](https://hexdocs.pm/zstream/) for more information.
61+
## License
62+
63+
Copyright (c) 2017 Anantha Kumaran
64+
65+
This library is MIT licensed. See the [LICENSE](https://github.com/ananthakumaran/zstream/blob/master/LICENSE) for details.

lib/zstream.ex

+26-47
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
defmodule Zstream do
22
@moduledoc """
3-
Module for reading and writing ZIP file stream
4-
5-
## Example
6-
7-
```
8-
Zstream.zip([
9-
Zstream.entry("report.csv", Stream.map(records, &CSV.dump/1)),
10-
Zstream.entry("catfilm.mp4", File.stream!("/catfilm.mp4", [], 512), coder: Zstream.Coder.Stored)
11-
])
12-
|> Stream.into(File.stream!("/archive.zip"))
13-
|> Stream.run
14-
```
15-
16-
```
17-
File.stream!("archive.zip", [], 512)
18-
|> Zstream.unzip()
19-
|> Enum.reduce(%{}, fn
20-
{:entry, %Zstream.Entry{name: file_name} = entry}, state -> state
21-
{:data, data}, state -> state
22-
{:data, :eof}, state -> state
23-
end)
24-
```
3+
Module for reading and writing ZIP file stream.
254
"""
265

276
defmodule Entry do
@@ -38,58 +17,58 @@ defmodule Zstream do
3817
@opaque entry :: map
3918

4019
@doc """
41-
Creates a ZIP file entry with the given `name`
20+
Creates a ZIP file entry with the given `name`.
4221
4322
The `enum` could be either lazy `Stream` or `List`. The elements in `enum`
4423
should be of type `iodata`
4524
4625
## Options
4726
48-
* `:coder` (module | {module, list}) - The compressor that should be
49-
used to encode the data. Available options are
27+
* `:coder` (module | {module, list}) - The compressor that should be
28+
used to encode the data. Available options are:
5029
51-
`Zstream.Coder.Deflate` - use deflate compression
30+
- `Zstream.Coder.Deflate` - use deflate compression
5231
53-
`Zstream.Coder.Stored` - store without any compression
32+
- `Zstream.Coder.Stored` - store without any compression
5433
55-
Defaults to `Zstream.Coder.Deflate`
34+
- Defaults to `Zstream.Coder.Deflate`
5635
57-
* `:encryption_coder` ({module, keyword}) - The encryption module that should be
58-
used to encrypt the data. Available options are
36+
* `:encryption_coder` ({module, keyword}) - The encryption module that should be
37+
used to encrypt the data. Available options are:
5938
60-
`Zstream.EncryptionCoder.Traditional` - use tranditional zip
61-
encryption scheme. `:password` key should be present in the
62-
options. Example `{Zstream.EncryptionCoder.Traditional, password:
63-
"secret"}`
39+
- `Zstream.EncryptionCoder.Traditional` - use tranditional zip
40+
encryption scheme. `:password` key should be present in the
41+
options. Example `{Zstream.EncryptionCoder.Traditional, password:
42+
"secret"}`
6443
65-
`Zstream.EncryptionCoder.None` - no encryption
44+
- `Zstream.EncryptionCoder.None` - no encryption
6645
67-
Defaults to `Zstream.EncryptionCoder.None`
46+
- Defaults to `Zstream.EncryptionCoder.None`
6847
6948
70-
* `:mtime` (DateTime) - File last modication time. Defaults to system local time.
49+
* `:mtime` (DateTime) - File last modication time. Defaults to system local time.
7150
"""
7251
@spec entry(String.t(), Enumerable.t(), Keyword.t()) :: entry
7352
defdelegate entry(name, enum, options \\ []), to: Zstream.Zip
7453

7554
@doc """
76-
Creates a ZIP file stream
55+
Creates a ZIP file stream.
7756
78-
entries are consumed one by one in the given order
57+
Entries are consumed one by one in the given order.
7958
8059
## Options
8160
82-
* `:zip64` (boolean) - If set to `true` zip64 format is used. Zip64
83-
can support files more than 4 GB in size, but not all the unzip
84-
programs support this format. Defaults to `false`
61+
* `:zip64` (boolean) - If set to `true` zip64 format is used. Zip64
62+
can support files more than 4 GB in size, but not all the unzip
63+
programs support this format. Defaults to `false`.
8564
"""
8665
@spec zip([entry], Keyword.t()) :: Enumerable.t()
8766
defdelegate zip(entries, options \\ []), to: Zstream.Zip
8867

8968
@doc """
90-
Unzips file stream
69+
Unzips file stream.
9170
92-
returns a new stream which emits the following tuples for each zip entry
71+
Returns a new stream which emits the following tuples for each zip entry.
9372
9473
{`:entry`, `t:Zstream.Entry.t/0`} - Indicates a new file entry.
9574
@@ -102,11 +81,11 @@ defmodule Zstream do
10281
allows the writer to zip streams with unknown size. But this
10382
prevents the reader from unzipping the file in a streaming fashion,
10483
because to find the file size one has to go to the end of the
105-
stream. Ironcially, if you use Zstream to zip a file, the same file
84+
stream. Ironically, if you use Zstream to zip a file, the same file
10685
can't be unzipped using Zstream.
10786
108-
* doesn't support file which uses data descriptor header
109-
* doesn't support encrypted file
87+
* Doesn't support file which uses data descriptor header.
88+
* Doesn't support encrypted file.
11089
"""
11190
defdelegate unzip(stream), to: Zstream.Unzip
11291
end

lib/zstream/coder/deflate.ex

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
defmodule Zstream.Coder.Deflate do
2-
@behaviour Zstream.Coder
32
@moduledoc """
4-
Implements the Deflate coder
3+
Implements the Deflate coder.
54
"""
65

6+
@behaviour Zstream.Coder
7+
78
def init(_opts) do
89
z = :zlib.open()
910
:ok = :zlib.deflateInit(z, :default, :deflated, -15, 8, :default)

lib/zstream/coder/stored.ex

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
defmodule Zstream.Coder.Stored do
2-
@behaviour Zstream.Coder
32
@moduledoc """
4-
Implements the Stored(uncompressed) coder
3+
Implements the Stored(uncompressed) coder.
54
"""
65

6+
@behaviour Zstream.Coder
7+
78
def init(_opts) do
89
nil
910
end

lib/zstream/encryption_coder/none.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
defmodule Zstream.EncryptionCoder.None do
2-
@behaviour Zstream.EncryptionCoder
32
@moduledoc """
4-
Noop encryption
3+
Noop encryption.
54
"""
5+
6+
@behaviour Zstream.EncryptionCoder
7+
68
def init(_opts) do
79
nil
810
end

lib/zstream/encryption_coder/traditional.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
defmodule Zstream.EncryptionCoder.Traditional do
2-
@behaviour Zstream.EncryptionCoder
32
@moduledoc """
4-
Implements the trandition encryption
3+
Implements the tradition encryption.
54
"""
5+
6+
@behaviour Zstream.EncryptionCoder
7+
68
use Bitwise
79

810
defmodule State do

mix.exs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
defmodule Zstream.Mixfile do
22
use Mix.Project
33

4+
@source_url "https://github.com/ananthakumaran/zstream"
45
@version "0.5.2"
56

67
def project do
78
[
89
app: :zstream,
910
version: @version,
10-
elixir: "~> 1.4",
11+
elixir: "~> 1.6",
1112
start_permanent: Mix.env() == :prod,
1213
description: "Streaming zip file writer and reader",
1314
package: package(),
@@ -28,25 +29,25 @@ defmodule Zstream.Mixfile do
2829

2930
defp deps do
3031
[
31-
{:temp, "~> 0.4", only: :test},
32-
{:ex_doc, "~> 0.19", only: :dev}
32+
{:temp, "~> 0.4", only: :test, runtime: false},
33+
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
3334
]
3435
end
3536

3637
defp package do
3738
%{
3839
licenses: ["MIT"],
39-
links: %{"Github" => "https://github.com/ananthakumaran/zstream"},
40-
maintainers: ["[email protected]"]
40+
links: %{"GitHub" => @source_url},
41+
maintainers: ["Anantha Kumaran <[email protected]>"]
4142
}
4243
end
4344

4445
defp docs do
4546
[
46-
source_url: "https://github.com/ananthakumaran/zstream",
47-
source_ref: "v#{@version}",
48-
main: Zstream,
49-
extras: ["README.md"]
47+
extras: ["README.md"],
48+
main: "readme",
49+
source_url: @source_url,
50+
source_ref: "v#{@version}"
5051
]
5152
end
5253
end

mix.lock

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
%{
2-
"earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm"},
3-
"ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
4-
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
5-
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
6-
"nimble_parsec": {:hex, :nimble_parsec, "0.5.2", "1d71150d5293d703a9c38d4329da57d3935faed2031d64bc19e77b654ef2d177", [:mix], [], "hexpm"},
7-
"temp": {:hex, :temp, "0.4.3", "b641c3ce46094839bff110fdb64162536d640d9d47ca2c37add9104a2fa3bd81", [:mix], [], "hexpm"},
2+
"earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"},
3+
"earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
4+
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
5+
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
6+
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
7+
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
8+
"temp": {:hex, :temp, "0.4.3", "b641c3ce46094839bff110fdb64162536d640d9d47ca2c37add9104a2fa3bd81", [:mix], [], "hexpm", "d7535439aeb967da5c37c96215fc204d77ec578b5cfc1c7948667052bf075ab9"},
89
}

0 commit comments

Comments
 (0)