aboutsummaryrefslogtreecommitdiff
path: root/index.html
blob: 0314d29a6dd1e8a3a31ef01adc735e72ae0e1bc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta id="repository-name" content="github.com/pablotron/zip-crystal">
  <link href="css/style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="js/doc.js"></script>
  <title>README - github.com/pablotron/zip-crystal</title>
</head>
<body>

<div id="types-list">
  <div id="search-box">
    <input type="search" id="search-input" placeholder="Search...">
  </div>

  <ul>
    <li class="current"><a href="index.html">README</a></li>
  </ul>

  <ul>
  
  <li class="parent " data-id="github.com/pablotron/zip-crystal/Zip" data-name="zip">
      <a href="Zip.html">Zip</a>
      
        <ul>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Archive" data-name="zip::archive">
      <a href="Zip/Archive.html">Archive</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/CompressionMethod" data-name="zip::compressionmethod">
      <a href="Zip/CompressionMethod.html">CompressionMethod</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/DeflateCompressionHelper" data-name="zip::deflatecompressionhelper">
      <a href="Zip/DeflateCompressionHelper.html">DeflateCompressionHelper</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Entry" data-name="zip::entry">
      <a href="Zip/Entry.html">Entry</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Error" data-name="zip::error">
      <a href="Zip/Error.html">Error</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Extra" data-name="zip::extra">
      <a href="Zip/Extra.html">Extra</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/GeneralFlags" data-name="zip::generalflags">
      <a href="Zip/GeneralFlags.html">GeneralFlags</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/NoneCompressionHelper" data-name="zip::nonecompressionhelper">
      <a href="Zip/NoneCompressionHelper.html">NoneCompressionHelper</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Source" data-name="zip::source">
      <a href="Zip/Source.html">Source</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/TimeHelper" data-name="zip::timehelper">
      <a href="Zip/TimeHelper.html">TimeHelper</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Version" data-name="zip::version">
      <a href="Zip/Version.html">Version</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Writer" data-name="zip::writer">
      <a href="Zip/Writer.html">Writer</a>
      
    </li>
  
  <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/WriterEntry" data-name="zip::writerentry">
      <a href="Zip/WriterEntry.html">WriterEntry</a>
      
    </li>
  
</ul>

      
    </li>
  
</ul>

</div>

<div id="main-content">
<h1>zip-crystal</h1>

<p>Read and write zip archives natively from
<a href="http://crystal-lang.org/" target="_blank">Crystal</a>.</p>

<h2>Installation</h2>

<p>Add this to your application's <code>shard.yml</code>:</p>

<pre><code class='language-yaml'>dependencies:
  zip-crystal:
    github: pablotron/zip-crystal</code></pre>

<h2>Usage</h2>

<pre><code class='language-crystal'><span class="k">require</span> <span class="s">&quot;zip-crystal/zip&quot;</span>

<span class="c"># write to &quot;foo.zip&quot;</span>
<span class="t">Zip</span>.write(<span class="s">&quot;foo.zip&quot;</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span>
  <span class="c"># add &quot;bar.txt&quot; with contents &quot;hello&#33;&quot;</span>
  zip.add(<span class="s">&quot;bar.txt&quot;</span>, <span class="s">&quot;hello&#33;&quot;</span>)

  <span class="c"># add local file &quot;/path/to/image.png&quot; as &quot;image.png&quot;</span>
  zip.add_file(<span class="s">&quot;image.png&quot;</span>, <span class="s">&quot;/path/to/image.png&quot;</span>)
<span class="k">end</span>

<span class="c"># create memory io</span>
mem_io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span>

<span class="c"># open &quot;/some/other/path/image.png&quot; for writing</span>
<span class="t">File</span>.open(<span class="s">&quot;/some/other/path/image.png&quot;</span>, <span class="s">&quot;wb&quot;</span>) <span class="k">do</span> <span class="o">|</span>file_io<span class="o">|</span>
  <span class="c"># read from &quot;foo.zip&quot;</span>
  <span class="t">Zip</span>.read(<span class="s">&quot;foo.zip&quot;</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span>
    <span class="c"># extract &quot;bar.txt&quot; to mem_io</span>
    zip[<span class="s">&quot;bar.txt&quot;</span>].read(mem_io)

    <span class="c"># extract &quot;image.png&quot; to file_io</span>
    zip[<span class="s">&quot;image.png&quot;</span>].read(file_io)
  <span class="k">end</span>
<span class="k">end</span></code></pre>

<p>See the <a href="https://pablotron.github.com/zip-crystal/" target="_blank">API documentation</a>
for additional information.</p>

<h2>Development</h2>

<p>TODO: Write development instructions here</p>

<h2>Contributing</h2>

<ol><li>Fork it ( https://github.com/pablotron/zip-crystal/fork )</li><li>Create your feature branch (git checkout -b my-new-feature)</li><li>Commit your changes (git commit -am 'Add some feature')</li><li>Push to the branch (git push origin my-new-feature)</li><li>Create a new Pull Request</li></ol>

<h2>Contributors</h2>

<ul><li><a href="https://github.com/pablotron" target="_blank">pablotron</a> Paul Duncan - creator, maintainer</li></ul>
</div>
</body>
</html>