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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa2e617b398ab4bc774b5f411ebfc81fee8116ffb04f0c18d9e5b7b0ac0bd4b2
4
- data.tar.gz: 34879e6fc7b6025cc95b512627d4cdb39da85aff70ee9eaeeaa6276e42befc25
3
+ metadata.gz: 6c1dbb116588b9b45a4d8809135d771b94ce50236a2009394a525a785f4f9f88
4
+ data.tar.gz: 30143aab8a7dd0ffbdd872597b0c07073e9dcf71f603ce5b6c99afade7c95629
5
5
  SHA512:
6
- metadata.gz: 9dc81afecb3c9480da8733b167305da5804cfd9d9572a857bda00142c819a01fe2ce1fcaf2a14ebf2f550622e90ee3259a8868bc5ae459a063dfe44cc86cf6dd
7
- data.tar.gz: a1547b8dc64dae71194c8bd50da819f0205cbd9d0b35173ed634985afe11dbf83644178455b4505fd4a22a4bb438f15d0d300175318108e7ef75cdae4db72a5c
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
@@ -1,3 +1,3 @@
1
1
  module RakeScript
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich