idata 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/iexport +18 -2
- data/guideline/Guideline.docx +0 -0
- data/lib/idata/version.rb +1 -1
- metadata +98 -73
- checksums.yaml +0 -7
data/bin/iexport
CHANGED
@@ -18,6 +18,7 @@ SUPPORTED_INPUT_FORMATS = ['CSV']
|
|
18
18
|
POSTGRESQL_PORT = 5432
|
19
19
|
CSV_DEFAULT_DELIMITER = ','
|
20
20
|
CSV_ROW_SEP = "\r\n"
|
21
|
+
CSV_DEFAULT_QUOTE_CHAR = '"'
|
21
22
|
|
22
23
|
$options = {}
|
23
24
|
parser = OptionParser.new("", 24) do |opts|
|
@@ -31,9 +32,17 @@ parser = OptionParser.new("", 24) do |opts|
|
|
31
32
|
$options[:headers] = v
|
32
33
|
end
|
33
34
|
|
35
|
+
opts.on("--[no-]quote-empty", "Whether or not export the header") do |v|
|
36
|
+
$options[:quote_empty] = v
|
37
|
+
end
|
38
|
+
|
34
39
|
opts.on("--[no-]quotes", "Quote null values") do |v|
|
35
40
|
$options[:quotes] = v
|
36
41
|
end
|
42
|
+
|
43
|
+
opts.on("--quote-char CHAR", "Quote null values") do |v|
|
44
|
+
$options[:quote_char] = v
|
45
|
+
end
|
37
46
|
|
38
47
|
opts.on("--delim DELIMITER", "CSV delimiter") do |v|
|
39
48
|
$options[:delim] = v
|
@@ -146,9 +155,11 @@ end
|
|
146
155
|
$options[:listen] ||= POSTGRESQL_PORT
|
147
156
|
$options[:delim] ||= CSV_DEFAULT_DELIMITER
|
148
157
|
$options[:linebreak] ||= CSV_ROW_SEP
|
158
|
+
$options[:quote_char] ||= CSV_DEFAULT_QUOTE_CHAR
|
149
159
|
$options[:delim] = "\t" if $options[:delim] == '\t'
|
150
160
|
$options[:headers] ||= false
|
151
161
|
$options[:quotes] ||= false
|
162
|
+
$options[:quote_empty] ||= false
|
152
163
|
$options[:select] ||= '*'
|
153
164
|
$options[:where] ||= 'true'
|
154
165
|
|
@@ -167,12 +178,17 @@ class Product < ActiveRecord::Base
|
|
167
178
|
self.table_name = $options[:table]
|
168
179
|
end
|
169
180
|
|
170
|
-
CSV.open($options[:output], "wb", :col_sep => $options[:delim], :row_sep => $options[:linebreak], :force_quotes => $options[:quotes]) do |csv|
|
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|
|
171
182
|
scope = Product.select($options[:select]).where($options[:where])
|
172
183
|
csv << scope.first.attributes.keys if $options[:headers]
|
173
184
|
|
174
185
|
scope.each do |item|
|
175
|
-
|
186
|
+
attrs = item.attributes.values
|
187
|
+
if $options[:quote_empty]
|
188
|
+
attrs.map!{|e| e == "" ? nil : e }
|
189
|
+
end
|
190
|
+
|
191
|
+
csv << attrs
|
176
192
|
end
|
177
193
|
end
|
178
194
|
|
Binary file
|
data/lib/idata/version.rb
CHANGED
metadata
CHANGED
@@ -1,75 +1,86 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: idata
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Nghi Pham
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-04-22 00:00:00 +07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
14
22
|
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
type: :development
|
21
23
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.9'
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 3
|
33
|
+
version: "1.3"
|
34
34
|
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
35
38
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 25
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 9
|
48
|
+
version: "0.9"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
42
52
|
name: rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '4.0'
|
48
|
-
type: :runtime
|
49
53
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 27
|
60
|
+
segments:
|
61
|
+
- 4
|
62
|
+
- 0
|
63
|
+
version: "4.0"
|
62
64
|
type: :runtime
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: pg
|
63
68
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
69
80
|
description: Tools for importing data from raw files
|
70
|
-
email:
|
81
|
+
email:
|
71
82
|
- minhnghivn@gmail.com
|
72
|
-
executables:
|
83
|
+
executables:
|
73
84
|
- iload
|
74
85
|
- ieval
|
75
86
|
- ipatch
|
@@ -77,8 +88,10 @@ executables:
|
|
77
88
|
- iexport
|
78
89
|
- isanitize
|
79
90
|
extensions: []
|
91
|
+
|
80
92
|
extra_rdoc_files: []
|
81
|
-
|
93
|
+
|
94
|
+
files:
|
82
95
|
- .gitignore
|
83
96
|
- Gemfile
|
84
97
|
- LICENSE.txt
|
@@ -90,31 +103,43 @@ files:
|
|
90
103
|
- bin/ipatch
|
91
104
|
- bin/isanitize
|
92
105
|
- bin/ivalidate
|
106
|
+
- guideline/Guideline.docx
|
93
107
|
- idata.gemspec
|
94
108
|
- lib/idata.rb
|
95
109
|
- lib/idata/version.rb
|
96
|
-
|
97
|
-
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: ""
|
112
|
+
licenses:
|
98
113
|
- MIT
|
99
|
-
metadata: {}
|
100
114
|
post_install_message:
|
101
115
|
rdoc_options: []
|
102
|
-
|
116
|
+
|
117
|
+
require_paths:
|
103
118
|
- lib
|
104
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
version: "0"
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
114
137
|
requirements: []
|
138
|
+
|
115
139
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
140
|
+
rubygems_version: 1.3.7
|
117
141
|
signing_key:
|
118
|
-
specification_version:
|
142
|
+
specification_version: 3
|
119
143
|
summary: Tools for importing data from raw files
|
120
144
|
test_files: []
|
145
|
+
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: de1fa33723709e45d67e5495ed8ca37134878e0c
|
4
|
-
data.tar.gz: bd2ed5bb808e59a51289a8f6c43094dbc250b57f
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: d7e6f3453ba1f48d6544cce26965ae1886b4e075adcef4afb2d966430d26e08ddd3796f125c8956b1daaf360923bfcd1cf57d20e77319cd4b397d5c336364a53
|
7
|
-
data.tar.gz: c3ee509d9390d2f495a99441458b7c3c90a9a5d295969b37ae4653585b904236c6d7c8a45fd7dbb317a91c1df153521a98160ca8b3fad41f35dc099bc9ef1669
|