idata 0.1.25 → 0.1.26
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/bin/iexport +16 -5
- data/lib/idata/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7615b5632f23a4d6a9f12ae44516ba1a985c71d9
|
|
4
|
+
data.tar.gz: 1de25681e830eba21537288a82a36b5d0a4658e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c38b43eac63a08f792b2fee967ec6aaa59e12e446a92641f4c5c7fb6a783ff210ac2925ba5051d4a27b2e7c0bd7e7f1678a6e7df43d9040d5294c44a0fa13a1
|
|
7
|
+
data.tar.gz: 7f8a19d9c36edb2a5a1d2521b457cb631671755838f626f13b0f9f12339812c71ceebfb2af445350ef779158e6748fd4320115f537fcd4b3e8b934c800224eff
|
data/bin/iexport
CHANGED
|
@@ -219,7 +219,7 @@ end
|
|
|
219
219
|
|
|
220
220
|
CSV.open($options[:output], "wb", :quote_char => $options[:quote_char], :col_sep => $options[:delim], :row_sep => $options[:linebreak], :force_quotes => $options[:quotes]) do |csv|
|
|
221
221
|
if $options[:query]
|
|
222
|
-
scope =
|
|
222
|
+
scope = ActiveRecord::Base.connection.execute($options[:query])
|
|
223
223
|
else
|
|
224
224
|
scope = Product.select($options[:select]).where($options[:where])
|
|
225
225
|
end
|
|
@@ -227,14 +227,25 @@ CSV.open($options[:output], "wb", :quote_char => $options[:quote_char], :col_sep
|
|
|
227
227
|
first = scope.first
|
|
228
228
|
|
|
229
229
|
if first
|
|
230
|
-
|
|
230
|
+
if $options[:query]
|
|
231
|
+
csv << first.delete_if{|k,v| k.nil? || $options[:exclude].include?(k) }.keys if $options[:headers]
|
|
232
|
+
else
|
|
233
|
+
csv << first.attributes.delete_if{|k,v| k.nil? || $options[:exclude].include?(k) }.keys if $options[:headers]
|
|
234
|
+
end
|
|
231
235
|
else
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
unless $options[:query]
|
|
237
|
+
# only use .column_names when table is empty, to ensure fields match values
|
|
238
|
+
csv << Product.column_names if $options[:headers]
|
|
239
|
+
end
|
|
234
240
|
end
|
|
235
241
|
|
|
236
242
|
scope.each do |item|
|
|
237
|
-
|
|
243
|
+
if $options[:query]
|
|
244
|
+
attrs = item.delete_if{|k,v| k.nil? || $options[:exclude].include?(k) }.values
|
|
245
|
+
else
|
|
246
|
+
attrs = item.attributes.delete_if{|k,v| k.nil? || $options[:exclude].include?(k) }.values
|
|
247
|
+
end
|
|
248
|
+
|
|
238
249
|
if !$options[:quote_empty]
|
|
239
250
|
attrs.map!{|e| e == "" ? nil : e }
|
|
240
251
|
end
|
data/lib/idata/version.rb
CHANGED