idata 0.1.2 → 0.1.3

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/bin/iexport +8 -1
  3. data/lib/idata/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32167a99138f7f8c9a2685be4fbb494bfdf44e5c
4
- data.tar.gz: ca5493dd9e660a24c69b9a8cc1c234e6e5b20bfc
3
+ metadata.gz: 521f9181a3c63dbe51c67763b06cb8469c0daf2d
4
+ data.tar.gz: dade0d4c7350811ad3270298cd18ed2c3213ba9c
5
5
  SHA512:
6
- metadata.gz: 177d8f683986549f9fcfc8f92cecb6065c0641fb769e0176b8c79e32880e0f5ff17e099d7d8aa0fe333de97cd8c680512b616657901fbdab905f66c1f143a6bf
7
- data.tar.gz: cde736b0efca4a968879c111c7987b3cca51f7946d3ce6574fe450332b6be4832be0217bd0a35884a7a84727638d3b3a4b85549f8eb7135725d72b7ef7a42980
6
+ metadata.gz: 52d9d927c5c2543c906652fbd38bab4d503cb97650b8e1f7b542e54ca1c99fddfe4a7f4307ddba2e98f257f1f00f0eba11d4be519c9a44322a6ea0a1261e1a98
7
+ data.tar.gz: 5b2a0c7f48ad547ede412525dfadfe885557a984315c1cb58cfe6eead69cd5d35d080765a120cc7cd8e44eecdce1ecd3ac5f3c04d6b179bce41abb059430f6b7
data/bin/iexport CHANGED
@@ -180,7 +180,14 @@ end
180
180
 
181
181
  CSV.open($options[:output], "wb", :quote_char => $options[:quote_char], :col_sep => $options[:delim], :row_sep => $options[:linebreak], :force_quotes => $options[:quotes]) do |csv|
182
182
  scope = Product.select($options[:select]).where($options[:where])
183
- csv << scope.first.attributes.keys if $options[:headers]
183
+ first = scope.first
184
+
185
+ if first
186
+ csv << first.attributes.keys if $options[:headers]
187
+ else
188
+ # only use .column_names when table is empty, to ensure fields match values
189
+ csv << Product.column_names if $options[:headers]
190
+ end
184
191
 
185
192
  scope.each do |item|
186
193
  attrs = item.attributes.values
data/lib/idata/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Idata
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nghi Pham