slyce 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/slyce +9 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b35094f0096060fd354165e0c24331549ae85eb73b3568c2ee25d318b4dada2
4
- data.tar.gz: 4354a7b22ab2ba4628e85f34b2bf7275873d044c10dd16c4a624ca31ae61fed1
3
+ metadata.gz: 057777cd908c785455b4ab4fc4c20b3aa545901bf552d0d1d568583424606103
4
+ data.tar.gz: 0cd8af51f8c809244bf308157d02adf5bcd4d0a6038acd2cb0abd73e9f609bd3
5
5
  SHA512:
6
- metadata.gz: a4ea7f796286ed343fef00dc1401ebf8960301975fbe40414834ae84c52162344f14521b5b2aea8073ff73aaa5122514552fa6d262246d2b738e95811d9747ab
7
- data.tar.gz: 6f6fd02773c11cf9c25b788657f452fa310d6fe997fcf3aae3a7dfb6a4fa2fe2c2896ced81f13370db8b80c1252e23cbd84bcb26b22f3c5fad71fb62151847b2
6
+ metadata.gz: 10e034e61797fa5cbad886553f00ff4017e4c0a8a78d473ec2790ebe179a6d914f2194ca1d4c6283516fe39c69f8532ace24be807591431c2a52b1b202c48b78
7
+ data.tar.gz: 1115cb037df547637f2c0d3f67b41297c27e37fba4d4f12d8cfe0780c2fa962d9d75d7527a1dc232f22b30c0d5cf6ef60221b3113b08b4eae31a7a005218ef41
data/bin/slyce CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  STDOUT.sync = true
4
4
 
5
- VERSION="0.9.0"
5
+ VERSION="0.9.1"
6
6
 
7
7
  require "bundler/setup"
8
8
  require "mysql2"
@@ -21,6 +21,7 @@ OptionParser.new.instance_eval do
21
21
  on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
22
22
  on "-s", "--show <count>" , "Show this many values", Integer
23
23
  on "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{VERSION}"; end
24
+ on "-w", "--where <cond>" , "Filter rows (eg - 'age=33,Name=/[BW]ill/i,color=\"\"'"
24
25
  on "-x", "--extract <col1,col2,...>", "Comma separated list of columns to extract"
25
26
 
26
27
  self
@@ -29,6 +30,7 @@ end.parse!(into: opts={}) rescue abort($!.message)
29
30
  abcd = opts[:alpha]
30
31
  show = opts[:show]
31
32
  want = opts[:extract].to_s.downcase.split(",")
33
+ filt = opts[:where] and filt = "where\n #{filt}"
32
34
 
33
35
  dbas ||= ARGV.shift or Kernel.abort "no database given"
34
36
  tabl ||= ARGV.shift or Kernel.abort "no table given"
@@ -52,8 +54,8 @@ def display(name, data, show, uniq, tots)
52
54
  puts "\n#{fill} #{name}\n#{fill} #{line}\n"
53
55
  data.each {|cnt, val| puts "%*d %s" % [wide, cnt, val || "NULL"] }
54
56
  puts "#{fill} -----\n"
55
- puts "%*d shown (top #{rows})" % [wide, rows] if show
56
- puts "%*d total (all #{uniq})" % [wide, tots]
57
+ puts "%*d shown (top %d)" % [wide, rows, rows] if show
58
+ puts "%*d total (all %d)" % [wide, tots, uniq]
57
59
  end
58
60
 
59
61
  # ==[ Let 'er rip! ]==
@@ -77,6 +79,7 @@ want.each do |name|
77
79
  `#{name}` as val
78
80
  from
79
81
  `#{tabl}`
82
+ #{filt}
80
83
  group by
81
84
  val
82
85
  order by #{sort}
@@ -90,12 +93,14 @@ want.each do |name|
90
93
  count(distinct(ifnull(`#{name}`,0)))
91
94
  from
92
95
  `#{tabl}`
96
+ #{filt}
93
97
 
94
98
  tots = conn.query(<<~"").to_a[0][0]
95
99
  select
96
- count(`#{name}`)
100
+ count(ifnull(`#{name}`,0))
97
101
  from
98
102
  `#{tabl}`
103
+ #{filt}
99
104
 
100
105
  display(name, data, show, uniq, tots)
101
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slyce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve