googlesheets 0.6.3 → 0.6.4

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 +16 -4
  3. data/lib/googlesheets.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 337343bcb13d2a791f5aee8a239ce9f6fb176d9844da5d2d672efd98d21974d5
4
- data.tar.gz: 68006ba26a382e5599a95822731e55261b7bb10b871c3536ecf4a2f0671d4755
3
+ metadata.gz: 52c14fb11d7e85e0466fa150a46b7403bfba5f4693e7332130536e60082c62c1
4
+ data.tar.gz: f487d35ebd512ecec19676c08471bc6f7155e6e937dc2dc5106b1e5e99569402
5
5
  SHA512:
6
- metadata.gz: 250b28e880607001b70f71a1f417325cd73c301fe4cad19af54e390f17e08630dd9e7a44a2aaa537646d64c2bc8e0571aeadda02e3929561b88232f581700e04
7
- data.tar.gz: 3e302a8611cd632225afac79f038ef000d3ea286e872de931640d43786b3de2acd7c325e9540a932be9b02dc6fc456f03b7dfb2e29092c0fa65703499990e9ff
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 "-v", "--version" , "Show version number" do Kernel.abort "#{program_name} #{version}"; 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
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
@@ -19,7 +19,7 @@ class Object
19
19
  end
20
20
 
21
21
  class GoogleSheets
22
- VERSION = "0.6.3"
22
+ VERSION = "0.6.4"
23
23
 
24
24
  attr_accessor :api
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlesheets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve