bak 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/bin/bak +14 -0
- data/lib/bak/backup_name_generator.rb +5 -0
- data/lib/bak/copier.rb +6 -0
- data/lib/bak/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b6c64c6d82f2fef02482b8177135f00c76cc57a
|
4
|
+
data.tar.gz: 20d1b920ce53ea9b114ed6e5dfeaf934ebf82efd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e30262bbce3c45844eab13a7df5c1db2f4ead61b7f7cc2dc76385832d306b89722f83c0d9728d7f254e45e08d2ce34c08d1d9ca247a4c4aa2c7d228a74250c9f
|
7
|
+
data.tar.gz: e14294bdaa108ebdcbd54c13803d6ff4e29a46c63deef3dc4c91234a16aed49bc5fbdf643ddcf4fd81f96e3042b15cc87457c59177de95e70f5744356af1751b
|
data/bin/bak
CHANGED
@@ -27,6 +27,14 @@ option_parser = OptionParser.new do |opts|
|
|
27
27
|
options[:prefix] = prefix
|
28
28
|
end
|
29
29
|
|
30
|
+
opts.on("-t TARGETPATH") do |path|
|
31
|
+
options[:target_path] = path
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("-c", "--create") do
|
35
|
+
options[:create_path] = true
|
36
|
+
end
|
37
|
+
|
30
38
|
opts.on("-R TEXT") do |text|
|
31
39
|
options[:replace] ||= {}
|
32
40
|
patternCount += 1
|
@@ -40,6 +48,12 @@ option_parser.parse!
|
|
40
48
|
options[:force] ||= false
|
41
49
|
options[:no_bak] ||= false
|
42
50
|
|
51
|
+
# make sure the create option is always paired with the target_path option
|
52
|
+
if options[:create_path] && !options[:target_path]
|
53
|
+
STDERR.puts("please specify target directory to create with the -t option")
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
|
43
57
|
if ARGV.length > 0
|
44
58
|
filenames = ARGV
|
45
59
|
else
|
@@ -22,6 +22,7 @@ module Bak
|
|
22
22
|
if @options[:postfix] then filename = _with_postfix(filename, @options[:postfix]) end
|
23
23
|
if @options[:prefix] then filename = _with_prefix(filename, @options[:prefix]) end
|
24
24
|
if @options[:replace] then filename = _with_replace(filename, @options[:replace]) end
|
25
|
+
if @options[:target_path] then filename = _with_target_path(filename, @options[:target_path]) end
|
25
26
|
end
|
26
27
|
unless @options[:no_bak] then filename = "#{filename}.bak" end
|
27
28
|
|
@@ -47,6 +48,10 @@ module Bak
|
|
47
48
|
return filename.gsub(pattern, replace)
|
48
49
|
end
|
49
50
|
|
51
|
+
def _with_target_path(filename, target_path)
|
52
|
+
return "#{target_path}/#{filename}"
|
53
|
+
end
|
54
|
+
|
50
55
|
def _get_date
|
51
56
|
return Time.new.strftime("%Y-%m-%d")
|
52
57
|
end
|
data/lib/bak/copier.rb
CHANGED
@@ -15,6 +15,12 @@ module Bak
|
|
15
15
|
if File.exists?(@end_file) && !@generator[:force]
|
16
16
|
return "#{end_file}: File already exists"
|
17
17
|
end
|
18
|
+
if @generator[:create_path] == true
|
19
|
+
FileUtils::mkdir_p @generator[:target_path]
|
20
|
+
end
|
21
|
+
if @generator[:target_path] && !File.directory?(@generator[:target_path])
|
22
|
+
return "#{@generator[:target_path]} directory does not exist"
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
def start
|
data/lib/bak/version.rb
CHANGED