raka 0.7.2 → 0.8.0
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/VERSION +1 -1
- data/bin/raka +10 -0
- data/lib/raka/compile.rb +56 -7
- 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: 011cb849875835a2f870852a235004111610ed9c0eba29ada3c50d83bd0d8236
|
4
|
+
data.tar.gz: 77cbf3b3e2f594942302cdc1231d32a7ac3ce609097c3999905beedd322d934b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc771c7c40c7e9e8cc98d1150be293abac519500150324163160c863c99488ddb8e679b84c0f37c0c4d4386de984fd4aae2e56df5c54859a3fe25693d9655e57
|
7
|
+
data.tar.gz: 58b4980a085bff10965b1863e7b0e8b06db64b722412eac860ec95279cbb45461ab53ac6ae12648c9c413262e17daeb450d0c14db30f9c878df5fbfa5e066273
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/bin/raka
CHANGED
@@ -5,6 +5,11 @@ require 'optparse'
|
|
5
5
|
require 'English'
|
6
6
|
require 'open3'
|
7
7
|
|
8
|
+
def get_version
|
9
|
+
version_file = File.join(File.dirname(__FILE__), '..', 'VERSION')
|
10
|
+
File.read(version_file).strip
|
11
|
+
end
|
12
|
+
|
8
13
|
def detect_main
|
9
14
|
# check predefined files
|
10
15
|
main_file_cands = ['Rakefile.raka', 'rakefile.raka', 'main.raka']
|
@@ -32,6 +37,11 @@ parser = OptionParser.new do |opts|
|
|
32
37
|
set_option(options, :verbose, v)
|
33
38
|
end
|
34
39
|
|
40
|
+
opts.on('--version', 'Show version') do
|
41
|
+
puts get_version
|
42
|
+
exit(0)
|
43
|
+
end
|
44
|
+
|
35
45
|
opts.on('-f', '--file FILE', String, 'Run even when up to date') do |s|
|
36
46
|
set_option(options, :file, s)
|
37
47
|
end
|
data/lib/raka/compile.rb
CHANGED
@@ -130,6 +130,45 @@ class DSLCompiler
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
# extract typed components from rhs array and return filtered array + components
|
134
|
+
def extract_typed_components(rhs)
|
135
|
+
deps = []
|
136
|
+
posts = []
|
137
|
+
filtered_rhs = []
|
138
|
+
|
139
|
+
rhs.each do |item|
|
140
|
+
if item.is_a?(Hash)
|
141
|
+
# Handle hash with multiple key-value pairs like [dep: dep3, post: post1]
|
142
|
+
item.each do |key, value|
|
143
|
+
case key
|
144
|
+
when :dep, 'dep'
|
145
|
+
# Handle both single values and arrays, but don't convert Token objects
|
146
|
+
if value.is_a?(Array)
|
147
|
+
deps.concat(value)
|
148
|
+
else
|
149
|
+
deps << value
|
150
|
+
end
|
151
|
+
when :post, 'post'
|
152
|
+
# Handle both single values and arrays, but don't convert Token objects
|
153
|
+
if value.is_a?(Array)
|
154
|
+
posts.concat(value)
|
155
|
+
else
|
156
|
+
posts << value
|
157
|
+
end
|
158
|
+
else
|
159
|
+
# Unknown typed component - raise error
|
160
|
+
raise "Unknown typed component: #{key}. Supported components are 'dep' and 'post'"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
else
|
164
|
+
# Regular item (dependency, action, or post-task)
|
165
|
+
filtered_rhs << item
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
{ deps: deps, posts: posts, filtered_rhs: filtered_rhs }
|
170
|
+
end
|
171
|
+
|
133
172
|
# compile token = rhs to rake rule
|
134
173
|
# rubocop:disable Style/MethodLength
|
135
174
|
# rubocop:disable Style/PerceivedComplexity
|
@@ -138,34 +177,44 @@ class DSLCompiler
|
|
138
177
|
raise "DSL compile error: seems not a valid @env of rake with class #{@env.class}"
|
139
178
|
end
|
140
179
|
|
180
|
+
# Extract typed components first
|
181
|
+
components = extract_typed_components(rhs)
|
182
|
+
typed_deps = components[:deps]
|
183
|
+
typed_posts = components[:posts]
|
184
|
+
filtered_rhs = components[:filtered_rhs]
|
185
|
+
|
141
186
|
# the format is [dep, ...] | [action, ...] | [post, ...], where the posts
|
142
187
|
# are those will be raked after the actions
|
143
|
-
actions_start =
|
188
|
+
actions_start = filtered_rhs.find_index { |item| item.respond_to?(:call) }
|
144
189
|
|
145
190
|
# case 1: has action
|
146
191
|
if actions_start
|
147
|
-
extra_deps =
|
148
|
-
actions_end =
|
192
|
+
extra_deps = filtered_rhs[0, actions_start]
|
193
|
+
actions_end = filtered_rhs[actions_start, filtered_rhs.length].find_index do |item|
|
149
194
|
!item.respond_to?(:call)
|
150
195
|
end
|
151
196
|
|
152
197
|
# case 1.1: has post
|
153
198
|
if actions_end
|
154
199
|
actions_end += actions_start
|
155
|
-
actions =
|
156
|
-
extra_tasks =
|
200
|
+
actions = filtered_rhs[actions_start, actions_end]
|
201
|
+
extra_tasks = filtered_rhs[actions_end, filtered_rhs.length]
|
157
202
|
# case 1.2: no post
|
158
203
|
else
|
159
|
-
actions =
|
204
|
+
actions = filtered_rhs[actions_start, filtered_rhs.length]
|
160
205
|
extra_tasks = []
|
161
206
|
end
|
162
207
|
# case 2: no action
|
163
208
|
else
|
164
|
-
extra_deps =
|
209
|
+
extra_deps = filtered_rhs
|
165
210
|
actions = []
|
166
211
|
extra_tasks = []
|
167
212
|
end
|
168
213
|
|
214
|
+
# Merge typed components with extracted components
|
215
|
+
extra_deps = extra_deps + typed_deps
|
216
|
+
extra_tasks = extra_tasks + typed_posts
|
217
|
+
|
169
218
|
unless lhs._input_?
|
170
219
|
create_rule lhs, proc { [] }, actions, extra_deps, extra_tasks
|
171
220
|
return
|