googlesheets 0.7.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/shat +19 -5
  3. data/lib/googlesheets.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daf8f693ecd8d71a27765777260113aa6983861deb3821e6b0a2c660a55b2752
4
- data.tar.gz: 61b86c3fedfdd39706d6ca0f5bc5c3510ff1acbb81474a94fdc2f67bd46d9008
3
+ metadata.gz: e14329dba7ace514cf5f694dd2cd3560c0c4d3519a763817bce352ef1411559c
4
+ data.tar.gz: 9f050792290e7a7c1317586ff8c3633474d538ad1cb60e5d8274f16cc38ac2da
5
5
  SHA512:
6
- metadata.gz: c7dbdc0f9217c727964938abb9941e3793226193c4bbc2e2b8991d06bae7f10c85f9ed30962aa250d4fa98a53bdfae9b06e93c6ed453a8a31a4091ba3eb2b55c
7
- data.tar.gz: 961beb15ab4c331098345ae559ef80e88e43d5e336e199b549294c5eeb3d7a7b61311f85f129ea8bd0969f7eae5c927cc59d7dbd0e261e810043920507ee35c1
6
+ metadata.gz: f1aaaa1d70f7695e9d9a3d3b5a04ca24ff894189833bc741d668abd206c61c3677cb51e198f6c4a073819b297ce676bb3c7f29a4c0635d48eeee0c4a9c12ee8a
7
+ data.tar.gz: 450e3d068618326be503baf436babda07bef675a7067a55d4c44c817524fef3fa48e3b81159ac1cc3b96dbc595e32515a99572f1a69c6b4adbe8445deee40994
data/bin/shat CHANGED
@@ -16,11 +16,16 @@ trap("INT" ) { abort "\n" }
16
16
  OptionParser.new.instance_eval do
17
17
  @banner = "usage: #{program_name} [options] <url>"
18
18
 
19
- on "-f", "--fill" , "Fill each row with as many cells as the first row"
20
- on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
21
- on "-t", "--trim" , "Trim leading and trailing whitespace"
22
- on "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{GoogleSheets::VERSION}"; end
19
+ on "-f", "--fill" , "Fill each row with as many cells as the first row"
20
+ on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
21
+ on "-s", "--strip" , "Strip leading and trailing whitespace"
22
+ on "-v", "--version", "Show version number" do Kernel.abort "#{program_name} #{GoogleSheets::VERSION}"; end
23
23
 
24
+ on "--csv" , "Output comma separated data (default)"
25
+ on "--psv" , "Output pipe separated data"
26
+ on "--tsv" , "Output tab separated data"
27
+
28
+ Kernel.abort to_s if ARGV.empty?
24
29
  self
25
30
  end.parse!(into: opts={}) rescue abort($!.message)
26
31
 
@@ -28,6 +33,15 @@ fill = opts[:fill]
28
33
  link = ARGV.shift or abort("no url provided")
29
34
  trim = opts[:trim]
30
35
 
36
+ # handle separators
37
+ xcsv = opts[:csv ]
38
+ xpsv = opts[:psv ]
39
+ xtsv = opts[:tsv ]
40
+ hits = [xcsv, xpsv, xtsv].compact.size
41
+ hits > 1 and abort "only one of csv, psv, or tsv allowed"
42
+ xcsv = true if hits.zero?
43
+ seps = xtsv ? "\t" : xpsv ? "|" : ","
44
+
31
45
  goog = GoogleSheets.new(link)
32
46
  rows = goog.sheet_read
33
47
  rows.each {|cols| cols.map(&:strip!) } if trim
@@ -41,4 +55,4 @@ if fill and need = rows[0]&.size
41
55
  end
42
56
  end
43
57
 
44
- Censive.writer {|csv| rows.each {|row| csv << row }}
58
+ Censive.writer(sep: seps) {|csv| rows.each {|row| csv << row }}
data/lib/googlesheets.rb CHANGED
@@ -19,7 +19,7 @@ class Object
19
19
  end
20
20
 
21
21
  class GoogleSheets
22
- VERSION = "0.7.0"
22
+ VERSION = "0.8.1"
23
23
 
24
24
  attr_accessor :api
25
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlesheets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.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-03-27 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client