slyce 0.9.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/slyce +9 -17
  3. data/bin/slyce3 +10 -18
  4. data/slyce.gemspec +1 -1
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4b3343260618e644b563f9b03b2817796a8439727c753dacf59a93e11bd04af
4
- data.tar.gz: 5b9d02e5e596ccf9b32d54f54bd35cb79b86242c9ab1924a46f79cfdd4efb12f
3
+ metadata.gz: 36daa71deee82e19314bc1df0caedb1bc6b4a2b8f0bf524a471f48fcf28c1fb7
4
+ data.tar.gz: 71c450033ed16659bcb206e6023dc92f9cf448736355385101d051f9c7cfebc4
5
5
  SHA512:
6
- metadata.gz: a942b4899789d36ee3a65afbdd4f38308e3438d46a1bdab18a99af94ed2cae00de3ffb282e2ec22eaaf14d341909c623085fa7bf0273753b4bcd915613812235
7
- data.tar.gz: 59397e8e24245ea8a42030721911c3dc20011d54d67f0b680b96db16154d95d98897705a166339bdf8fc495828b9f25da5a8a0fc8c51caa101b674cd0633eadc
6
+ metadata.gz: a621fa8b4369fe27d5edc33573b0fe1f59312c7e97564a2c146517bebb3481b1633ffb9444cd494a97890efb0d8fa57f3885281e4c6d281821c6219376f1ee86
7
+ data.tar.gz: aa98ed93dfc2e762b4e39fbe1d70d5f09c00d47ed5021511dc5811fbb826c97d121f7719a196677b60351f0fc5152f1efcc7a1984140b0be758dab6253cab38d
data/bin/slyce CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- VERSION="0.9.8"
3
+ VERSION="1.0.0"
4
4
 
5
5
  STDOUT.sync = true
6
6
 
@@ -15,19 +15,19 @@ tabl = nil
15
15
  OptionParser.new.instance_eval do
16
16
  @banner = "usage: #{program_name} [options] <database> <table>"
17
17
 
18
- on "-a", "--alpha" , "Sort alphabetically, not numerically"
19
18
  on "-c", "--columns" , "Display column names and quit"
20
19
  on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
20
+ on "-n", "--natural" , "Sort naturally, not numerically"
21
21
  on "-s", "--show <count>" , "Show this many values", Integer
22
22
  on "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{VERSION}"; end
23
- on "-w", "--where <cond>" , "Filter rows (eg - 'age=33,Name=/[BW]ill/i,color=\"\"'"
23
+ on "-w", "--where <cond>" , "Where clause (eg - 'age>50 and state='AZ')"
24
24
  on "-x", "--extract <col1,col2,...>", "Comma separated list of columns to extract"
25
25
 
26
26
  self
27
27
  end.parse!(into: opts={}) rescue abort($!.message)
28
28
 
29
- abcd = opts[:alpha]
30
29
  filt = opts[:where] and filt = "where\n #{filt}"
30
+ natu = opts[:natural]
31
31
  show = opts[:show]
32
32
  want = opts[:extract].to_s.downcase.split(",")
33
33
 
@@ -37,9 +37,7 @@ tabl ||= ARGV.shift or abort "no table given"
37
37
  # ==[ Helpers ]==
38
38
 
39
39
  class Mysql2::Client
40
- def sql(...)
41
- query(...)
42
- end
40
+ alias_method :sql, :query
43
41
 
44
42
  def sql!(stmt, *args, **, &)
45
43
  puts "\n==[ SQL statement ]==\n\n", stmt.strip, ";"
@@ -57,7 +55,7 @@ def display(name, data, show, uniq, tots)
57
55
  puts "\n#{fill} #{name}\n#{fill} #{line}\n"
58
56
  data.each {|cnt, val| puts "%*d %s" % [wide, cnt, val || "NULL"] }
59
57
  puts "#{fill} -----\n"
60
- puts "%*d shown (top %d)" % [wide, rows, rows] if show
58
+ puts "%*d shown (top %d)" % [wide, seen, rows] if show
61
59
  puts "%*d total (all %d)" % [wide, tots, uniq]
62
60
  end
63
61
 
@@ -78,7 +76,7 @@ if want.empty?
78
76
  end
79
77
 
80
78
  want.each do |name|
81
- sort = abcd ? "" : "cnt desc,"
79
+ sort = natu ? "" : "cnt desc,"
82
80
  stmt = show ? "limit #{show}" : ""
83
81
  data = conn.sql(<<~"" + stmt).to_a
84
82
  select
@@ -95,15 +93,9 @@ want.each do |name|
95
93
  -if(regexp_like(`#{name}`, '^\\\\d'), regexp_instr(`#{name}`, '[^\\\\d]'), null) desc,
96
94
  `#{name}` is null, `#{name}`
97
95
 
98
- uniq = conn.sql(<<~"").to_a[0][0]
99
- select
100
- count(distinct(ifnull(`#{name}`,0)))
101
- from
102
- `#{tabl}`
103
- #{filt}
104
-
105
- tots = conn.sql(<<~"").to_a[0][0]
96
+ uniq, tots = conn.sql(<<~"").to_a[0]
106
97
  select
98
+ count(distinct(ifnull(`#{name}`,0))),
107
99
  count(ifnull(`#{name}`,0))
108
100
  from
109
101
  `#{tabl}`
data/bin/slyce3 CHANGED
@@ -9,7 +9,7 @@
9
9
  # wget https://github.com/nalgeon/sqlean/releases/download/0.19.3/sqlean-macos-arm64.zip
10
10
  # unzip sqlean-macos-arm64.zip regexp.dylib
11
11
 
12
- VERSION="0.9.8"
12
+ VERSION="1.0.0"
13
13
 
14
14
  STDOUT.sync = true
15
15
 
@@ -24,21 +24,21 @@ tabl = nil
24
24
  OptionParser.new.instance_eval do
25
25
  @banner = "usage: #{program_name} [options] <database> <table>"
26
26
 
27
- on "-a", "--alpha" , "Sort alphabetically, not numerically"
28
27
  on "-c", "--columns" , "Display column names and quit"
29
28
  on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
29
+ on "-n", "--natural" , "Sort naturally, not numerically"
30
30
  on "-r", "--regexp <path>" , "Path to the sqlean/regexp extension"
31
31
  on "-s", "--show <count>" , "Show this many values", Integer
32
32
  on "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{VERSION}"; end
33
- on "-w", "--where <cond>" , "Filter rows (eg - 'age=33,Name=/[BW]ill/i,color=\"\"'"
33
+ on "-w", "--where <cond>" , "Where clause (eg - 'age>50 and state='AZ')"
34
34
  on "-x", "--extract <col1,col2,...>", "Comma separated list of columns to extract"
35
35
 
36
36
  self
37
37
  end.parse!(into: opts={}) rescue abort($!.message)
38
38
 
39
- abcd = opts[:alpha]
40
39
  filt = opts[:where] and filt = "where\n #{filt}"
41
- regx = opts[:regexp] || Dir["{,sqlean}/regexp.{dll,dylib,so}"].first
40
+ natu = opts[:natural]
41
+ regx = opts[:regexp] || Dir["{.,sqlean}/regexp.{dll,dylib,so}"].first
42
42
  show = opts[:show]
43
43
  want = opts[:extract].to_s.downcase.split(",")
44
44
 
@@ -50,9 +50,7 @@ regx && File.exist?(regx) or abort "no regexp extension found#{regx ? " at '#{r
50
50
  # ==[ Helpers ]==
51
51
 
52
52
  class Extralite::Database
53
- def sql(...)
54
- query_ary(...)
55
- end
53
+ alias_method :sql, :query_ary
56
54
 
57
55
  def sql!(stmt, *args, **, &)
58
56
  puts "\n==[ SQL statement ]==\n\n", stmt.strip, ";"
@@ -70,7 +68,7 @@ def display(name, data, show, uniq, tots)
70
68
  puts "\n#{fill} #{name}\n#{fill} #{line}\n"
71
69
  data.each {|cnt, val| puts "%*d %s" % [wide, cnt, val || "NULL"] }
72
70
  puts "#{fill} -----\n"
73
- puts "%*d shown (top %d)" % [wide, rows, rows] if show
71
+ puts "%*d shown (top %d)" % [wide, seen, rows] if show
74
72
  puts "%*d total (all %d)" % [wide, tots, uniq]
75
73
  end
76
74
 
@@ -91,7 +89,7 @@ if want.empty?
91
89
  end
92
90
 
93
91
  want.each do |name|
94
- sort = abcd ? "" : "cnt desc,"
92
+ sort = natu ? "" : "cnt desc,"
95
93
  stmt = show ? "limit #{show}" : ""
96
94
  data = conn.sql(<<~"" + stmt).to_a
97
95
  select
@@ -109,15 +107,9 @@ want.each do |name|
109
107
  `#{name}` is null, `#{name}`
110
108
  collate nocase
111
109
 
112
- uniq = conn.sql(<<~"").to_a[0][0]
113
- select
114
- count(distinct(ifnull(`#{name}`,0)))
115
- from
116
- `#{tabl}`
117
- #{filt}
118
-
119
- tots = conn.sql(<<~"").to_a[0][0]
110
+ uniq, tots = conn.sql(<<~"").to_a[0]
120
111
  select
112
+ count(distinct(ifnull(`#{name}`,0))),
121
113
  count(ifnull(`#{name}`,0))
122
114
  from
123
115
  `#{tabl}`
data/slyce.gemspec CHANGED
@@ -11,6 +11,6 @@ Gem::Specification.new do |s|
11
11
  s.license = "MIT"
12
12
  s.files = `git ls-files`.split("\n") - %w[.gitignore]
13
13
  s.executables = `cd bin && git ls-files .`.split("\n")
14
- s.add_runtime_dependency "extralite-bundle", "~> 1.2.5"
14
+ s.add_runtime_dependency "extralite-bundle", "~> 1.25"
15
15
  s.add_runtime_dependency "mysql2", "~> 0.5"
16
16
  end
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: 0.9.8
4
+ version: 1.0.0
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-03-11 00:00:00.000000000 Z
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: extralite-bundle
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.5
19
+ version: '1.25'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.5
26
+ version: '1.25'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement