raka 0.7.3 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6918188c64614bab203408d4dcac9a7dc48fc1234452ffd5dc481f1fa48b3be5
4
- data.tar.gz: dab15a870d3891b96e28800cd412787c1b794101923b042c896a0b4ad0bf533f
3
+ metadata.gz: 42db0891e95e6b4506cac41e2754df5387cc456559a174299a28da2b4066705e
4
+ data.tar.gz: 01b935c926560fd2b1f106aee4548bb9a303c386105a756e45c29db50b1f2ad1
5
5
  SHA512:
6
- metadata.gz: 7202488f6e5d0c06ebea878d963ef30d4f143db323832ef8cfb6df4741d99cdafed65ef7564e302d589b50fb8896fbc3077a80e93e8c1ce4c58f4921103d91b6
7
- data.tar.gz: fb07a9052a869639c4a2ae8d3a93810ce8d7c622f543b1549d21a50bea17f24ab87d84dcaf6283ca75c9f816f4860c368e413a830a5804ec248621584335a15e
6
+ metadata.gz: a7cc42e54f408a69cfb124a0c4072f0669a19138e931a3a3413490fee1beadfee6d371c18021124fbd35345ef77308f7410876a8a7b3c151c58b5fabe319a53d
7
+ data.tar.gz: e1269029d10dcdc410430b99117651c8c54bc72723af9df21f11db09c76c3cfdcbbb27473da49507997ba6daab37e192b8136575e9332670c8b6ae71d5c063f5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.8.1
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
@@ -77,12 +77,12 @@ class Duckdb
77
77
  # Split the SQL into separate statements and execute them individually
78
78
  bash env, %(
79
79
  # Execute the combined SQL script with proper variable replacement
80
- cat #{fname} | sed 's|:_name_|#{task.output_stem}|g' | #{duckdb_cmd} | tee #{fname}.log
80
+ cat #{fname} | sed 's|:_name_|#{task.output_stem}|g' | #{duckdb_cmd} | { cat; echo; } | sed '$ { /^$/ d; }' | tee #{fname}.log
81
81
  echo "#{@database}" > #{task.name}
82
82
  )
83
83
  when :adhoc
84
84
  bash env, %(
85
- cat #{fname} | sed 's|:output:|#{task.name}|g' | #{duckdb_cmd} | tee #{fname}.log
85
+ cat #{fname} | sed 's|:output:|#{task.name}|g' | #{duckdb_cmd} | { cat; echo; } | sed '$ { /^$/ d; }' | tee #{fname}.log
86
86
  )
87
87
  end
88
88
  end
@@ -52,7 +52,7 @@ class Psql
52
52
 
53
53
  bash env, %(
54
54
  #{sh_cmd(schema)} #{param_str} -v _name_=#{task.output_stem} \
55
- -v _schema_=#{schema.empty? ? '' : schema + '.'} -f #{fname} | tee #{fname}.log
55
+ -v _schema_=#{schema.empty? ? '' : schema + '.'} -f #{fname} | { cat; echo; } | sed '$ { /^$/ d; }' | tee #{fname}.log
56
56
  mv #{fname}.log #{task.name}
57
57
  )
58
58
  end
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yarray