slyce 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/slyce +9 -9
- data/bin/slyce3 +46 -10
- data/bin/slyced +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6b0abe59bae61e2f6883c497a4aea1496cfb34bc6aaa3e98de9736c8571562
|
4
|
+
data.tar.gz: 52e62601f71421927d88fddfa1aaab680c292a0bd6ff62c419d52dbd7db5fd2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d3b6b2c9924c7d12e5b5665d699c717253b4cd85fcbb717694d86bf16d824b6a7de2f16d5990d06a3bc1e4b6fffde75019d13eacc3ab612a0eeb74a2fbf6aa
|
7
|
+
data.tar.gz: cb60a335ea7143ac375eb9e9c61a3477b88976127e9af90c6f544e9dbbaecc3efdd609dfd8b22be084a049829110af6b8c2b4a9173b0495a275f5bbe5e8ab7e8
|
data/bin/slyce
CHANGED
@@ -36,7 +36,7 @@ end
|
|
36
36
|
# ==[ Options ]==
|
37
37
|
|
38
38
|
OptionParser.new.instance_eval do
|
39
|
-
@version = "1.5.
|
39
|
+
@version = "1.5.1"
|
40
40
|
@banner = "usage: #{program_name} [options] <database> <table>"
|
41
41
|
|
42
42
|
on "--csv" , "Output comma separated values"
|
@@ -46,7 +46,7 @@ OptionParser.new.instance_eval do
|
|
46
46
|
on "-c", "--columns" , "Display column names and quit"
|
47
47
|
on "-d", "--dump" , "Dump database schema and quit"
|
48
48
|
on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
|
49
|
-
on "-H", "--
|
49
|
+
on "-H", "--headerless" , "Do not show headers when exporting delimited files"
|
50
50
|
on "-n", "--natural" , "Sort naturally, not numerically"
|
51
51
|
on "-s", "--show <count>" , "Show this many values", Integer
|
52
52
|
on "-t", "--tables" , "Display table names and quit"
|
@@ -65,13 +65,13 @@ xpsv = opts[:psv]
|
|
65
65
|
xtsv = opts[:tsv]
|
66
66
|
xprt = xcsv || xpsv || xtsv and require "censive"
|
67
67
|
|
68
|
-
asky = opts[:ascii
|
69
|
-
dump = opts[:dump
|
70
|
-
want = opts[:extract
|
71
|
-
natu = opts[:natural
|
72
|
-
show = opts[:show
|
73
|
-
hide = opts[:
|
74
|
-
filt = opts[:where
|
68
|
+
asky = opts[:ascii ] and require "any_ascii"
|
69
|
+
dump = opts[:dump ]
|
70
|
+
want = opts[:extract ].to_s.downcase.split(",")
|
71
|
+
natu = opts[:natural ]
|
72
|
+
show = opts[:show ]
|
73
|
+
hide = opts[:headerless]
|
74
|
+
filt = opts[:where ] and filt = "\nwhere\n #{filt}"
|
75
75
|
|
76
76
|
dbas ||= ARGV.shift or abort "no database given"
|
77
77
|
tabl ||= ARGV.shift or opts[:tables] or !want.empty? or abort "no table given"
|
data/bin/slyce3
CHANGED
@@ -49,13 +49,17 @@ end
|
|
49
49
|
# ==[ Options ]==
|
50
50
|
|
51
51
|
OptionParser.new.instance_eval do
|
52
|
-
@version = "1.5.
|
52
|
+
@version = "1.5.1"
|
53
53
|
@banner = "usage: #{program_name} [options] <database> <table>"
|
54
54
|
|
55
|
+
on "--csv" , "Output comma separated values"
|
56
|
+
on "--psv" , "Output pipe separated values"
|
57
|
+
on "--tsv" , "Output tab separated values"
|
58
|
+
on "-a", "--ascii" , "Convert data to ASCII using AnyAscii"
|
55
59
|
on "-c", "--columns" , "Display column names and quit"
|
56
60
|
on "-d", "--delete" , "Delete the .slyce database first"
|
57
61
|
on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
|
58
|
-
on "-
|
62
|
+
on "-H", "--headerless" , "Do not show headers when exporting delimited files"
|
59
63
|
on "-n", "--natural" , "Sort naturally, not numerically"
|
60
64
|
on "-r", "--regexp <path>" , "Path to the sqlean/regexp extension"
|
61
65
|
on "-s", "--show <count>" , "Show this many values", Integer
|
@@ -69,13 +73,20 @@ end.parse!(into: opts={}) rescue abort($!.message)
|
|
69
73
|
dbas = nil
|
70
74
|
tabl = nil
|
71
75
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
xcsv = opts[:csv]
|
77
|
+
xpsv = opts[:psv]
|
78
|
+
xtsv = opts[:tsv]
|
79
|
+
xprt = xcsv || xpsv || xtsv and require "censive"
|
80
|
+
|
81
|
+
asky = opts[:ascii ] and require "any_ascii"
|
82
|
+
nuke = opts[:delete ]
|
83
|
+
want = opts[:extract ].to_s.downcase.split(",")
|
84
|
+
keep = opts[:keep ]
|
85
|
+
natu = opts[:natural ]
|
86
|
+
regx = opts[:regexp ] || Dir["{.,sqlean,#{ENV['HOME']}}/regexp.{dll,dylib,so}"].first
|
87
|
+
show = opts[:show ]
|
88
|
+
hide = opts[:headerless]
|
89
|
+
filt = opts[:where ] and filt = "\nwhere\n #{filt}"
|
79
90
|
|
80
91
|
# ensure regexp extension is available
|
81
92
|
regx && File.exist?(regx) or abort "no regexp extension found#{regx ? " at '#{regx}'" : ''}"
|
@@ -90,8 +101,9 @@ when /(\.csv)$/, "/dev/stdin", "-"
|
|
90
101
|
file = $1 ? dbas : "-"
|
91
102
|
dbas = ".slyce"
|
92
103
|
tabl = "csv"
|
104
|
+
head = " |head -1" if opts[:columns]
|
93
105
|
`rm -f "#{dbas}"` if File.exist?(dbas) && !keep
|
94
|
-
`sqlite3 -csv '#{dbas}' ".import '|cat #{file}' '#{tabl}'"`
|
106
|
+
`sqlite3 -csv '#{dbas}' ".import '|cat #{file}#{head}' '#{tabl}'"`
|
95
107
|
else
|
96
108
|
tabl ||= ARGV.shift or abort "no table given"
|
97
109
|
end
|
@@ -112,6 +124,30 @@ if want.empty?
|
|
112
124
|
abort "no columns are selected"
|
113
125
|
end
|
114
126
|
|
127
|
+
# handle exports
|
128
|
+
if xprt
|
129
|
+
list = want.map {|item| %{"#{item}"} }.join(", ")
|
130
|
+
limt = show ? "limit #{show}" : ""
|
131
|
+
data = conn.sql(<<~"".rstrip).to_a
|
132
|
+
select
|
133
|
+
#{list}
|
134
|
+
from
|
135
|
+
"#{tabl}"
|
136
|
+
#{filt}
|
137
|
+
#{limt}
|
138
|
+
|
139
|
+
seps = xcsv ? "," : xtsv ? "\t" : xpsv ? "|" : abort("unknown separator #{seps.inspect}")
|
140
|
+
|
141
|
+
Censive.write(sep: seps) do |csv|
|
142
|
+
csv << want unless hide
|
143
|
+
data.each do |row|
|
144
|
+
csv << row.map {|e| asky ? AnyAscii.transliterate(e.to_s) : e.to_s }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
exit
|
149
|
+
end
|
150
|
+
|
115
151
|
want.each do |name|
|
116
152
|
sort = natu ? "" : "cnt desc,"
|
117
153
|
limt = show ? "limit #{show}" : ""
|
data/bin/slyced
CHANGED
@@ -38,7 +38,7 @@ end
|
|
38
38
|
# ==[ Options ]==
|
39
39
|
|
40
40
|
OptionParser.new.instance_eval do
|
41
|
-
@version = "1.5.
|
41
|
+
@version = "1.5.1"
|
42
42
|
@banner = "usage: #{program_name} [options] <database> <table>"
|
43
43
|
|
44
44
|
on "--csv" , "Output comma separated values"
|
@@ -47,7 +47,7 @@ OptionParser.new.instance_eval do
|
|
47
47
|
on "-a", "--ascii" , "Convert data to ASCII using AnyAscii"
|
48
48
|
on "-c", "--columns" , "Display column names and quit"
|
49
49
|
on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
|
50
|
-
on "-H", "--
|
50
|
+
on "-H", "--headerless" , "Do not show headers when exporting delimited files"
|
51
51
|
on "-n", "--natural" , "Sort naturally, not numerically"
|
52
52
|
on "-s", "--show <count>" , "Show this many values", Integer
|
53
53
|
on "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{@version}"; end
|
@@ -65,12 +65,12 @@ xpsv = opts[:psv]
|
|
65
65
|
xtsv = opts[:tsv]
|
66
66
|
xprt = xcsv || xpsv || xtsv and require "censive"
|
67
67
|
|
68
|
-
asky = opts[:ascii
|
69
|
-
want = opts[:extract]
|
70
|
-
natu = opts[:natural
|
71
|
-
show = opts[:show
|
72
|
-
hide = opts[:
|
73
|
-
filt = opts[:where
|
68
|
+
asky = opts[:ascii ] and require "any_ascii"
|
69
|
+
want = opts[:extract ].to_s.downcase.split(",")
|
70
|
+
natu = opts[:natural ]
|
71
|
+
show = opts[:show ]
|
72
|
+
hide = opts[:headerless]
|
73
|
+
filt = opts[:where ] and filt = "\nwhere\n #{filt}"
|
74
74
|
|
75
75
|
dbas ||= ARGV.shift or abort "no database given"
|
76
76
|
tabl ||= ARGV.shift or abort "no table given"
|
@@ -80,7 +80,7 @@ tabl ||= ARGV.shift or abort "no table given"
|
|
80
80
|
# ==[ Let 'er rip! ]==
|
81
81
|
|
82
82
|
conn = DuckDB::Database.open(dbas).connect
|
83
|
-
resu = conn.
|
83
|
+
resu = conn.sql(<<~end)
|
84
84
|
select column_name
|
85
85
|
from information_schema.columns
|
86
86
|
where table_name='#{tabl}'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: any_ascii
|