Add usage example to README & change headers to allow h3
This commit is contained in:
parent
dbc0213633
commit
8ca332df72
91
README.md
91
README.md
|
|
@ -1,10 +1,8 @@
|
||||||
rubyzip [](http://travis-ci.org/aussiegeek/rubyzip)
|
# rubyzip [](http://travis-ci.org/aussiegeek/rubyzip)
|
||||||
=======
|
|
||||||
|
|
||||||
rubyzip is a ruby library for reading and writing zip files.
|
rubyzip is a ruby library for reading and writing zip files.
|
||||||
|
|
||||||
Installation
|
## Installation
|
||||||
------------
|
|
||||||
rubyzip is available on RubyGems, so:
|
rubyzip is available on RubyGems, so:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
@ -17,37 +15,30 @@ Or in your Gemfile:
|
||||||
gem 'rubyzip'
|
gem 'rubyzip'
|
||||||
```
|
```
|
||||||
|
|
||||||
Developing
|
## Usage
|
||||||
----------
|
|
||||||
|
|
||||||
To run tests you need run next commands:
|
### Basic zip archive creation
|
||||||
|
|
||||||
```
|
```ruby
|
||||||
bundle install
|
require 'rubygems'
|
||||||
rake
|
require 'zip/zip'
|
||||||
|
|
||||||
|
folder = "Users/me/Desktop/stuff_to_zip"
|
||||||
|
input_filenames = ['image.jpg', 'description.txt', 'stats.csv']
|
||||||
|
|
||||||
|
zipfile_name = "/Users/me/Desktop/archive.zip"
|
||||||
|
|
||||||
|
Zip::ZipFile.open(zipfile_name, Zip::ZipFile::CREATE) do |zipfile|
|
||||||
|
input_filenames.each do |filename|
|
||||||
|
# Two arguments:
|
||||||
|
# - The name of the file as it will appear in the archive
|
||||||
|
# - The original file, including the path to find it
|
||||||
|
zipfile.add(filename, folder + '/' + filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
Configuration
|
## Further Documentation
|
||||||
-------------
|
|
||||||
|
|
||||||
By default, rubyzip will not overwrite files if they already exist inside of the extracted path. To change this behavior, you may specify a configuration option like so:
|
|
||||||
|
|
||||||
```
|
|
||||||
Zip.options[:on_exists_proc] = true
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using rubyzip with rails, consider placing this snippet of code in an initializer file such as `config/initializers/rubyzip.rb`
|
|
||||||
|
|
||||||
Additionally, if you want to configure rubyzip to overwrite existing files while creating a .zip file, you can do so with the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
Zip.options[:continue_on_exists_proc] = true
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Documentation
|
|
||||||
-------------
|
|
||||||
|
|
||||||
|
|
||||||
There is more than one way to access or create a zip archive with
|
There is more than one way to access or create a zip archive with
|
||||||
rubyzip. The basic API is modeled after the classes in
|
rubyzip. The basic API is modeled after the classes in
|
||||||
|
|
@ -76,22 +67,39 @@ For details about the specific behaviour of classes and methods refer
|
||||||
to the test suite. Finally you can generate the rdoc documentation or
|
to the test suite. Finally you can generate the rdoc documentation or
|
||||||
visit http://rubyzip.sourceforge.net.
|
visit http://rubyzip.sourceforge.net.
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
rubyzip is distributed under the same license as ruby. See
|
## Configuration
|
||||||
http://www.ruby-lang.org/en/LICENSE.txt
|
|
||||||
|
|
||||||
|
By default, rubyzip will not overwrite files if they already exist inside of the extracted path. To change this behavior, you may specify a configuration option like so:
|
||||||
|
|
||||||
Website and Project Home
|
```
|
||||||
------------------------
|
Zip.options[:on_exists_proc] = true
|
||||||
|
```
|
||||||
|
|
||||||
|
If you're using rubyzip with rails, consider placing this snippet of code in an initializer file such as `config/initializers/rubyzip.rb`
|
||||||
|
|
||||||
|
Additionally, if you want to configure rubyzip to overwrite existing files while creating a .zip file, you can do so with the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
Zip.options[:continue_on_exists_proc] = true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
To run tests you need run next commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
bundle install
|
||||||
|
rake
|
||||||
|
```
|
||||||
|
|
||||||
|
## Website and Project Home
|
||||||
|
|
||||||
http://github.com/aussiegeek/rubyzip
|
http://github.com/aussiegeek/rubyzip
|
||||||
|
|
||||||
http://rdoc.info/github/aussiegeek/rubyzip/master/frames
|
http://rdoc.info/github/aussiegeek/rubyzip/master/frames
|
||||||
|
|
||||||
Authors
|
## Authors
|
||||||
-------
|
|
||||||
|
|
||||||
Alexander Simonov ( alex at simonov.me)
|
Alexander Simonov ( alex at simonov.me)
|
||||||
|
|
||||||
|
|
@ -102,3 +110,8 @@ Thomas Sondergaard (thomas at sondergaard.cc)
|
||||||
Technorama Ltd. (oss-ruby-zip at technorama.net)
|
Technorama Ltd. (oss-ruby-zip at technorama.net)
|
||||||
|
|
||||||
extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
|
extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
rubyzip is distributed under the same license as ruby. See
|
||||||
|
http://www.ruby-lang.org/en/LICENSE.txt
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue