idata 0.2.3 → 0.2.4
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 +37 -14
- data/lib/idata/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a65ffab6dcd5b46ea706e0234d603432d8dfe967
|
4
|
+
data.tar.gz: 375b06bd1ba205618418c0fd536ea241cf59dc10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e35c422fa9eae8475d33b750022f236ec74e0f1f95fd4baff680abaec9f7d2ff1c6ef436a183c7c8d9d09cf35c3b0b4b4aed2bf4cb18d674356d16787024130
|
7
|
+
data.tar.gz: 0c8838b2a6483870fec4289d4d8570e24e2da1af095a12d6ccdc274451b1b2ab55413f81e5f8916b80b50a2fb905d035b7a9d19a3fdfc8db53ba56055be06f19
|
data/bin/iexport
CHANGED
@@ -14,6 +14,7 @@ require 'active_record'
|
|
14
14
|
require 'rubygems'
|
15
15
|
require 'digest/sha1'
|
16
16
|
require 'fileutils'
|
17
|
+
require 'sqlite3'
|
17
18
|
|
18
19
|
SUPPORTED_INPUT_FORMATS = ['CSV']
|
19
20
|
POSTGRESQL_PORT = 5432
|
@@ -80,6 +81,10 @@ parser = OptionParser.new("", 24) do |opts|
|
|
80
81
|
opts.on("-o", "--output FILE", "Output file") do |v|
|
81
82
|
$options[:output] = v
|
82
83
|
end
|
84
|
+
|
85
|
+
opts.on("--sqlitedb PATH", "Path to SQLite3 database file") do |v|
|
86
|
+
$options[:sqlitedb] = v
|
87
|
+
end
|
83
88
|
|
84
89
|
opts.on("-h", "--host HOST", "PostgreSQL host") do |v|
|
85
90
|
$options[:host] = v
|
@@ -157,21 +162,32 @@ if $options[:output].nil?
|
|
157
162
|
exit
|
158
163
|
end
|
159
164
|
|
160
|
-
if $options[:host].nil?
|
165
|
+
if $options[:host].nil? && $options[:sqlitedb].nil?
|
161
166
|
puts "\nPlease specify host name: -h\n\n"
|
162
167
|
exit
|
163
168
|
end
|
164
169
|
|
165
|
-
if $options[:database].nil?
|
170
|
+
if $options[:database].nil? && $options[:sqlitedb].nil?
|
166
171
|
puts "\nPlease specify PostgreSQL database name: -d\n\n"
|
167
172
|
exit
|
168
173
|
end
|
169
174
|
|
170
|
-
if $options[:username].nil?
|
175
|
+
if $options[:username].nil? && $options[:sqlitedb].nil?
|
171
176
|
puts "\nPlease specify PostgreSQL username: -u\n\n"
|
172
177
|
exit
|
173
178
|
end
|
174
179
|
|
180
|
+
if ($options[:host] || $options[:username] || $options[:listen] || $options[:password]) && $options[:sqlitedb]
|
181
|
+
puts "\nYou cannot specify both PostgreSQL ('host', 'username', 'listen', 'password') and SQLite ('sqlitedb') parameters \n\n"
|
182
|
+
exit
|
183
|
+
end
|
184
|
+
|
185
|
+
if $options[:sqlitedb] && !File.exists?($options[:sqlitedb])
|
186
|
+
puts "\nFile does not exist '#{$options[:sqlitedb]}'\n\n"
|
187
|
+
exit
|
188
|
+
end
|
189
|
+
|
190
|
+
|
175
191
|
# Default value
|
176
192
|
$options[:listen] ||= POSTGRESQL_PORT
|
177
193
|
$options[:delim] ||= CSV_DEFAULT_DELIMITER
|
@@ -182,7 +198,7 @@ $options[:headers] ||= false
|
|
182
198
|
$options[:quotes] ||= false
|
183
199
|
$options[:quote_empty] ||= false
|
184
200
|
$options[:select] ||= '*'
|
185
|
-
$options[:where] ||= 'true'
|
201
|
+
$options[:where] ||= ( $options[:sqlitedb].nil? ) ? 'true' : '1=1'
|
186
202
|
$options[:include] ||= ""
|
187
203
|
|
188
204
|
# Do not quote the '"' char
|
@@ -203,16 +219,23 @@ end
|
|
203
219
|
|
204
220
|
$options[:select] = [$options[:select].split(/\s*,\s*/) + $options[:include].split(/\s*,\s*/)].join(", ")
|
205
221
|
|
206
|
-
|
207
|
-
ActiveRecord::Base.establish_connection(
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
222
|
+
if $options[:sqlitedb]
|
223
|
+
ActiveRecord::Base.establish_connection(
|
224
|
+
'adapter' => 'sqlite3',
|
225
|
+
'database' => $options[:sqlitedb],
|
226
|
+
'timeout' => 15000
|
227
|
+
)
|
228
|
+
else
|
229
|
+
ActiveRecord::Base.establish_connection(
|
230
|
+
'adapter' => 'postgresql',
|
231
|
+
'host' => $options[:host],
|
232
|
+
'database' => $options[:database],
|
233
|
+
'username' => $options[:username],
|
234
|
+
'password' => $options[:password],
|
235
|
+
'port' => $options[:listen],
|
236
|
+
'timeout' => 15000
|
237
|
+
)
|
238
|
+
end
|
216
239
|
|
217
240
|
class Product < ActiveRecord::Base
|
218
241
|
self.table_name = $options[:table]
|
data/lib/idata/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nghi Pham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|