Skip to content

Commit

Permalink
Added licensing
Browse files Browse the repository at this point in the history
  • Loading branch information
Quintus committed Feb 14, 2011
1 parent 8153fdb commit deba9dc
Show file tree
Hide file tree
Showing 8 changed files with 597 additions and 2 deletions.
339 changes: 339 additions & 0 deletions COPYING.txt

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
= libarchive-ruby

This is <b>libarchive-ruby</b>, your preferred archiving toolkit in Ruby!
libarchive-ruby is a Ruby binding to the famous
{libarchive library}[http://code.google.com/p/libarchive/] and supports
nearly all features the library exposes through it's C++ interface.

librarchive-ruby focuses on a clean and ruby-like syntax that makes it trivial
to create, read, write and extract archive files of various formats. Want to
know more? Keep reading!

== Prerequesites

In order to successfully install libarchive-ruby, you need the following:

* Ruby >= 1.9.2
* A C++ compiler (we use the {GNU project's}[http://www.gnu.org] <tt>g++</tt>)
* libarchive (we tested with 2.8.4)

== How to install?

=== RubyGems

This is the easiest and preferred way. Ensure you have a proper built
environment for C++ code, and then do

# gem install libarchive-ruby

=== Building from source

If you want to be on the bleeding etch, clone the our
{git repository at GitHub}[https://github.com/Hanmac/libarchive-ruby]:

$ git clone https://github.com/Hanmac/libarchive-ruby.git
$ cd libarchive-ruby

Then you can either choose to use the library from that directory by running

$ rake compile

or to make a gem and install that one.

$ rake gem
# gem install --local pkg/libarchive-ruby-x.x.x

== How to use?

First, you have to require the library:

require "archive" #Note this is NOT "libarchive-ruby"

Then you can use the beautiful rubyish API:

=== Read an archive

Assuming, you have "myarchive.tar.bz2" in the current directory.

a = Archive.new("myarchive.tar.bz2")
puts "This archive contains:"
a.each{|entry| puts entry}
#Archive includes the Enumerable module, making available all that
#nice enumerating functionality:
puts All entries in uppercase are:
puts a.map{|entry| entry.path.upcase}.join("\n")

=== Extract an archive

Assuming you have "myarchive.tar.bz2" in the current directory.

a = Archive.new("myarchive.tar.bz2")

#Extract all files to the current directory
a.extract

#Extract a specific file
a.extract("mydir/myfile")

#Restrict what file attributes are extracted:
a.extract(:extract => Archive::EXTRACT_OWNER | Archive::EXTRACT_TIME)

#Extract only files whose path is longer than 5 characters
a.extract_if{|entry| entry.path.size > 5}

=== Create an archive

Assuming you have three files "a.rb", "b.cpp" and "README.rdoc" in your
current directory:

a = Archive.new("myarchive.tar.gz")
a << "a.rb" << "b.cpp" << "README.rdoc"

#Note how libarchive-ruby automatically picked up the archive format
#you wanted by examining the file extension:
puts a.format_name #=> POSIX ustar format

== Further reading

Have a look at the documentation for the Archive and Archive::Entry classes
for more information.

== License

libarchive-ruby is a Ruby binding for the C++ library libarchive.

Copyright © 2011 YOUR NAME

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

=== Contact

You can read me via the email address hanmac ÄT gmx DÖT de.
26 changes: 24 additions & 2 deletions Rakefile.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#Encoding: UTF-8
=begin
This file is part of libarchive-ruby.
libarchive-ruby is a Ruby binding for the C++ library libarchive.
Copyright © 2011 YOUR NAME
libarchive-ruby is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libarchive-ruby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=end

require "rake"
gem "rdoc" #Ruby's internal RDoc is not really good
require "rdoc/task"
Expand Down Expand Up @@ -26,7 +48,7 @@
#s.add_dependency("term-ansicolor", ">= 2.0.0")
#s.add_development_dependency("rdoc", ">= 3")
s.requirements = ["A C++ compiler", "libarchive library"]
s.files = ["README.rdoc", Dir["ext/*.cpp"], Dir["ext/*.hpp"], Dir["ext/*.rb"], Dir["lib/**/*.rb"]].flatten
s.files = ["README.rdoc", "COPYING.txt", Dir["ext/*.cpp"], Dir["ext/*.hpp"], Dir["ext/*.rb"], Dir["lib/**/*.rb"]].flatten
s.extensions << "ext/extconf.rb"
s.has_rdoc = true
s.extra_rdoc_files = %w[README.rdoc]
Expand All @@ -36,7 +58,7 @@
Rake::GemPackageTask.new(spec).define

Rake::RDocTask.new do |rd|
rd.rdoc_files.include("lib/**/*.rb", "ext/**/*.cpp", "ext/**/*.hpp", "**/*.rdoc")
rd.rdoc_files.include("COPYING.txt", "lib/**/*.rb", "ext/**/*.cpp", "ext/**/*.hpp", "**/*.rdoc")
rd.title = "libarchive-ruby RDocs"
rd.main = "README.rdoc"
rd.generator = "hanna" #Ignored if hanna-nouveau isn't installed
Expand Down
22 changes: 22 additions & 0 deletions ext/archive.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/****************************************************************************
This file is part of libarchive-ruby.
libarchive-ruby is a Ruby binding for the C++ library libarchive.
Copyright (C) 2011 YOUR NAME
libarchive-ruby is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libarchive-ruby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
****************************************************************************/

#include "main.hpp"
#include <vector>
#define _self wrap<rarchive*>(self)
Expand Down
22 changes: 22 additions & 0 deletions ext/entry.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/****************************************************************************
This file is part of libarchive-ruby.
libarchive-ruby is a Ruby binding for the C++ library libarchive.
Copyright (C) 2011 YOUR NAME
libarchive-ruby is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libarchive-ruby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
****************************************************************************/

#include "main.hpp"

#define _self wrap<archive_entry*>(self)
Expand Down
23 changes: 23 additions & 0 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
#Encoding: UTF-8
=begin
This file is part of libarchive-ruby.
libarchive-ruby is a Ruby binding for the C++ library libarchive.
Copyright © 2011 YOUR NAME
libarchive-ruby is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libarchive-ruby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=end

require 'mkmf'


Expand Down
22 changes: 22 additions & 0 deletions ext/main.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/****************************************************************************
This file is part of libarchive-ruby.
libarchive-ruby is a Ruby binding for the C++ library libarchive.
Copyright (C) 2011 YOUR NAME
libarchive-ruby is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libarchive-ruby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
****************************************************************************/

#ifndef __RubyAchiveMain_H__
#define __RubyAchiveMain_H__

Expand Down
22 changes: 22 additions & 0 deletions test/test_tararchive.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
#!/usr/bin/env ruby
#Encoding: UTF-8
=begin
This file is part of libarchive-ruby.
libarchive-ruby is a Ruby binding for the C++ library libarchive.
Copyright © 2011 YOUR NAME
libarchive-ruby is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
libarchive-ruby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=end

gem "test-unit", ">= 2.1" #Ensure we use the gem
require "test/unit"
require_relative File.join("..","ext","archive")
Expand Down

0 comments on commit deba9dc

Please sign in to comment.