googlesheets 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/shat +16 -4
- data/lib/googlesheets.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52c14fb11d7e85e0466fa150a46b7403bfba5f4693e7332130536e60082c62c1
|
4
|
+
data.tar.gz: f487d35ebd512ecec19676c08471bc6f7155e6e937dc2dc5106b1e5e99569402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff5b9ef469d0822e598e72ad9a3eb557f913d8f50c48f23d60169092c14cfff1edf1473470ec0bf169d4ebbd4050f87e8114dab38d711789093111d1ecd7c96
|
7
|
+
data.tar.gz: fab7b3b54481bbef23d835bd4b887247badb779bf3b373cbe90ac1652a873a32ca78c3bb1b9086af38c1a3d91e61335ed8224626b10339d53dc403ec3ebaf90c
|
data/bin/shat
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
version="0.0.1"
|
4
|
-
|
5
3
|
STDOUT.sync = true
|
6
4
|
|
7
5
|
begin
|
8
|
-
require "censive"
|
6
|
+
require "censive"
|
9
7
|
rescue LoadError
|
10
8
|
abort "#{File.basename($0)} needs another gem, run 'gem install censive'"
|
11
9
|
end
|
@@ -18,15 +16,29 @@ trap("INT" ) { abort "\n" }
|
|
18
16
|
OptionParser.new.instance_eval do
|
19
17
|
@banner = "usage: #{program_name} [options] <url>"
|
20
18
|
|
19
|
+
on "-f", "--fill" , "Fill each row with as many cells as the first row"
|
21
20
|
on "-h", "--help" , "Show help and command usage" do Kernel.abort to_s; end
|
22
|
-
on "-
|
21
|
+
on "-t", "--trim" , "Trim leading and trailing whitespace"
|
22
|
+
on "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{GoogleSheets::VERSION}"; end
|
23
23
|
|
24
24
|
self
|
25
25
|
end.parse!(into: opts={}) rescue abort($!.message)
|
26
26
|
|
27
|
+
fill = opts[:fill]
|
27
28
|
link = ARGV.shift or abort("no url provided")
|
29
|
+
trim = opts[:trim]
|
28
30
|
|
29
31
|
goog = GoogleSheets.new(link)
|
30
32
|
rows = goog.sheet_read
|
33
|
+
rows.each {|cols| cols.map(&:strip!) } if trim
|
34
|
+
|
35
|
+
if fill and need = rows[0]&.size
|
36
|
+
rows.each_with_index do |cols, i|
|
37
|
+
if (size = cols.size) != need
|
38
|
+
abort "row #{i + 1} has more columns than the header row" if size > need
|
39
|
+
cols.concat(Array.new(need - size, ""))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
31
43
|
|
32
44
|
Censive.writer {|csv| rows.each {|row| csv << row }}
|
data/lib/googlesheets.rb
CHANGED