spud 0.1.9 → 0.1.10
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/lib/build_tools/build_rule.rb +8 -0
- data/lib/build_tools/spud/rule.rb +14 -5
- data/lib/build_tools/spud/rule_context.rb +3 -7
- data/lib/spud.rb +54 -1
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb821b1f4c184c6f4fda6e5fe02f17807786cbae5d2678f5ce63d154e8986e29
|
4
|
+
data.tar.gz: 9db7fac77dcd10a339c6f5ded2136b36801b547abee13ee73d062674f8a949f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37572660fdd244779b01427399527d1ec89f7533657f0e9b2ec8e620efc2ba3111dc6c3b5f12429270dddfbb9f46a018a5745934684581ea1af4b6eed11558c5
|
7
|
+
data.tar.gz: 40247e664b05f7e059c3b676e0465bab1b03927dceda1ffaf6fd6991c145ce2afc76d8780bb856ab5ddf923271febfb689956a7d0057b3768b944c6c598488f5
|
@@ -21,9 +21,9 @@ module Spud::BuildTools
|
|
21
21
|
def invoke(*args, **kwargs)
|
22
22
|
raise Spud::Error, "'#{@name}' is up to date" if up_to_date?
|
23
23
|
|
24
|
-
missing =
|
24
|
+
missing = positional_params.length - args.length
|
25
25
|
if missing > 0
|
26
|
-
names =
|
26
|
+
names = positional_params.map { |name| "'#{name}'" }.join(', ')
|
27
27
|
arguments = missing > 1 ? 'arguments' : 'argument'
|
28
28
|
raise Spud::Error, "invocation of '#{@name}' missing required #{arguments} #{names}"
|
29
29
|
end
|
@@ -37,6 +37,15 @@ module Spud::BuildTools
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
# Params
|
41
|
+
def positional_params
|
42
|
+
@positional_params ||= params.select { |p| p.first == :req }.map(&:last)
|
43
|
+
end
|
44
|
+
|
45
|
+
def keyword_params
|
46
|
+
@keyword_params ||= params.select { |p| p.first == :key }.map(&:last)
|
47
|
+
end
|
48
|
+
|
40
49
|
private
|
41
50
|
|
42
51
|
# Up to date checking
|
@@ -86,11 +95,11 @@ module Spud::BuildTools
|
|
86
95
|
|
87
96
|
# Lambda
|
88
97
|
def key_params?
|
89
|
-
|
98
|
+
@key_params ||= !keyword_params.empty?
|
90
99
|
end
|
91
100
|
|
92
|
-
def
|
93
|
-
lam.parameters
|
101
|
+
def params
|
102
|
+
@params ||= lam.parameters
|
94
103
|
end
|
95
104
|
|
96
105
|
def lam
|
@@ -16,10 +16,6 @@ module Spud::BuildTools
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def __shell(cmd, params = {})
|
20
|
-
@__process = Spud::Shell.new(cmd, params)
|
21
|
-
end
|
22
|
-
|
23
19
|
def sh(cmd)
|
24
20
|
out = sh?(cmd)
|
25
21
|
raise ShellError unless out.status.exitstatus.zero?
|
@@ -29,7 +25,7 @@ module Spud::BuildTools
|
|
29
25
|
|
30
26
|
def sh?(cmd)
|
31
27
|
puts cmd
|
32
|
-
|
28
|
+
Spud::Shell.new(cmd)
|
33
29
|
end
|
34
30
|
|
35
31
|
def shh(cmd)
|
@@ -40,7 +36,7 @@ module Spud::BuildTools
|
|
40
36
|
end
|
41
37
|
|
42
38
|
def shh?(cmd)
|
43
|
-
|
39
|
+
Spud::Shell.new(cmd)
|
44
40
|
end
|
45
41
|
|
46
42
|
def shhh(cmd)
|
@@ -51,7 +47,7 @@ module Spud::BuildTools
|
|
51
47
|
end
|
52
48
|
|
53
49
|
def shhh?(cmd)
|
54
|
-
|
50
|
+
Spud::Shell.new(cmd, silent: true)
|
55
51
|
end
|
56
52
|
|
57
53
|
def invoke(name, *args, **kwargs)
|
data/lib/spud.rb
CHANGED
@@ -91,20 +91,73 @@ module Spud
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def print_rules!
|
94
|
-
table = rules.map { |name, rule|
|
94
|
+
#table = rules.map { |name, rule| { name: name, filename: rule.filename } }
|
95
|
+
|
96
|
+
longest_name = 0
|
97
|
+
longest_filename = 0
|
98
|
+
longest_positional = 0
|
99
|
+
longest_keyword = 0
|
100
|
+
table = []
|
101
|
+
rules.each do |name, rule|
|
102
|
+
longest_name = name.length if name.length > longest_name
|
103
|
+
|
104
|
+
positional = rule.positional_params.map(&method(:wrap_param)).join(' ')
|
105
|
+
longest_positional = positional.length if positional.length > longest_positional
|
106
|
+
|
107
|
+
keyword = rule.keyword_params.map(&method(:prefix_param)).join(' ')
|
108
|
+
longest_keyword = keyword.length if keyword.length > longest_keyword
|
109
|
+
|
110
|
+
longest_filename = rule.filename.length if rule.filename.length > longest_filename
|
111
|
+
|
112
|
+
table << [name, positional, keyword, rule.filename]
|
113
|
+
end
|
114
|
+
|
115
|
+
table.each do |(name, positional, keyword, filename)|
|
116
|
+
fields = [name.ljust(longest_name)]
|
117
|
+
fields << positional.ljust(longest_positional) unless longest_positional == 0
|
118
|
+
fields << keyword.ljust(longest_keyword) unless longest_keyword == 0
|
119
|
+
fields << filename.ljust(longest_filename)
|
120
|
+
|
121
|
+
puts fields.join(' ')
|
122
|
+
end
|
123
|
+
|
124
|
+
return
|
95
125
|
|
96
126
|
longest_rule = 0
|
97
127
|
longest_filename = 0
|
128
|
+
longest_positional = 0
|
129
|
+
longest_keyword = 0
|
98
130
|
table.each do |(rule, filename)|
|
99
131
|
longest_rule = rule.length if rule.length > longest_rule
|
100
132
|
longest_filename = filename.length if filename.length > longest_filename
|
133
|
+
|
134
|
+
positional = rule.positional_params.map(&method(:wrap_param)).join(' ')
|
135
|
+
longest_positional = positional.length if positional.length > longest_positional
|
136
|
+
|
137
|
+
keyword = rule.keyword_params.map(&method(:prefix_param)).join(' ')
|
138
|
+
longest_keyword = keyword.length if keyword.length > longest_keyword
|
101
139
|
end
|
102
140
|
|
103
141
|
table.each do |(rule, filename)|
|
142
|
+
[
|
143
|
+
[rule, longest_rule],
|
144
|
+
[positional, longest_positional],
|
145
|
+
[filename, longest_filename],
|
146
|
+
[filename, longest_filename],
|
147
|
+
]
|
148
|
+
|
104
149
|
puts "#{rule.ljust(longest_rule)} #{filename.ljust(longest_filename)}"
|
105
150
|
end
|
106
151
|
end
|
107
152
|
|
153
|
+
def wrap_param(name)
|
154
|
+
"<#{name}>"
|
155
|
+
end
|
156
|
+
|
157
|
+
def prefix_param(name)
|
158
|
+
name.length == 1 ? "-#{name}" : "--#{name}"
|
159
|
+
end
|
160
|
+
|
108
161
|
# Help
|
109
162
|
def print_help!
|
110
163
|
help = StringIO.new
|
data/lib/version.rb
CHANGED