Skip to content

Commit

Permalink
Merge pull request #47 from malithsen/gzip-tar
Browse files Browse the repository at this point in the history
gzip tar #41
  • Loading branch information
pickhardt committed May 9, 2014
2 parents fed0e10 + 663e229 commit 805560f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ The following is a non-exhaustive list of things you can do:
betty uncompress something.tar.gz
betty unarchive something.tar.gz to somedir
(You can use unzip, unarchive, untar, uncompress, and expand interchangeably.)
betty compress /path/to/dir

iTunes
betty mute itunes
Expand Down
16 changes: 16 additions & 0 deletions lib/internet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ def self.uncompress(command)
}
end
end

def self.compress(command)
match = command.match(/^(?:zip|archive|tar gzip|gzip tar|compress)\s+([^\s]+)(\s+(?:directory|dir|folder|path))?$/i)

if match
what_file = match[1].strip

{
:command => "cd #{what_file}; tar -czvf #{what_file}.tar.gz *"
:explanation => "Compress the contents of #{what_file} directory, outputting the compressed file to parent directory"
}
end
end

def self.interpret(command)
responses = []
Expand All @@ -40,6 +53,9 @@ def self.interpret(command)

uncompress_command = self.uncompress(command)
responses << uncompress_command if uncompress_command

compress_command = self.compress(command)
responses << compress_command if compress_command

responses
end
Expand Down

0 comments on commit 805560f

Please sign in to comment.