mirrorworks 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -4
  3. data/lib/mirrorworks.rb +13 -10
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 222eb5938e2c9cd60556a8a9ed479001102bcbda
4
- data.tar.gz: a6f9bbf43a1ff4d23dceaff53347ea1d01cfb5cc
3
+ metadata.gz: cd0da08208a1d2ea56fec9b382602974852e3ef3
4
+ data.tar.gz: 38e022c740f21507f07eec06a628b1c5ef810d6f
5
5
  SHA512:
6
- metadata.gz: e31c0d4d8e6b628276fd9ebead81596f3717b102c9dc8109990209f841dfb272852690d2a2b58b695524ad7c9c45857011ac48c7aed6d9654d2b4651cad758ae
7
- data.tar.gz: 21c0cb44184b11b7af6c8d2327f683376e68718cd67b3b15adf35854b8e8a7e364df9058b78418d647f39a397adae99367f6bf70c151f149a5f423ed1e19513d
6
+ metadata.gz: ceaab3fd63fea590e302e70099e34d3ee363a7e7ab27e67b63b3416dd1a26cc2cb06e619f6ef04a6d641b6bbcadb2a5fe3f58f12d48e6ed21a24b0cb4ca13755
7
+ data.tar.gz: 31df3fb01deac0c5ff2235f711f6f412dd6a07a3a138e2278913236f8f67ff3190cd1aae4dc7459f5dac94ac26952498f4dd696005fdf8ff096338a1a896c1cc
data/README.md CHANGED
@@ -10,10 +10,11 @@ with commands like
10
10
  and
11
11
  `$ mirrorworks pull`
12
12
 
13
-
14
13
  Installation and Configuration
15
14
  ------------------------------
16
- Make sure you have rsync and ruby installed on your system.
15
+ For Windows users, install [cygwin](http://www.cygwin.com/).
16
+
17
+ Make sure you have rsync and ruby installed.
17
18
 
18
19
  Install the gem with
19
20
  `$ gem install mirrorworks`
@@ -27,12 +28,17 @@ This file contains some underlying rsync runtime options as well as a set of
27
28
  synchronized. Each consists of a name, a local file/dir, and a remote file/dir.
28
29
  There are a few things to remember when setting up your reflections:
29
30
 
30
- * The name of each reflection should be unique.
31
+ * The name of each reflection should be unique and should not include spaces.
31
32
  * Directory paths should end in a slash /.
32
33
  * You can use '$HOME' or '~' to refer to your home directory.
33
- * Currently, paths including a space can't be used.
34
+ * On windows, use cygwin style paths; for example, '/cygdrive/c/...'
34
35
 
35
36
  Using Mirrorworks
36
37
  -----------------
37
38
  The script is very straightforward. For usage, run
38
39
  `$ mirrorworks --help`
40
+
41
+ Development
42
+ -----------
43
+ For bug reports and feature requests, feel free to open an issue or make a
44
+ pull request on [github](https://github.com/tylerbrazier/mirrorworks).
data/lib/mirrorworks.rb CHANGED
@@ -3,13 +3,15 @@ require 'fileutils'
3
3
  require 'rsync'
4
4
  require 'json'
5
5
 
6
+ VERSION = '0.1.0'
6
7
  CONF_AT = File.join(Dir.home, '.mirrorworksrc.json')
7
8
 
8
9
  class Mirrorworks
9
10
 
10
11
  def initialize
11
12
  @help_opts = ''
12
- @conf = nil
13
+ @options = {}
14
+ @conf = {}
13
15
  end
14
16
 
15
17
 
@@ -18,6 +20,7 @@ class Mirrorworks
18
20
  raise "Can't read #{CONF_AT}. Use 'install' command to make example conf."
19
21
  end
20
22
  File.open(CONF_AT, 'r') {|f| @conf = JSON.parse(f.read)}
23
+ @conf['rsync_opts'] << '--delete' if @options[:x]
21
24
  end
22
25
 
23
26
 
@@ -55,9 +58,10 @@ class Mirrorworks
55
58
  def push(args)
56
59
  each_reflection(args) do |ref|
57
60
  puts ">>>> Pushing #{ref['name']} >>>>"
58
- result = Rsync.run(ref['local'], ref['remote'], @conf['rsync_opts'])
61
+ src = ref['local'].sub(' ', '\ ')
62
+ dest = ref['remote'].sub(' ', '\ ')
63
+ result = Rsync.run(src, dest, @conf['rsync_opts'])
59
64
  raise result.error unless result.success?
60
-
61
65
  result.changes.each {|c| puts c.filename}
62
66
  puts
63
67
  end
@@ -66,9 +70,10 @@ class Mirrorworks
66
70
  def pull(args)
67
71
  each_reflection(args) do |ref|
68
72
  puts "<<<< Pulling #{ref['name']} <<<<"
69
- result = Rsync.run(ref['remote'], ref['local'], @conf['rsync_opts'])
73
+ src = ref['remote'].sub(' ', '\ ')
74
+ dest = ref['local'].sub(' ', '\ ')
75
+ result = Rsync.run(src, dest, @conf['rsync_opts'])
70
76
  raise result.error unless result.success?
71
-
72
77
  result.changes.each {|c| puts c.filename}
73
78
  puts
74
79
  end
@@ -95,9 +100,7 @@ class Mirrorworks
95
100
 
96
101
 
97
102
  def version
98
- path = File.join(File.dirname(__FILE__), '..', 'mirrorworks.gemspec')
99
- spec = Gem::Specification::load(path)
100
- puts spec.version
103
+ puts VERSION
101
104
  exit
102
105
  end
103
106
 
@@ -137,7 +140,7 @@ class Mirrorworks
137
140
  opts.on('-V', '--version', 'print version and exit') {version}
138
141
  opts.on('-h', '--help', 'print help and exit') {help}
139
142
  opts.on('-x', '--hard', 'delete extra files on transfer') do |x|
140
- @conf['rsync_opts'] << '--delete' if x
143
+ @options[:x] = x
141
144
  end
142
145
  @help_opts = opts.to_s
143
146
  end.parse! args
@@ -161,7 +164,7 @@ class Mirrorworks
161
164
  raise "No command '#{command}'"
162
165
  end
163
166
  rescue Exception => e
164
- puts e.message
167
+ puts e.message unless e.is_a? SystemExit
165
168
  end
166
169
  end
167
170
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mirrorworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brazier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-12 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rsync