rbbt-util 5.41.0 → 5.41.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/tsv.rb +1 -0
- data/share/rbbt_commands/tsv/get +20 -4
- 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: 4bd731f2fb8604116f9baf947e8e0b5f5e8bd1b252773864f5a76e9c4b52126d
|
4
|
+
data.tar.gz: 82c364cc76d5921e49197c410d05a919e8b71a96d0499827b0546bf402c401ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 655e499e17ea4806f278ecaf83521c200aa978ace61c27f5aac0490bc99a40cac42498f323155ee3c547a2a98d23271a8fa6d3b424180c87b249b50219fb7235
|
7
|
+
data.tar.gz: c3ef8cc5790db9bb5df6d0853542355b267e2f8f26c4b6bc8305729b793eff8832a33479a53339605bcaf8b450a500dc58a9bd5557e1d993f8c8b72228ab1793
|
data/lib/rbbt/tsv.rb
CHANGED
@@ -69,6 +69,7 @@ module TSV
|
|
69
69
|
options = TSV.str2options(options) if String === options and options.include? "~"
|
70
70
|
options ||= {}
|
71
71
|
options[:type] ||= type unless type.nil?
|
72
|
+
options[:zipped] = true if options[:one2one]
|
72
73
|
|
73
74
|
persist_options = Misc.pull_keys options, :persist
|
74
75
|
|
data/share/rbbt_commands/tsv/get
CHANGED
@@ -7,9 +7,10 @@ options = SOPT.setup <<EOF
|
|
7
7
|
|
8
8
|
Query a TSV value
|
9
9
|
|
10
|
-
$ rbbt tsv get [options] <filename.tsv|-> <key>
|
10
|
+
$ rbbt tsv get [options] <filename.tsv|-> [<key>]
|
11
11
|
|
12
|
-
Use - to read from STDIN
|
12
|
+
Use - to read from STDIN, 'key' can be the key string or a number representing
|
13
|
+
its position. If not specified 'key' defaults to 0, the first entry.
|
13
14
|
|
14
15
|
-tch--tokyocabinet File is a tokyocabinet hash database
|
15
16
|
-tcb--tokyocabinet_bd File is a tokyocabinet B database
|
@@ -26,7 +27,7 @@ rbbt_usage and exit 0 if options[:help]
|
|
26
27
|
|
27
28
|
file, key = ARGV
|
28
29
|
|
29
|
-
raise ParameterException, "Please specify file
|
30
|
+
raise ParameterException, "Please specify file" if file.nil?
|
30
31
|
|
31
32
|
file = STDIN if file == '-'
|
32
33
|
|
@@ -48,7 +49,15 @@ key_field = options[:key_field]
|
|
48
49
|
fields = fields.split(/[,|]/, -1) unless fields.nil?
|
49
50
|
|
50
51
|
if TSV === tsv
|
52
|
+
case key
|
53
|
+
when nil
|
54
|
+
key = tsv.keys.first if key.nil?
|
55
|
+
when /^\d+$/
|
56
|
+
key = tsv.keys[key.to_i] unless tsv.include?(key)
|
57
|
+
end
|
58
|
+
|
51
59
|
v = tsv[key]
|
60
|
+
|
52
61
|
fields ||= tsv.fields
|
53
62
|
puts Log.color(:blue, "Key: #{ key }")
|
54
63
|
if fields
|
@@ -72,8 +81,15 @@ end
|
|
72
81
|
parser = TSV::Parser.new tsv, :key_field => key_field, :fields => fields, :type => options[:type], :header_hash => options[:header_hash], :sep => options[:sep]
|
73
82
|
fields ||= parser.fields
|
74
83
|
|
84
|
+
i = 0
|
75
85
|
TSV.traverse(parser) do |k,v|
|
76
|
-
|
86
|
+
if key== "#{i}"
|
87
|
+
key = k.first
|
88
|
+
elsif key.nil?
|
89
|
+
key = k.first
|
90
|
+
end
|
91
|
+
i += 1
|
92
|
+
next unless k.include?(key)
|
77
93
|
k = k.first if Array === k
|
78
94
|
puts Log.color(:blue, "Key: #{ k }")
|
79
95
|
if fields
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.41.
|
4
|
+
version: 5.41.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|