z_build 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/z_build.rb +51 -3
- metadata +2 -2
data/lib/z_build.rb
CHANGED
@@ -31,6 +31,52 @@ require 'tempfile'
|
|
31
31
|
# end
|
32
32
|
module ZBuild
|
33
33
|
|
34
|
+
# Temporarily set the working directory to the specified path,
|
35
|
+
# then on completion of the given block the prior working directory
|
36
|
+
# will be automatically restored.
|
37
|
+
#
|
38
|
+
# @yield to the block given
|
39
|
+
#
|
40
|
+
def working_dir_shift(path, &block)
|
41
|
+
restore_path = self.working_dir
|
42
|
+
|
43
|
+
self.set_working_dir path
|
44
|
+
|
45
|
+
yield
|
46
|
+
|
47
|
+
self.set_working_dir restore_path
|
48
|
+
end
|
49
|
+
|
50
|
+
# Temporarily set the deploy directory to the specified path,
|
51
|
+
# then on completion of the given block the prior deploy directory
|
52
|
+
# will be automatically restored.
|
53
|
+
#
|
54
|
+
# @yield to the block given
|
55
|
+
#
|
56
|
+
def deploy_dir_shift(path, &block)
|
57
|
+
restore_path = self.deploy_dir
|
58
|
+
|
59
|
+
self.set_deploy_dir path
|
60
|
+
|
61
|
+
yield
|
62
|
+
|
63
|
+
self.set_deploy_dir restore_path
|
64
|
+
end
|
65
|
+
|
66
|
+
# Set the default permissions for file systems created using ZBuild.
|
67
|
+
#
|
68
|
+
# @param [Fixnum] perms
|
69
|
+
def set_default_permissions(perms=0750)
|
70
|
+
@default_permissions = perms
|
71
|
+
end
|
72
|
+
|
73
|
+
# Retrieve the default permission settings for file systems created using ZBuild.
|
74
|
+
#
|
75
|
+
# @return [Fixnum] the default set permissions, 0750 by default
|
76
|
+
def default_permissions
|
77
|
+
@default_permissions ||= 0750
|
78
|
+
end
|
79
|
+
|
34
80
|
# Run shell commands
|
35
81
|
#
|
36
82
|
# @example
|
@@ -64,7 +110,7 @@ module ZBuild
|
|
64
110
|
result = `#{shell_command}`
|
65
111
|
|
66
112
|
if opts[:check_return] && !result.empty?
|
67
|
-
raise "run failed for shell command: #{shell_command}"
|
113
|
+
raise "run failed for shell command: #{shell_command} result:#{result}"
|
68
114
|
end
|
69
115
|
|
70
116
|
result
|
@@ -89,7 +135,9 @@ module ZBuild
|
|
89
135
|
# @param [Fixnum] perm the permissions for the directory/directories created
|
90
136
|
# @note this function works like the shell mkdir -p, so that /multiple/paths/deep will create all
|
91
137
|
# directories in the path
|
92
|
-
|
138
|
+
#
|
139
|
+
# @see #default_permissions
|
140
|
+
def deploy_mkdir(path, perm=self.default_permissions)
|
93
141
|
deploy_path = self.deploy_path path
|
94
142
|
|
95
143
|
# only create when does not already exist
|
@@ -706,7 +754,7 @@ module ZBuild
|
|
706
754
|
end
|
707
755
|
|
708
756
|
# variable was found in hash - update keyed value with var replacement
|
709
|
-
hash[key] =
|
757
|
+
hash[key] = hash[key].gsub("${#{var}}", hash[var])
|
710
758
|
end
|
711
759
|
end
|
712
760
|
end
|