rsync_wrapper 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cba4bd6a73d13ae9dc92c566a2694e1197117a97
4
- data.tar.gz: 2b83903b66a5022ce08aa433414901c85210876d
3
+ metadata.gz: 686b2404897c84aee2cbcd4c5cf046a91e8f6d1b
4
+ data.tar.gz: 0279fe6f44e171d042d8161d0b4f7ee7863039d4
5
5
  SHA512:
6
- metadata.gz: 1a8143497aa2eaa3c7f82c88ecf6f15d3ad46545d3bdc47f762971382f7d527ba4d2769cb430fe0739c92636919ef737b4da9a6301bde4a51ef50b1b910aadf6
7
- data.tar.gz: 0f9d36b3ed59bdd9901db8a3aa916f1a3f36b0b80e02c163676ccfc45263b487aa301dc9800a17b19944693192446c755c4e0768eb589f7cfd68afd3826bd3ec
6
+ metadata.gz: bb19534e016f979ac8bc609e404e5653f5fa95e26d82945518d95efa2486d3ad167b13ec7ae0b4f7149a7a6edecd46328493179da59dc70ffef4c18afa7307b0
7
+ data.tar.gz: e71bb69e96cd2272e64f13b2fc440b246fc3fe05b22cbb79cfba225eee047cd7b2a28c876d5d6a495b91f527c4a13936c0e395d02283be4893b7c83914f4806e
data/README.md CHANGED
@@ -39,6 +39,7 @@ The constructor accepts the following named arguments:
39
39
  | `:subdirs_only` | Optional | `Boolean` | An option to have `rsync` only sync files that are in subfolders of `:src_dir`. Defaults to `false`. |
40
40
  | `: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. |
41
41
  | `:logfile` | Optional | `String` | If the `:log_dir` is not specified, you can provide an explicit path for `rsync_wrapper`'s temporary logfile. |
42
+ | `:bwlimit`|Optional|`Integer`|From rsync's man pages: This option allows you to specify a maximum transfer rate in kilobytes per second. This option is most effective when using rsync with large files (several megabytes and up). Due to the nature of rsync transfers, blocks of data are sent, then if rsync determines the transfer was too fast, it will wait before sending the next data block. The result is an average transfer rate equaling the specified limit. A value of zero specifies no limit.|
42
43
 
43
44
  To execute `rsync`, invoke the `sync!` method which accepts a block with 2 parameters:
44
45
 
@@ -50,8 +51,8 @@ To execute `rsync`, invoke the `sync!` method which accepts a block with 2 param
50
51
  Example:
51
52
 
52
53
  ```ruby
53
- source_directory = '/Users/seanhuber/Documents/my_pdfs'
54
- destination_directory = '/Users/seanhuber/Documents/my_pdfs (copied)'
54
+ source_directory = '/path/of/directory/you/want/to/sync'
55
+ destination_directory = '/path/of/directory/to/sync/to'
55
56
 
56
57
  rsync = Rsync.new(src_dir: source_directory, dest_dir: destination_directory)
57
58
 
@@ -18,6 +18,11 @@ class Rsync
18
18
  else
19
19
  File.join(Dir.pwd, "rsync-#{SecureRandom.uuid}.log")
20
20
  end
21
+
22
+ @optional_arguments = [
23
+ :bwlimit,
24
+ # TODO: add rsync's other arguments that wouldn't interfere with the design of this gem https://linux.die.net/man/1/rsync
25
+ ].map{|arg| opts[arg] ? [arg, opts[arg]] : nil}.compact.to_h
21
26
  end
22
27
 
23
28
  def sync! &block
@@ -31,6 +36,9 @@ class Rsync
31
36
  rsync_opts = ['-ri', "--log-file '#{@logfile}'", '--size-only', '--prune-empty-dirs']
32
37
  rsync_opts += @inclusions.map{|inc| "--include '#{inc}'"}
33
38
  rsync_opts += @exclusions.map{|exc| "--exclude '#{exc}'"}
39
+
40
+ rsync_opts += @optional_arguments.map{|k,v| "--#{k}=#{v}"}
41
+
34
42
  cmd = "rsync #{rsync_opts.join(' ')} \"#{@dirs[:src_dir]}\" \"#{@dirs[:dest_dir]}\" > /dev/null 2>&1"
35
43
  `#{cmd}`
36
44
  end
@@ -1,3 +1,3 @@
1
1
  module RsyncWrapper
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsync_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2017-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler