qa_cube 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 7536b4f77c7471067b2bcd91ad4f89b701979ce7
4
- data.tar.gz: 0cb0b861e469145aa4d43d51481a33992438677c
3
+ metadata.gz: 920a047ff624eaad42076bf7759b45dedc6aceaa
4
+ data.tar.gz: cbc1016e96d664622a6188d2e84512fbaa2386e9
5
5
  SHA512:
6
- metadata.gz: fa42f5185aeb99d459d82abcb9804e748c8be2e40655dd9b2a1163625f100770394ca56bee2c16411bae5e0dda7e0b68f01c4c13d325e9318af32c309dac8e75
7
- data.tar.gz: ebd8eeb13d7b005cc5e85e68ade6c176d4ecbdc185bd25fdccf43996e81dc45a78eff97cb27de7b27854cba9516d38e477064d15b79f93fe29a36ea2021ebbe7
6
+ metadata.gz: 20481caae32dfb5f2e99e81a9e3f7514888b99983e6f38cb527e068508cdff81cc207cce5372b2d9137eec857312a40cde54a244bf69c867d9427b36c655363c
7
+ data.tar.gz: 007479dd668a6a7edb8f9ba145edfb9e567fd704302101f13e80afdf6029fd88da9b72c8ee6b1a41272d005d1ca106b2596ad8089ca119bb7cfd2e2e72bf924d
data/CREDIT ADDED
@@ -0,0 +1 @@
1
+ Since this code is mostly from Google's developer examples, it falls under https://opensource.google.com/docs/thirdparty/licenses/#GoogleAuthoredCode . Anything I've added on top of it is "public domain/free for any use".
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ qa_cube (0.0.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.15)
16
+ qa_cube!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.15.4
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Since this code is mostly from Google's developer examples, it falls under https://opensource.google.com/docs/thirdparty/licenses/#GoogleAuthoredCode . Anything I've added on top of it is "public domain/free for any use".
data/lib/.gitignore ADDED
@@ -0,0 +1 @@
1
+ client_secret.json
data/lib/appender.rb ADDED
@@ -0,0 +1,55 @@
1
+ require "qa_cube/version"
2
+ require 'google/apis/sheets_v4'
3
+ require 'googleauth'
4
+ require 'googleauth/stores/file_token_store'
5
+
6
+ require 'fileutils'
7
+
8
+
9
+ module QACube
10
+ class SheetsAppender
11
+
12
+ OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'
13
+ APPLICATION_NAME = 'Google Sheets API Test Result Appender'
14
+ CREDENTIALS_PATH = File.join(Dir.home, '.credentials','sheetsappender.yaml')
15
+ SCOPE = Google::Apis::SheetsV4::AUTH_SPREADSHEETS
16
+
17
+ def initialize(sheet_name:, spreadsheet_id:, range:, verbose: nil, client_secrets_path:)
18
+ @verbose ||= verbose
19
+ if @verbose.nil?
20
+ @verbose = false
21
+ end
22
+ @client_secrets_path = client_secrets_path
23
+ @service = Google::Apis::SheetsV4::SheetsService.new
24
+ @service.authorization = authorize
25
+ @spreadsheet_id = spreadsheet_id
26
+ @sheet_name = sheet_name
27
+ @range = "\'#{sheet_name}\'!#{range}"
28
+ end
29
+
30
+ def append(values:)
31
+ request_body = Google::Apis::SheetsV4::ValueRange.new({values: values})
32
+ response = @service.append_spreadsheet_value(@spreadsheet_id, @range, request_body, value_input_option: "USER_ENTERED")
33
+ if @verbose
34
+ puts response.to_json
35
+ end
36
+ end
37
+
38
+ def authorize
39
+ FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
40
+ client_id = Google::Auth::ClientId.from_file(@client_secrets_path)
41
+ token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
42
+ authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
43
+ user_id = 'default'
44
+ credentials = authorizer.get_credentials(user_id)
45
+ if credentials.nil?
46
+ url = authorizer.get_authorization_url(base_url: OOB_URI)
47
+ puts "First time auth URL"
48
+ puts url
49
+ code = gets
50
+ credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)
51
+ end
52
+ credentials
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,54 @@
1
+ require "qa_cube/version"
2
+ require 'google/apis/sheets_v4'
3
+ require 'googleauth'
4
+ require 'googleauth/stores/file_token_store'
5
+
6
+ require 'fileutils'
7
+
8
+ module QaCube
9
+ class SheetsAppender
10
+
11
+ OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'
12
+ APPLICATION_NAME = 'Google Sheets API Test Result Appender'
13
+ CREDENTIALS_PATH = File.join(Dir.home, '.credentials','sheetsappender.yaml')
14
+ SCOPE = Google::Apis::SheetsV4::AUTH_SPREADSHEETS
15
+
16
+ def initialize(sheet_name:, spreadsheet_id:, range:, verbose: nil, client_secrets_path:)
17
+ @verbose ||= verbose
18
+ if @verbose.nil?
19
+ @verbose = false
20
+ end
21
+ @client_secrets_path = client_secrets_path
22
+ @service = Google::Apis::SheetsV4::SheetsService.new
23
+ @service.authorization = authorize
24
+ @spreadsheet_id = spreadsheet_id
25
+ @sheet_name = sheet_name
26
+ @range = "\'#{sheet_name}\'!#{range}"
27
+ end
28
+
29
+ def append(values:)
30
+ request_body = Google::Apis::SheetsV4::ValueRange.new({values: values})
31
+ response = @service.append_spreadsheet_value(@spreadsheet_id, @range, request_body, value_input_option: "USER_ENTERED")
32
+ if @verbose
33
+ puts response.to_json
34
+ end
35
+ end
36
+
37
+ def authorize
38
+ FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
39
+ client_id = Google::Auth::ClientId.from_file(@client_secrets_path)
40
+ token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
41
+ authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
42
+ user_id = 'default'
43
+ credentials = authorizer.get_credentials(user_id)
44
+ if credentials.nil?
45
+ url = authorizer.get_authorization_url(base_url: OOB_URI)
46
+ puts "First time auth URL"
47
+ puts url
48
+ code = gets
49
+ credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)
50
+ end
51
+ credentials
52
+ end
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module QaCube
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/qa_cube.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Bennett Talpers"]
10
10
  spec.email = ["bennett.talpers@gmail.com"]
11
11
 
12
- spec.summary = %q{Allows a user to easily append data to a Google Sheets sheet.}
13
- spec.description = %q{Code taken from the examples found on https://developers.google.com/sheets/api/samples and parameterized, so it can be plugged & easily to automated QA projects.}
12
+ spec.summary = %q{A collection of QA tools.}
13
+ spec.description = %q{A collection of QA tooling. Currently only includes sheetsappender, which is a tool for appending data to an existing google sheets page}
14
14
  spec.homepage = "https://github.com/btalpers/qa_cube"
15
15
 
16
16
  if spec.respond_to?(:metadata)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa_cube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bennett Talpers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-02 00:00:00.000000000 Z
11
+ date: 2018-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,21 +66,26 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.6.2
69
- description: Code taken from the examples found on https://developers.google.com/sheets/api/samples
70
- and parameterized, so it can be plugged & easily to automated QA projects.
69
+ description: A collection of QA tooling. Currently only includes sheetsappender, which
70
+ is a tool for appending data to an existing google sheets page
71
71
  email:
72
72
  - bennett.talpers@gmail.com
73
73
  executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ".gitignore"
77
+ - CREDIT
78
78
  - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE
79
81
  - README.md
80
82
  - Rakefile
81
83
  - bin/console
82
84
  - bin/setup
85
+ - lib/.gitignore
86
+ - lib/appender.rb
83
87
  - lib/qa_cube.rb
88
+ - lib/qa_cube/appender.rb
84
89
  - lib/qa_cube/version.rb
85
90
  - qa_cube.gemspec
86
91
  homepage: https://github.com/btalpers/qa_cube
@@ -106,5 +111,5 @@ rubyforge_project:
106
111
  rubygems_version: 2.5.1
107
112
  signing_key:
108
113
  specification_version: 4
109
- summary: Allows a user to easily append data to a Google Sheets sheet.
114
+ summary: A collection of QA tools.
110
115
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/