-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,73 @@ | ||
# RsyncWrapper | ||
rsync_wrapper | ||
============== | ||
|
||
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rsync_wrapper`. To experiment with that code, run `bin/console` for an interactive prompt. | ||
`rsync_wrapper` is a simple gem that provides a ruby wrapper to the [rsync](http://linux.die.net/man/1/rsync) file copying tool. | ||
|
||
TODO: Delete this and the text above, and describe your gem | ||
|
||
## Installation | ||
Requirements and Dependencies | ||
----------------------------- | ||
|
||
Add this line to your application's Gemfile: | ||
Developed/Tested with Ruby version 2.3, but it should work with any version >= 1.9. This gem will only work on an *NIX (OSX/Linux) based operating system that has `rsync`. | ||
|
||
|
||
Installation | ||
----------------------------- | ||
|
||
Add to your `Gemfile`: | ||
|
||
```ruby | ||
gem 'rsync_wrapper' | ||
``` | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install rsync_wrapper | ||
Usage | ||
----------------------------- | ||
|
||
## Usage | ||
First, instantiate an instance of `Rsync`: | ||
|
||
TODO: Write usage instructions here | ||
```ruby | ||
rsync = Rsync.new(**options) | ||
``` | ||
|
||
## Development | ||
The constructor accepts the following named arguments: | ||
|
||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. | ||
| Argument Name | Required? | Object Type | Description | | ||
|-----------------------|-----------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `:src_dir` | Required | `String` | An absolute path representing the source directory to have `rsync` copy. e.g., `"/Users/seanhuber/Documents/my_pdfs"` | | ||
| `:dest_dir` | Required | `String` | An absolute path representing the destination directory that `rsync` will copy the `:src_dir` to. | | ||
| `:include_extensions` | Optional | `Array` | An array of symbols or strings for each file extension `rsync` should include, e.g., `[:doc, :docx, :pdf]` | | ||
| `:subdirs_only` | Optional | `Boolean` | An option to have `rsync` only sync files that are in subfolders of `:src_dir`. Defaults to `false`. | | ||
| `:log_dir` | Optional | `String` | `rsync_wrapper` has `rsync` pipe its results into a logfile so that the ruby code can then parse this file (and then deletes it). This option should be set to the absolute path of the directory where the temporary logfile will be stored. | | ||
| `:logfile` | Optional | `String` | If the `:log_dir` is not specified, you can provide an explicit path for `rsync_wrapper`'s temporary logfile. | | ||
|
||
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). | ||
To execute `rsync`, invoke the `sync!` method which accepts a block with 2 parameters: | ||
|
||
## Contributing | ||
| Argument Index | Object Type | Description | | ||
|----------------|-------------|-----------------------------------------------------------------------------------------| | ||
| `0` | `String` | The relative path (relative to `:dest_dir` from above) of the copied file. | | ||
| `1` | `Boolean` | `true` if the copied file is a new file. `false` if the copied file is an updated file. | | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rsync_wrapper. | ||
Example: | ||
|
||
```ruby | ||
source_directory = '/Users/seanhuber/Documents/my_pdfs' | ||
destination_directory = '/Users/seanhuber/Documents/my_pdfs (copied)' | ||
|
||
rsync = Rsync.new(src_dir: source_directory, dest_dir: destination_directory) | ||
|
||
rsync.sync! do |file_path, new_file| | ||
puts "Full Path: #{File.join(destination_directory, file_path)}" | ||
puts "The relative path of the new file is: #{file_path}" | ||
if new_file | ||
puts "This is a brand new file." | ||
else | ||
puts "This is an updated file." | ||
end | ||
end | ||
``` | ||
|
||
## License | ||
|
||
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). | ||
License | ||
----------------------------- | ||
|
||
MIT-LICENSE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RsyncWrapper | ||
VERSION = "0.1.0" | ||
VERSION = '1.0.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters