googlesheets 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/bin/shat +16 -4
  4. data/lib/googlesheets.rb +8 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 337343bcb13d2a791f5aee8a239ce9f6fb176d9844da5d2d672efd98d21974d5
4
- data.tar.gz: 68006ba26a382e5599a95822731e55261b7bb10b871c3536ecf4a2f0671d4755
3
+ metadata.gz: daf8f693ecd8d71a27765777260113aa6983861deb3821e6b0a2c660a55b2752
4
+ data.tar.gz: 61b86c3fedfdd39706d6ca0f5bc5c3510ff1acbb81474a94fdc2f67bd46d9008
5
5
  SHA512:
6
- metadata.gz: 250b28e880607001b70f71a1f417325cd73c301fe4cad19af54e390f17e08630dd9e7a44a2aaa537646d64c2bc8e0571aeadda02e3929561b88232f581700e04
7
- data.tar.gz: 3e302a8611cd632225afac79f038ef000d3ea286e872de931640d43786b3de2acd7c325e9540a932be9b02dc6fc456f03b7dfb2e29092c0fa65703499990e9ff
6
+ metadata.gz: c7dbdc0f9217c727964938abb9941e3793226193c4bbc2e2b8991d06bae7f10c85f9ed30962aa250d4fa98a53bdfae9b06e93c6ed453a8a31a4091ba3eb2b55c
7
+ data.tar.gz: 961beb15ab4c331098345ae559ef80e88e43d5e336e199b549294c5eeb3d7a7b61311f85f129ea8bd0969f7eae5c927cc59d7dbd0e261e810043920507ee35c1
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
1
  # googlesheets
2
2
 
3
3
  Ruby gem for Google Sheets API
4
-
5
- ### NOTE: gem install google-api-client
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.7.0"
23
23
 
24
24
  attr_accessor :api
25
25
 
@@ -31,6 +31,13 @@ class GoogleSheets
31
31
  @json = opts[:credentials] || "credentials.json"
32
32
  @yaml = opts[:token ] || "token.yaml"
33
33
 
34
+ if !File.exist?(@json)
35
+ base = File.expand_path(File.join(ENV["HOME"], ".google"))
36
+ abort "unable to file Google API credentials" unless File.exist?(base)
37
+ @json = File.join(base, @json)
38
+ @yaml = File.join(base, @yaml)
39
+ end
40
+
34
41
  if opts[:debug] == true
35
42
  $stdout.sync = true
36
43
  Google::Apis.logger = Logger.new(STDERR)
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.6.3
4
+ version: 0.7.0
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-17 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.4.8
59
+ rubygems_version: 3.4.9
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Ruby library for Google Sheets