ruby_make_script 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_make_script/utils.rb +79 -18
- data/lib/ruby_make_script/version.rb +1 -1
- data/ruby_make_script.gemspec +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a370bfa77890704eba2e733162beac06b58ab808c12560aa80f82954ead81b9a
|
4
|
+
data.tar.gz: 2367de1ec588fa4927475288cdc9959e8aa13afb487e608d08911cd1f7d8c15f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b85472ea65c10e3642fdb99aa1b578b686e95fa3f6d85271e3a7f197efae992091f18b4b154a596fee23b8c01c737e28829dcd7c6d1329669759f695ea5cdbac
|
7
|
+
data.tar.gz: 3f6b650ac72704263761b7cded263e00378e893d0fc5838bf346646c461a80ca1bb0845ed5b5d3372e6516642aea77f079f89fa9a7789ea4428817dc741b895a
|
@@ -1,15 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
# since ~ "cd <path>" invalid, add a function here
|
4
2
|
def cd(str)
|
5
|
-
|
6
|
-
orig = Dir.pwd
|
7
|
-
Dir.chdir(str)
|
8
|
-
yield
|
9
|
-
Dir.chdir(orig)
|
10
|
-
else
|
11
|
-
Dir.chdir(str)
|
12
|
-
end
|
3
|
+
Dir.chdir(str)
|
13
4
|
end
|
14
5
|
|
15
6
|
# these were like cd function
|
@@ -21,6 +12,15 @@ end
|
|
21
12
|
def mkdir(*str)
|
22
13
|
r"mkdir #{str.join(' ')}"
|
23
14
|
end
|
15
|
+
# these were like cd function
|
16
|
+
def mv(*str)
|
17
|
+
r"mv #{str.join(' ')}"
|
18
|
+
end
|
19
|
+
|
20
|
+
# these were like cd function
|
21
|
+
def cp(*str)
|
22
|
+
r"cp #{str.join(' ')}"
|
23
|
+
end
|
24
24
|
|
25
25
|
def r(*str)
|
26
26
|
str = str.join(" ")
|
@@ -34,14 +34,7 @@ end
|
|
34
34
|
# since ~ "cd <path>" invalid, add a function here
|
35
35
|
def cd?(str)
|
36
36
|
begin
|
37
|
-
|
38
|
-
orig = Dir.pwd
|
39
|
-
Dir.chdir(str)
|
40
|
-
yield
|
41
|
-
Dir.chdir(orig)
|
42
|
-
else
|
43
|
-
Dir.chdir(str)
|
44
|
-
end
|
37
|
+
Dir.chdir(str)
|
45
38
|
rescue => exception
|
46
39
|
puts Pastel.new.yellow("warning> ") + "command error: cd " + str + " (suppressed)"
|
47
40
|
return false
|
@@ -59,6 +52,16 @@ def mkdir?(*str)
|
|
59
52
|
r?"mkdir #{str.join(' ')}"
|
60
53
|
end
|
61
54
|
|
55
|
+
# these were like cd function
|
56
|
+
def mv?(*str)
|
57
|
+
r?"mv #{str.join(' ')}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# these were like cd function
|
61
|
+
def cp?(*str)
|
62
|
+
r?"cp #{str.join(' ')}"
|
63
|
+
end
|
64
|
+
|
62
65
|
# no error
|
63
66
|
def r?(*str)
|
64
67
|
str = str.join(" ")
|
@@ -74,7 +77,65 @@ def runfile(file, *args)
|
|
74
77
|
path = File.expand_path(file)
|
75
78
|
r path, *args
|
76
79
|
end
|
80
|
+
|
77
81
|
def runfile?(file, *args)
|
78
82
|
path = File.expand_path(file)
|
79
83
|
r? path, *args
|
80
84
|
end
|
85
|
+
|
86
|
+
class InDir
|
87
|
+
def initialize(path, err=true)
|
88
|
+
@path = path
|
89
|
+
@err = err
|
90
|
+
end
|
91
|
+
|
92
|
+
def enter
|
93
|
+
@orig = Dir.pwd
|
94
|
+
if @err
|
95
|
+
cd @path
|
96
|
+
else
|
97
|
+
cd? @path
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def exit
|
102
|
+
if @err
|
103
|
+
cd @orig
|
104
|
+
else
|
105
|
+
cd? @orig
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def dir(path)
|
111
|
+
InDir.new(path)
|
112
|
+
end
|
113
|
+
|
114
|
+
def dir?(path)
|
115
|
+
InDir.new(path, false)
|
116
|
+
end
|
117
|
+
|
118
|
+
class InEnv
|
119
|
+
def initialize(expr)
|
120
|
+
@k, @v = expr.split('=')
|
121
|
+
end
|
122
|
+
|
123
|
+
def enter
|
124
|
+
@v0 = ENV[k]
|
125
|
+
ENV[k] = @v
|
126
|
+
end
|
127
|
+
|
128
|
+
def exit
|
129
|
+
ENV[k] = @v0
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def envir(expr)
|
134
|
+
InEnv.new(expr)
|
135
|
+
end
|
136
|
+
|
137
|
+
def using(*operation)
|
138
|
+
operation.each{ |o| o.enter}
|
139
|
+
yield
|
140
|
+
operation.each{ |o| o.exit}
|
141
|
+
end
|
data/ruby_make_script.gemspec
CHANGED
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
33
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
34
|
end
|
35
|
-
p spec.files
|
36
35
|
spec.bindir = "exe"
|
37
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
37
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_make_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dnailz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|