ruby_clone 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +215 -186
  2. data/lib/ruby_clone/version.rb +1 -1
  3. metadata +7 -7
data/README.md CHANGED
@@ -6,18 +6,18 @@
6
6
 
7
7
  Install the gem:
8
8
 
9
- gem install ruby_clone
9
+ `gem install ruby_clone`
10
10
 
11
11
  Create a file that is named '.ruby_clone' in your home folder and set up a profile.
12
12
  **NOTE**: Don't forget to use the dot in the file.
13
13
 
14
14
  And then execute:
15
15
 
16
- $ ruby_clone my_profile
16
+ `$ ruby_clone my_profile`
17
17
 
18
18
  You can also specify another path of your **RubyClone** file:
19
19
 
20
- $ ruby_clone -b /my/ruby_clone_file my_profile
20
+ `$ ruby_clone -b /my/ruby_clone_file my_profile`
21
21
 
22
22
  ## Usage
23
23
 
@@ -31,19 +31,20 @@ To start using it, you'll need to create the following configuration in your **R
31
31
  **NOTE 2**: If your source folder/destination_folder has spaces as "My Source Folder", you need to set up it as
32
32
  "My\\ Source\\ Folder" with **two back slashes** for **each space**. Spaces and only one back slash will not work.
33
33
 
34
-
35
- profile :my_profile do
36
- from "/my/source_folder/"
37
- to "/my/destination_folder"
38
- end
34
+ ```ruby
35
+ profile :my_profile do
36
+ from "/my/source_folder/"
37
+ to "/my/destination_folder"
38
+ end
39
+ ```
39
40
 
40
41
  If you set up this configuration in your $HOME/.ruby_clone, you can run with:
41
42
 
42
- $ ruby_clone my_profile
43
+ `$ ruby_clone my_profile`
43
44
 
44
45
  If is in another path, run with:
45
46
 
46
- $ ruby_clone -b /my/backup_file my_profile
47
+ `$ ruby_clone -b /my/backup_file my_profile`
47
48
 
48
49
  **NOTE**: This basic setup doesn't sync deleted files from the source folder. If you want to delete them, you need
49
50
  to setup the option 'delete: true'.
@@ -53,17 +54,21 @@ to setup the option 'delete: true'.
53
54
  **RubyClone** offers the option to use SSH in a easy way. You just need to use the option ':ssh' with the 'user@host'.
54
55
  Example for SSH that is on source folder.
55
56
 
56
- profile :my_profile do
57
- from "/my/source_folder/", ssh: "user@source_server"
58
- to "/my/destination_folder"
59
- end
57
+ ```ruby
58
+ profile :my_profile do
59
+ from "/my/source_folder/", ssh: "user@source_server"
60
+ to "/my/destination_folder"
61
+ end
62
+ ```
60
63
 
61
64
  Example for SSH that is on destination folder:
62
65
 
63
- profile :my_profile do
64
- from "/my/source_folder/"
65
- to "/my/destination_folder", ssh: "user@destination_server"
66
- end
66
+ ```ruby
67
+ profile :my_profile do
68
+ from "/my/source_folder/"
69
+ to "/my/destination_folder", ssh: "user@destination_server"
70
+ end
71
+ ```
67
72
 
68
73
  After running one of theses profiles, you just need to type the password.
69
74
 
@@ -76,225 +81,252 @@ Here is all the configuration you can set up and improve your **RubyClone** file
76
81
 
77
82
  ### Excluding a Pattern - exclude_pattern "pattern"
78
83
 
79
- If you need to exclude folders or files matching a pattern, use the 'exclude_pattern command.
80
- This command can be used in two ways: On the top of **RubyClone** file and/or inside the 'from'.
81
- Here a complete example:
84
+ If you need to exclude folders or files matching a pattern, use the 'exclude_pattern command.
85
+ This command can be used in two ways: On the top of **RubyClone** file and/or inside the 'from'.
86
+ Here a complete example:
82
87
 
83
- exclude_pattern "top_pattern"
88
+ ```ruby
89
+ exclude_pattern "top_pattern"
84
90
 
85
- profile :my_profile1 do
86
- from "/my/source_folder/"
87
- to "/my/destination_folder"
88
- end
91
+ profile :my_profile1 do
92
+ from "/my/source_folder/"
93
+ to "/my/destination_folder"
94
+ end
89
95
 
90
- profile :my_profile2 do
91
- from "/my/source_folder/" do
92
- exclude_pattern "from_pattern"
93
- end
94
- to "/my/destination_folder"
95
- end
96
+ profile :my_profile2 do
97
+ from "/my/source_folder/" do
98
+ exclude_pattern "from_pattern"
99
+ end
100
+ to "/my/destination_folder"
101
+ end
102
+ ```
96
103
 
97
- 1. 'my_profile1' will exclude only the "top_pattern".
98
- 2. 'my_profile2' will exclude the "top_pattern" and "from_pattern"
104
+ 1. 'my_profile1' will exclude only the "top_pattern".
105
+ 2. 'my_profile2' will exclude the "top_pattern" and "from_pattern"
99
106
 
100
107
  ### Including a Pattern - include_pattern "pattern"
101
108
 
102
- Same as the exclude_pattern. If you need to include folders or files matching a pattern, use the
103
- include_pattern command. This command can be use in two ways: On the top of **RubyClone** file and/or
104
- inside the 'from' block. Example:
105
-
106
- include_pattern "top_pattern"
107
-
108
- profile :my_profile1 do
109
- from "/my/source_folder/"
110
- to "/my/destination_folder"
111
- end
112
-
113
- profile :my_profile2 do
114
- from "/my/source_folder/" do
115
- include_pattern "from_pattern"
116
- end
117
- to "/my/destination_folder"
118
- end
119
-
120
- 1. 'my_profile1' will include only the "top_pattern".
121
- 2. 'my_profile2' will include the "top_pattern" and "from_pattern"
122
-
123
- Here an example using exclude_pattern and include_pattern together. In this example, :my_profile will exclude
124
- all folders and will sync/include only the 'from_pattern'
125
-
126
- profile :my_profile do
127
- from "/my/source_folder/" do
128
- exclude_pattern "*"
129
- include_pattern "from_pattern"
130
- end
131
- to "/my/destination_folder"
132
- end
109
+ Same as the exclude_pattern. If you need to include folders or files matching a pattern, use the
110
+ include_pattern command. This command can be use in two ways: On the top of **RubyClone** file and/or
111
+ inside the 'from' block. Example:
112
+
113
+ ```ruby
114
+ include_pattern "top_pattern"
115
+
116
+ profile :my_profile1 do
117
+ from "/my/source_folder/"
118
+ to "/my/destination_folder"
119
+ end
120
+
121
+ profile :my_profile2 do
122
+ from "/my/source_folder/" do
123
+ include_pattern "from_pattern"
124
+ end
125
+ to "/my/destination_folder"
126
+ end
127
+ ```
128
+
129
+ 1. 'my_profile1' will include only the "top_pattern".
130
+ 2. 'my_profile2' will include the "top_pattern" and "from_pattern"
131
+
132
+ Here an example using exclude_pattern and include_pattern together. In this example, :my_profile will exclude
133
+ all folders and will sync/include only the 'from_pattern'
134
+
135
+ ```ruby
136
+ profile :my_profile do
137
+ from "/my/source_folder/" do
138
+ exclude_pattern "*"
139
+ include_pattern "from_pattern"
140
+ end
141
+ to "/my/destination_folder"
142
+ end
143
+ ```
133
144
 
134
145
  ### Deleting files
135
146
 
136
- 1. Deleting files that don't exist in source_folder but in destination folder - delete: true
147
+ * Deleting files that don't exist in source_folder but in destination folder - delete: true
137
148
 
138
- The basic configuration was created to be a secure configuration. So if you really want to delete files/folders
139
- in your destination folder that doesn't exist anymore in your source folder, you'll need to set up 'delete: true' in
140
- your **RubyClone** file. Below an example how to do it:
149
+ The basic configuration was created to be a secure configuration. So if you really want to delete files/folders
150
+ in your destination folder that doesn't exist anymore in your source folder, you'll need to set up 'delete: true' in
151
+ your **RubyClone** file. Below an example how to do it:
141
152
 
142
- profile :my_profile do
143
- from "/my/source_folder/"
144
- to "/my/destination_folder", delete: true
145
- end
153
+ ```ruby
154
+ profile :my_profile do
155
+ from "/my/source_folder/"
156
+ to "/my/destination_folder", delete: true
157
+ end
158
+ ```
146
159
 
147
- Now all files that exists in "/my/destination_folder/" but "/my/source_folder" will be deleted. If for some
148
- reason you want to keep some files and delete others, just set up the exclude_pattern inside 'from' block.
160
+ Now all files that exists in "/my/destination_folder/" but "/my/source_folder" will be deleted. If for some
161
+ reason you want to keep some files and delete others, just set up the exclude_pattern inside 'from' block.
149
162
 
150
- 2. Deleting files that are excluded from source folder to destination folder - delete_excluded: true
163
+ * Deleting files that are excluded from source folder to destination folder - delete_excluded: true
151
164
 
152
- If you decided to exclude files from the syncronization but they still in your destination folder, you can use
153
- the 'delete_excluded' to delete this files inside destination folder that are excluded from the source_folder.
154
- Example:
165
+ If you decided to exclude files from the syncronization but they still in your destination folder, you can use
166
+ the 'delete_excluded' to delete this files inside destination folder that are excluded from the source_folder.
167
+ Example:
155
168
 
156
- profile :my_profile do
157
- from "/my/source_folder/" do
158
- exclude_pattern "my_pattern"
159
- end
160
- to "/my/destination_folder", delete_excluded: true
161
- end
169
+ ```ruby
170
+ profile :my_profile do
171
+ from "/my/source_folder/" do
172
+ exclude_pattern "my_pattern"
173
+ end
174
+ to "/my/destination_folder", delete_excluded: true
175
+ end
176
+ ```
162
177
 
163
- Now all files that are inside destination_folder that have the pattern 'my_pattern' will be deleted.
178
+ Now all files that are inside destination_folder that have the pattern 'my_pattern' will be deleted.
164
179
 
165
- **NOTE**: When you use 'delete_excluded :true' you don't need to set up 'delete: true' even the from
166
- configuration doesn't have the 'exclude_pattern'
180
+ **NOTE**: When you use 'delete_excluded :true' you don't need to set up 'delete: true' even the from
181
+ configuration doesn't have the 'exclude_pattern'
167
182
 
168
183
  ### Backuping files - backup "folder"
169
184
 
170
- 1. If you want to save all the files that get **updated** and **deleted**, you need to set up the 'backup'
171
- configuration inside the 'to' block. Example:
185
+ * If you want to save all the files that get **updated** and **deleted**, you need to set up the 'backup'
186
+ configuration inside the 'to' block. Example:
172
187
 
173
- profile :my_profile do
174
- from "/my/source_folder/"
175
- to "/my/destination_folder", delete: true do
176
- backup "/my/backup_folder"
177
- end
178
- end
188
+ ```ruby
189
+ profile :my_profile do
190
+ from "/my/source_folder/"
191
+ to "/my/destination_folder", delete: true do
192
+ backup "/my/backup_folder"
193
+ end
194
+ end
195
+ ```
179
196
 
180
- Now all the folders/files that get **updated** or **deleted** in the "/my/destination_folder" will be moved to
181
- "/my/backup_folder". The files moved to "/my/destination_folder" will have a default suffix that is a **RubyClone**
182
- control key plus the Date with the format: "yyyyMMdd".
183
197
 
184
- All files that are saved in the "/my/backup_folder" will have a limit of 5 files. So if any file that passed this
185
- limit, the old file will be deleted. You can change this limit using the option "limit".
198
+ Now all the folders/files that get **updated** or **deleted** in the "/my/destination_folder" will be moved to
199
+ "/my/backup_folder". The files moved to "/my/destination_folder" will have a default suffix that is a **RubyClone**
200
+ control key plus the Date with the format: "yyyyMMdd".
186
201
 
187
- **NOTE**: The **RubyClone** control key is a special key to use as a control to remove old duplicated files.
202
+ All files that are saved in the "/my/backup_folder" will have a limit of 5 files. So if any file that passed this
203
+ limit, the old file will be deleted. You can change this limit using the option "limit".
188
204
 
189
- 2. Changing the suffix of the files inside the backup folder - backup "folder", suffix: "my_suffix"
205
+ **NOTE**: The **RubyClone** control key is a special key to use as a control to remove old duplicated files.
190
206
 
191
- If you want to change the Date suffix for the files that you backup, you need to set the 'suffix' as a parameter to 'backup'.
192
- Example:
207
+ * Changing the suffix of the files inside the backup folder - backup "folder", suffix: "my_suffix"
193
208
 
194
- profile :my_profile do
195
- from "/my/source_folder/"
196
- to "/my/destination_folder", delete: true do
197
- backup "/my/backup_folder", suffix: "my_suffix"
198
- end
199
- end
209
+ If you want to change the Date suffix for the files that you backup, you need to set the 'suffix' as a parameter to 'backup'.
210
+ Example:
211
+
212
+ ```ruby
213
+ profile :my_profile do
214
+ from "/my/source_folder/"
215
+ to "/my/destination_folder", delete: true do
216
+ backup "/my/backup_folder", suffix: "my_suffix"
217
+ end
218
+ end
219
+ ```
200
220
 
201
- Another example using suffix with the Time class of Ruby to generate the date with timestamp "yyyyMMdd_hhmmss" :
221
+ Another example using suffix with the Time class of Ruby to generate the date with timestamp "yyyyMMdd_hhmmss" :
202
222
 
203
- profile :my_profile do
204
- from "/my/source_folder/"
205
- to "/my/destination_folder", delete: true do
206
- backup "/my/backup_folder", suffix: "_#{Time.now.strftime("%Y%m%d_%H%M%S")}"
207
- end
208
- end
223
+ ```ruby
224
+ profile :my_profile do
225
+ from "/my/source_folder/"
226
+ to "/my/destination_folder", delete: true do
227
+ backup "/my/backup_folder", suffix: "_#{Time.now.strftime("%Y%m%d_%H%M%S")}"
228
+ end
229
+ end
230
+ ```
209
231
 
210
- **NOTE**: Changing the suffix will not change the **RubyClone** control key. Since this key control how to remove the
211
- old duplicated files.
232
+ **NOTE**: Changing the suffix will not change the **RubyClone** control key. Since this key control how to remove the
233
+ old duplicated files.
212
234
 
213
- 3. Disabling the default suffix - backup "folder", disable_suffix: true
235
+ * Disabling the default suffix - backup "folder", disable_suffix: true
214
236
 
215
- If for some reason you want to disable the file suffix in the backup folder you can set true for 'default_true'. Doing
237
+ If for some reason you want to disable the file suffix in the backup folder you can set true for 'default_true'. Doing
216
238
  that all the files that are moved to "/my/backup_folder" will have the same name and it will get override by a new file.
217
239
  Example:
218
240
 
219
- profile :my_profile do
220
- from "/my/source_folder/"
221
- to "/my/destination_folder", delete: true do
222
- backup "/my/backup_folder", disable_suffix: true
223
- end
224
- end
241
+ ```ruby
242
+ profile :my_profile do
243
+ from "/my/source_folder/"
244
+ to "/my/destination_folder", delete: true do
245
+ backup "/my/backup_folder", disable_suffix: true
246
+ end
247
+ end
248
+ ```
225
249
 
226
- **NOTE**: This kind of setup will **backup only one file** and nothing more.
250
+ **NOTE**: This kind of setup will **backup only one file** and nothing more.
227
251
 
228
- 4. Changing how many files you want to backup - backup "folder", limit: 10
252
+ * Changing how many files you want to backup - backup "folder", limit: 10
229
253
 
230
- **RubyClone** have a default to save 5 files "/my/backup_folder" that have the same name. If you want to change the
231
- limit you just need to set up the option limit with the number of files to save.
232
- Example:
254
+ **RubyClone** have a default to save 5 files "/my/backup_folder" that have the same name. If you want to change the
255
+ limit you just need to set up the option limit with the number of files to save.
256
+ Example:
233
257
 
234
- profile :my_profile do
235
- from "/my/source_folder/"
236
- to "/my/destination_folder", delete: true do
237
- backup "/my/backup_folder", limit: 20
238
- end
239
- end
258
+ ```ruby
259
+ profile :my_profile do
260
+ from "/my/source_folder/"
261
+ to "/my/destination_folder", delete: true do
262
+ backup "/my/backup_folder", limit: 20
263
+ end
264
+ end
265
+ ```
240
266
 
241
- Now "/my/backup_folder" will save 20 files with the same name.
267
+ Now "/my/backup_folder" will save 20 files with the same name.
242
268
 
243
- 5. Disabling the limit of files to save. Save unlimited files - backup "folder", limit: :unlimited
269
+ * Disabling the limit of files to save. Save unlimited files - backup "folder", limit: :unlimited
244
270
 
245
- If for some reason you want to backup all files that are **updated** or **deleted** you need to set up the 'limit'
246
- option with ':unlimited'
247
- Example:
271
+ If for some reason you want to backup all files that are **updated** or **deleted** you need to set up the 'limit'
272
+ option with ':unlimited'
273
+ Example:
248
274
 
249
- profile :my_profile do
250
- from "/my/source_folder/"
251
- to "/my/destination_folder", delete: true do
252
- backup "/my/backup_folder", limit: :unlimited
253
- end
254
- end
275
+ ```ruby
276
+ profile :my_profile do
277
+ from "/my/source_folder/"
278
+ to "/my/destination_folder", delete: true do
279
+ backup "/my/backup_folder", limit: :unlimited
280
+ end
281
+ end
282
+ ```
255
283
 
256
- Now all files will be saved, until you change the 'limit' to a specific number to erased all the old files that passed
257
- the new limit.
284
+ Now all files will be saved, until you change the 'limit' to a specific number to erased all the old files that passed
285
+ the new limit.
258
286
 
259
287
  ### Disabling the output commands of RSync - config options
260
288
 
261
- 1. **RubyClone** offers the possibility to not show the rsync command generated (show_command) and rsync output
262
- (show_output). To use it, you need to set up in the top of your **RubyClone** file the 'config' and the commands you
263
- want to disable. Example:
289
+ * **RubyClone** offers the possibility to not show the rsync command generated (show_command) and rsync output
290
+ (show_output). To use it, you need to set up in the top of your **RubyClone** file the 'config' and the commands you
291
+ want to disable. Example:
264
292
 
265
- config show_command: false, show_output: false
293
+ ```ruby
294
+ config show_command: false, show_output: false
266
295
 
267
- profile :my_profile do
268
- from "/my/source_folder/"
269
- to "/my/destination_folder"
270
- end
296
+ profile :my_profile do
297
+ from "/my/source_folder/"
298
+ to "/my/destination_folder"
299
+ end
300
+ ```
271
301
 
272
- The above config will not show anymore the rsync command and rsync outputs. But errors will keep showing if
273
- happen.
302
+ The above config will not show anymore the rsync command and rsync outputs. But errors will keep showing if
303
+ happen.
274
304
 
275
- 2. Overriding the default configuration of Rsync command - config options: 'override_options'
305
+ * Overriding the default configuration of Rsync command - config options: 'override_options'
276
306
 
277
- If you need to override the default configurations for RSync you can set up the "config options: 'my_options'".
278
- Example:
307
+ If you need to override the default configurations for RSync you can set up the "config options: 'my_options'".
308
+ Example:
279
309
 
280
- config options: '-Cav --stats'
310
+ ```ruby
311
+ config options: '-Cav --stats'
281
312
 
282
- profile :my_profile do
283
- from "/my/source_folder/"
284
- to "/my/destination_folder"
285
- end
313
+ profile :my_profile do
314
+ from "/my/source_folder/"
315
+ to "/my/destination_folder"
316
+ end
317
+ ```
286
318
 
287
319
  ## Running
288
320
 
289
321
  **RubyClone** as default will try to read the **RubyClone** file in your home folder: $HOME/.ruby_clone. If you
290
322
  need to specify another path of your **RubyClone** file don't forget to add the option -b
291
323
 
292
- $ ruby_clone -b /my/ruby_clone_file profile
324
+ `$ ruby_clone -b /my/ruby_clone_file profile`
293
325
 
294
326
  RSync offers the options to dry-run the command and just run the sincronization as a simulation. You can do this
295
327
  too with **RubyClone**. Just pass the option '-d' to ruby_clone
296
328
 
297
- $ ruby_clone -d profile
329
+ `$ ruby_clone -d profile`
298
330
 
299
331
  ## More interesting **RubyClone** file
300
332
 
@@ -306,19 +338,16 @@ it will copy the 'source_folder' inside the 'destination_folder. (This behaviour
306
338
  **NOTE 2**: If your source folder/destination_folder has spaces as "/My Source Folder", you need to set up it as
307
339
  "My\\ Source\\ Folder" with **two back slashes** for **each space**. Spaces and only one back slash will not work.
308
340
 
309
- profile :my_profile do
310
- from "/my/source_folder/" do
311
- exclude_pattern "pattern"
312
- end
313
- to "/my/destination_folder", delete_excluded: true do
314
- backup "/my/backup"
315
- end
316
- end
317
-
318
- ## **WARNINGS**
319
-
320
- Even this script were has been tested many times, you run this script entirely at your own risk.
321
- **RubyClone** accepts no responsibility for any damage this script may cause.
341
+ ```ruby
342
+ profile :my_profile do
343
+ from "/my/source_folder/" do
344
+ exclude_pattern "pattern"
345
+ end
346
+ to "/my/destination_folder", delete_excluded: true do
347
+ backup "/my/backup"
348
+ end
349
+ end
350
+ ```
322
351
 
323
352
  ## Contributing to **RubyClone**
324
353
 
@@ -326,4 +355,4 @@ it will copy the 'source_folder' inside the 'destination_folder. (This behaviour
326
355
 
327
356
  ## Copyright
328
357
 
329
- Copyright (c) 2012 Frederico Benevides. See MIT-LICENSE for further details.
358
+ Copyright (c) 2012 Frederico Benevides. See MIT-LICENSE for further details.
@@ -1,3 +1,3 @@
1
1
  module RubyClone
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_clone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70295966492060 !ruby/object:Gem::Requirement
16
+ requirement: &70236612351040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70295966492060
24
+ version_requirements: *70236612351040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-rspec
27
- requirement: &70295966491280 !ruby/object:Gem::Requirement
27
+ requirement: &70236612350320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.2.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70295966491280
35
+ version_requirements: *70236612350320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70295966490740 !ruby/object:Gem::Requirement
38
+ requirement: &70236612349580 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.11.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70295966490740
46
+ version_requirements: *70236612349580
47
47
  description: Ruby clone is a command line tool to work with Rsync using DSL!
48
48
  email:
49
49
  - fredbene@gmail.com