raka 0.7.3 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/raka/compile.rb +56 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6918188c64614bab203408d4dcac9a7dc48fc1234452ffd5dc481f1fa48b3be5
4
- data.tar.gz: dab15a870d3891b96e28800cd412787c1b794101923b042c896a0b4ad0bf533f
3
+ metadata.gz: 011cb849875835a2f870852a235004111610ed9c0eba29ada3c50d83bd0d8236
4
+ data.tar.gz: 77cbf3b3e2f594942302cdc1231d32a7ac3ce609097c3999905beedd322d934b
5
5
  SHA512:
6
- metadata.gz: 7202488f6e5d0c06ebea878d963ef30d4f143db323832ef8cfb6df4741d99cdafed65ef7564e302d589b50fb8896fbc3077a80e93e8c1ce4c58f4921103d91b6
7
- data.tar.gz: fb07a9052a869639c4a2ae8d3a93810ce8d7c622f543b1549d21a50bea17f24ab87d84dcaf6283ca75c9f816f4860c368e413a830a5804ec248621584335a15e
6
+ metadata.gz: cc771c7c40c7e9e8cc98d1150be293abac519500150324163160c863c99488ddb8e679b84c0f37c0c4d4386de984fd4aae2e56df5c54859a3fe25693d9655e57
7
+ data.tar.gz: 58b4980a085bff10965b1863e7b0e8b06db64b722412eac860ec95279cbb45461ab53ac6ae12648c9c413262e17daeb450d0c14db30f9c878df5fbfa5e066273
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.8.0
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 = rhs.find_index { |item| item.respond_to?(:call) }
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 = rhs[0, actions_start]
148
- actions_end = rhs[actions_start, rhs.length].find_index do |item|
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 = rhs[actions_start, actions_end]
156
- extra_tasks = rhs[actions_end, rhs.length]
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 = rhs[actions_start, rhs.length]
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 = rhs
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yarray