ruby_make_script 0.1.0 → 0.1.5
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/Gemfile +0 -1
- data/lib/ruby_make_script.rb +13 -9
- data/lib/ruby_make_script/utils.rb +79 -18
- data/lib/ruby_make_script/version.rb +1 -1
- data/ruby_make_script.gemspec +2 -2
- data/test.rb +7 -0
- metadata +17 -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
|
data/Gemfile
CHANGED
data/lib/ruby_make_script.rb
CHANGED
@@ -15,6 +15,10 @@
|
|
15
15
|
#
|
16
16
|
#
|
17
17
|
|
18
|
+
if !system('gem list | grep pastel > /dev/null')
|
19
|
+
puts "pastel not install automaticly, please 'gem install pastel'"
|
20
|
+
end
|
21
|
+
|
18
22
|
require 'pastel'
|
19
23
|
require 'yaml'
|
20
24
|
|
@@ -35,7 +39,7 @@ require 'ruby_make_script/target'
|
|
35
39
|
|
36
40
|
# check a file (recursively) and run the commands of the target.
|
37
41
|
def resolve(file, force_exec=false)
|
38
|
-
if file_modified?(file)
|
42
|
+
if force_exec || file_modified?(file)
|
39
43
|
t = $file_target_dict[file]
|
40
44
|
# when t == nil, its a file not used for target
|
41
45
|
if t != nil
|
@@ -108,7 +112,7 @@ class Symbol
|
|
108
112
|
# end
|
109
113
|
# ```
|
110
114
|
def then
|
111
|
-
from()
|
115
|
+
PhonyTarget.new(String(self)).from() { yield }
|
112
116
|
end
|
113
117
|
end
|
114
118
|
|
@@ -158,23 +162,23 @@ def make
|
|
158
162
|
$file_time_dict = YAML.load(File.read('./.make_script.yaml'))
|
159
163
|
$cur_file_time_dict = $file_time_dict.clone()
|
160
164
|
end
|
161
|
-
puts Pastel.new.
|
165
|
+
puts Pastel.new.bright_cyan("make> ") + "start"
|
166
|
+
|
162
167
|
begin
|
163
|
-
if ARGV.length
|
168
|
+
if ARGV.length == 0
|
164
169
|
$targetlist[0].resolve_all
|
165
170
|
else
|
166
|
-
resolve(ARGV[
|
171
|
+
resolve(ARGV[0], true)
|
167
172
|
end
|
168
173
|
|
169
174
|
rescue StandardError => e
|
170
|
-
puts Pastel.new.red.bold("
|
175
|
+
puts Pastel.new.red.bold("make failed> ") + e.message
|
171
176
|
if e.message != "make command failed"
|
172
177
|
puts e.backtrace
|
173
178
|
end
|
174
179
|
else
|
175
|
-
puts Pastel.new.
|
180
|
+
puts Pastel.new.bright_cyan("make> ") + "completed"
|
176
181
|
end
|
177
182
|
|
178
183
|
File.open('./.make_script.yaml', 'w') { |f| f.write(YAML.dump($cur_file_time_dict)) }
|
179
|
-
|
180
|
-
end
|
184
|
+
end
|
@@ -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
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.description = %q{A ruby make DSL for ruby like GNU make. (very simple)}
|
14
14
|
spec.homepage = "https://github.com/DnailZ/ruby_make_script"
|
15
15
|
spec.license = "MIT"
|
16
|
-
|
16
|
+
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
@@ -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"]
|
@@ -40,4 +39,5 @@ Gem::Specification.new do |spec|
|
|
40
39
|
spec.add_development_dependency "bundler", "~> 1.17"
|
41
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
42
41
|
spec.add_development_dependency "minitest", "~> 5.0"
|
42
|
+
spec.add_development_dependency "pastel" , "~> 0.7.4"
|
43
43
|
end
|
data/test.rb
ADDED
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
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pastel
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.4
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.7.4
|
55
69
|
description: A ruby make DSL for ruby like GNU make. (very simple)
|
56
70
|
email:
|
57
71
|
- dnailzb@outlook.com
|
@@ -73,6 +87,7 @@ files:
|
|
73
87
|
- lib/ruby_make_script/utils.rb
|
74
88
|
- lib/ruby_make_script/version.rb
|
75
89
|
- ruby_make_script.gemspec
|
90
|
+
- test.rb
|
76
91
|
homepage: https://github.com/DnailZ/ruby_make_script
|
77
92
|
licenses:
|
78
93
|
- MIT
|