rake_script 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rake_script/file_system.rb +44 -0
- data/lib/rake_script/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c1dbb116588b9b45a4d8809135d771b94ce50236a2009394a525a785f4f9f88
|
4
|
+
data.tar.gz: 30143aab8a7dd0ffbdd872597b0c07073e9dcf71f603ce5b6c99afade7c95629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47c17babcf9499576d4ebfd146b85fda5d8dcaf79fafdf4ca31ddb8dc704d4de51198e199de798c4db0881c91f8e9fc8c78ff6fc70ee2d4ae082eedf302438a7
|
7
|
+
data.tar.gz: 9eb4d5f2b9b7f617c60222f0e865dc52be5e7de7c3b184fdba68b2a2a025af0020ea1244a27e47e6f809f9413d870f0d52ff0e7f8a28150bacac69c52e6eb5da
|
@@ -8,5 +8,49 @@ module RakeScript
|
|
8
8
|
def folder_exist?(path)
|
9
9
|
File.directory?(path)
|
10
10
|
end
|
11
|
+
|
12
|
+
def posix_flags(*flags)
|
13
|
+
result = []
|
14
|
+
flags.each do |flag|
|
15
|
+
if flag.is_a?(Hash)
|
16
|
+
result.concat(
|
17
|
+
flag.reject { |_, v| !v }.map { |k, v| v.is_a?(TrueClass) ? k.to_s : "#{k}=#{v}" }
|
18
|
+
)
|
19
|
+
else
|
20
|
+
result.push(flag.to_s)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_rf(*paths)
|
26
|
+
options = paths.last.is_a?(Hash) ? paths.pop : {}
|
27
|
+
flags = posix_flags('-rf', '-v': !!options[:verbose])
|
28
|
+
cmd('rm', *flags, *paths)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_dir_p(*paths)
|
32
|
+
options = paths.last.is_a?(Hash) ? paths.pop : {}
|
33
|
+
# FileUtils.mkdir_p(paths, options)
|
34
|
+
flags = posix_flags('-p', '-v': !!options[:verbose])
|
35
|
+
cmd('mkdir', *flags, *paths)
|
36
|
+
end
|
37
|
+
|
38
|
+
def copy(from, to, options = {})
|
39
|
+
# from = from.include?('*') ? Dir.glob(from) : [from]
|
40
|
+
# from.each { |f| FileUtils.cp(f, to, options) }
|
41
|
+
flags = posix_flags('-v': !!options[:verbose])
|
42
|
+
cmd('cp', *flags, from, to)
|
43
|
+
end
|
44
|
+
|
45
|
+
def copy_r(from, to, options = {})
|
46
|
+
# from = from.include?('*') ? Dir.glob(from) : [from]
|
47
|
+
# from.each { |f| FileUtils.cp_r(f, to, options) }
|
48
|
+
flags = posix_flags('-r', '-v': !!options[:verbose])
|
49
|
+
cmd('cp', *flags, from, to)
|
50
|
+
end
|
51
|
+
|
52
|
+
def chdir(path)
|
53
|
+
Dir.chdir(path) { yield }
|
54
|
+
end
|
11
55
|
end
|
12
56
|
end
|
data/lib/rake_script/version.rb
CHANGED