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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f8c020988e2d5df3aa710ce88fe4d92a2a754363d924a580fcc31b138330258
4
- data.tar.gz: b6ee155b7bfb819baa21fac27c8561a3e1332bd9677a081abbe811bbb45c7973
3
+ metadata.gz: 4bd731f2fb8604116f9baf947e8e0b5f5e8bd1b252773864f5a76e9c4b52126d
4
+ data.tar.gz: 82c364cc76d5921e49197c410d05a919e8b71a96d0499827b0546bf402c401ae
5
5
  SHA512:
6
- metadata.gz: 16d876542942fd0a0e1982dee1e7bf94ccd7bf8c8f4e3bb5310588a2f4587a3abe6d56fb101e1e1352c12225de507d46c18fa6b9109b2328079a999142479fa9
7
- data.tar.gz: 6d135e37aa6151b68552a5c9f32f3cc1f1fef20a3f26695c9a033a09e0541a31a60de9b2fac33aea4c69e89a1acff54296264ba8435e9fecdaed5dcd5ee868fb
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
 
@@ -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 and key" if key.nil?
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
- next unless k.include? key
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.0
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: 2023-12-21 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake