Giter VIP home page Giter VIP logo

unpack's Introduction

Unpack*(er)* - run files, run

What is Unpack?

Unpack makes it possible to unarchive rar and zip files using ruby.

You pass a directory and it will find all your archive files, unpack and remove them (if you want to).

So how do I use it?

Start by installing the gem

sudo gem install unpack

Start irb and include the gem, require 'unpack'

Working with a directory

Unpack everything in the current directory

$ Unpack.runner!
=> [#<Container:0x000001010ab458 @files=["dmd-tsa-cd2.avi"], @directory="/Downloads/Some.Super.Movie/CD2">]

Unpack everything in another directory

$ Unpack.runner!('/some/dir')
=> [#<Container:0x000001010ab458 @files=["some_files.mov"], @directory="/some/dir">]

Unpack and delete archived file

$ Unpack.runner!('.', remove: true)
=> [#<Container:0x000001010ab458 @files=["dmd-tsa-cd2.avi"], @directory="/Downloads/Some.Super.Movie/CD2">]
$ Unpack.runner!('.', remove: true)
=> []

Remove every archive file, even if nothing where unpacked

$ Unpack.runner!('.', remove: true, force_remove: true)
=> []

Unpack all archived file, but not deeper 3 folders down

$ Unpack.runner!('.', depth: 3)
=> [#<Container:0x000001010ab458 @files=["dmd-tsa-cd2.avi"], @directory="/Downloads/Some.Super.Movie/CD2">]

Unpack everything, even one file directories

To prevent you from unarchive files in folders that contains subtitles and other nonrelevant files, the folder must contain 5 archive files or more.

If you want to unpack everything, even subtitles directories, then you will have to specify the min_files option.

$ Unpack.runner!('.', min_files: 0)
=> [#<Container:0x000001010ab458 @files=["english.str"], @directory="/Downloads/Subtitle/">]

Working with one specific file

Unpack a file

$ Unpack.it!(file: 'zip/my_file.zip')
=> [#<Container:0x000001010ab458 @files=["file1", "file2"], @directory="/Downloads/my/files/zip">]

Unpack a specific file, removing it when done

$ Unpack.it!(file: 'zip/my_file.zip', remove: true)
=> [#<Container:0x000001010ab458 @files=["file1", "file2"], @directory="/Downloads/my/files/zip">]

Unpack a specific file and move the new files to a destination directory

$ Unpack.it!(file: 'zip/my_file.zip', to: '/tmp')
=> [#<Container:0x000001010ab458 @files=["file1", "file2"], @directory="/tmp">]

Some configure alternatives

The runner! method

  • ** :min_files ** (Integer) The minimum amount of files in the directory you want to archive the files in. Default is 5.
  • ** :depth ** (Integer) The maximum folder depth. Default is 2.
  • ** :debugger ** (Boolean) Prints some debug output into the console. Default is false.
  • ** :force_remove ** (Boolean) Remove rarfiles, even if no files where unarchived. Default is false. To get this to work you also have to set the remove option to true.
  • ** :remove ** (Boolean) Removes archived files after they have been used. Default is false.
  • ** :absolute_path_to_unrar ** (String) The absolut path to the unrar binary. Default is the unrar binary that comes with the gem.

The it! method

  • :to (String) The absolute or relative path to the destination directory. If nothing is defined, the :file path will be used.
  • :file (String) The absolute or relative path to the archive file.
  • :remove (Boolean) See the runner! method above
  • :absolute_path_to_unrar (String) See the runner! method above
  • :debugger (String) See the runner! method above

What is being returned?

The runner! method returns an Array of Container instances. The it! method returns an instance of Container.

These are the accessors of the Container class.

  • files (String) The absolut path to the files that where unarchived.
  • directory (String) The absolut path to the folder containing the files.

This sounds supr, how do I help?

  • Start by copying the project or make your own branch.
  • Navigate to the root path of the project and run bundle.
  • Start by running all tests using rspec, autotest.
  • Implement your own code, write some tests, commit and do a pull request.

Requirements

The gem is tested in OS X 10.6.6 using Ruby 1.9.2 and 1.8.7.

Thanks to ...

unpack's People

Contributors

oleander avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.