ruby_make_script 0.1.5 → 0.1.6

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: a370bfa77890704eba2e733162beac06b58ab808c12560aa80f82954ead81b9a
4
- data.tar.gz: 2367de1ec588fa4927475288cdc9959e8aa13afb487e608d08911cd1f7d8c15f
3
+ metadata.gz: 39795ddc3d0820433555bb57ffd41639be77a702ee4e3ff72cac6dd243fa9bb8
4
+ data.tar.gz: 629a6e4804bd3112e66660e3b921965d16456d94478da616453824de2ccd53ee
5
5
  SHA512:
6
- metadata.gz: b85472ea65c10e3642fdb99aa1b578b686e95fa3f6d85271e3a7f197efae992091f18b4b154a596fee23b8c01c737e28829dcd7c6d1329669759f695ea5cdbac
7
- data.tar.gz: 3f6b650ac72704263761b7cded263e00378e893d0fc5838bf346646c461a80ca1bb0845ed5b5d3372e6516642aea77f079f89fa9a7789ea4428817dc741b895a
6
+ metadata.gz: d6dec45593827ae2055b5cef614fcb2ca905d61bc3b85c02524cff4cdaeb2b8397e255d4550aa9079557af32d0baed3082ac858d81608c885a1226d99130e648
7
+ data.tar.gz: 784d568d21a7ac1a3120ca7b125079a9bc2fc42a030e19e668cd99e18332b66739550561be954ce4f61be025b7076526f091c66a866d66d0213c9e3b11d2b273
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .make_script.yaml
@@ -179,6 +179,47 @@ def make
179
179
  else
180
180
  puts Pastel.new.bright_cyan("make> ") + "completed"
181
181
  end
182
-
182
+ if !File.exist?('./.make_script.yaml')
183
+ File.open('.gitignore', 'a') do |f|
184
+ f << "\n.make_script.yaml\n"
185
+ end
186
+ end
183
187
  File.open('./.make_script.yaml', 'w') { |f| f.write(YAML.dump($cur_file_time_dict)) }
184
188
  end
189
+
190
+ def dump_md(filename, thisfile="make.rb")
191
+ puts Pastel.new.bright_cyan("make> ") + "dumping markdown file #{filename}"
192
+ File.open(filename, 'w') do |f|
193
+ f.puts "# #{thisfile} Documentation"
194
+ f.puts ""
195
+ if block_given?
196
+ yield f
197
+ f.puts ""
198
+ end
199
+ f.puts "## Usage"
200
+ f.puts ""
201
+ f.puts "Please install ruby and some package first:"
202
+ f.puts ""
203
+ f.puts "```sh"
204
+ f.puts "$ apt instal ruby"
205
+ f.puts "$ gem instal pastel ruby_make_script"
206
+ f.puts "```"
207
+ f.puts ""
208
+ f.puts "then you can run these command below."
209
+ $targetlist.each { |t|
210
+ if t.class == PhonyTarget
211
+ args = t.doc.arglist.map{ |a| a[0] }.join(' ')
212
+ f.puts "### `./#{thisfile} #{t.target} #{args}`"
213
+ f.puts ""
214
+ f.puts "#{t.doc.descr}"
215
+ f.puts ""
216
+ t.doc.arglist.each { |a|
217
+ f.puts "* `#{a[0]}` : #{a[1]}"
218
+ }
219
+ if t.doc.arglist != []
220
+ f.puts ""
221
+ end
222
+ end
223
+ }
224
+ end
225
+ end
@@ -0,0 +1,42 @@
1
+
2
+ class TargetDoc
3
+ attr_accessor :arglist
4
+ attr_accessor :descr
5
+ attr_accessor :name
6
+
7
+ def initialize()
8
+ @arglist = []
9
+ @descr = ""
10
+ @name = ""
11
+ end
12
+ def set_name(name)
13
+ @name = name
14
+ end
15
+
16
+ def add_arg(name, doc)
17
+ @arglist += [[name, doc]]
18
+ end
19
+
20
+ def add_descr(str)
21
+ @descr += str + "\n"
22
+ end
23
+
24
+ def empty?()
25
+ @arglist == [] || @descr == ""
26
+ end
27
+
28
+ def form_str()
29
+ [@name, *@arglist].join(" ")
30
+ end
31
+ end
32
+
33
+ $targetdoc = TargetDoc.new
34
+
35
+ def descr!(str)
36
+ $targetdoc.add_descr(str)
37
+ end
38
+
39
+ def arg!(name, doc)
40
+ $targetdoc.add_arg(name, doc)
41
+ end
42
+
@@ -1,8 +1,10 @@
1
1
  $t = []
2
2
  $d = []
3
3
 
4
- module Target
4
+ require "ruby_make_script/doc"
5
5
 
6
+ module Target
7
+
6
8
  def depend_each
7
9
  depend.each { |f|
8
10
  yield f
@@ -39,6 +41,7 @@ class FileTarget
39
41
  resolve(f)
40
42
  }
41
43
  end
44
+
42
45
  def run
43
46
  if ! @completed
44
47
  @update_proc.call
@@ -53,6 +56,7 @@ class FileTarget
53
56
  @depend = []
54
57
  @completed = false
55
58
  end
59
+
56
60
  def from(*dependlist)
57
61
  @depend = dependlist
58
62
  @update_proc = Proc.new {
@@ -72,7 +76,9 @@ end
72
76
 
73
77
  class PhonyTarget
74
78
  include Target
79
+ attr_accessor :target
75
80
  attr_accessor :depend
81
+ attr_accessor :doc
76
82
  def resolve_all
77
83
  resolve(@target)
78
84
  end
@@ -88,6 +94,9 @@ class PhonyTarget
88
94
  @target = str
89
95
  @depend = []
90
96
  @completed = false
97
+
98
+ @doc = $targetdoc
99
+ $targetdoc = TargetDoc.new
91
100
  end
92
101
 
93
102
  def from(*dependlist)
@@ -1,3 +1,3 @@
1
1
  module RubyMakeScript
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/make.md ADDED
@@ -0,0 +1 @@
1
+ # `make.rb` Usage### `make.rb setup <args...>`
data/test.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require "ruby_make_script"
2
2
 
3
3
  make do
4
+ descr! "setup the environment"
5
+ arg! "<args...>", "command to run"
4
6
  :setup.from do
5
7
  r "echo", "Hello", "World"
6
8
  end
7
- end
9
+ end
10
+
11
+ dump_md('make.md'){}
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.5
4
+ version: 0.1.6
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-24 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,9 +83,11 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/ruby_make_script.rb
86
+ - lib/ruby_make_script/doc.rb
86
87
  - lib/ruby_make_script/target.rb
87
88
  - lib/ruby_make_script/utils.rb
88
89
  - lib/ruby_make_script/version.rb
90
+ - make.md
89
91
  - ruby_make_script.gemspec
90
92
  - test.rb
91
93
  homepage: https://github.com/DnailZ/ruby_make_script