google_drive_dotenv 0.3.0 → 0.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f1f1301b0ccab8d3d313e1191bd6981b57df72b4ceda55de8def0bc2838c375
4
- data.tar.gz: 0acfbde9b338fd5ec46a50994e8774c7120ba8fec169255bc06c64ea88980b0e
3
+ metadata.gz: 17b9031fb2ec54382d971e6a7aef38ce233ef3c11432131bcf30fb4e6236205b
4
+ data.tar.gz: bb35aaecb7d879cd670457c5a7400689afc270cafb61970962d1d3e0d9632ebd
5
5
  SHA512:
6
- metadata.gz: 32c420b15ad226514c3897e2bd19f3f4232f558c85ee811d7724198b43ba503ebca862d2546c5f894ce58333400c7e54ec91bfef119fda193822e2046ce9eb70
7
- data.tar.gz: 93115793354066506019e246fd38e768b3ef5dee6370c2b0b59a02b9beb9f6bbd5c49b3b7e9a80d9d53e208bfc14f261215dac7db03b6ee9128f5601de86af43
6
+ metadata.gz: 8bd12718ff1e9e277340350619ab19f11d2d07b5b8f33ff71243b7e256d424cdab5747d94025cecf794d7dac0a77eb9b002e67dc520012ce7af1c1a06c634989
7
+ data.tar.gz: c5351befb99f7460e141240041c71c6eef7cfa0062d275fce669607eac7bd30dbe51e0ac6b9f7155c369ba2edf8f6e70a3593c613b1f4bc6042b7825a5d7e67e
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # GoogleDriveDotenv
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/google_drive_dotenv`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
3
  ## Usage
6
4
  ```
7
5
  Commands:
@@ -14,6 +12,8 @@ Usage:
14
12
  Options:
15
13
  o, [--output=OUTPUT]
16
14
  # Default: .env
15
+ c, [--config=CONFIG]
16
+ # Default: ~/google_config.json
17
17
 
18
18
  Export Spreadsheet to env file
19
19
  ```
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency 'thor'
30
30
  spec.add_dependency 'google_drive'
31
+ spec.add_dependency 'sinatra'
32
+ spec.add_dependency 'launchy'
31
33
 
32
34
  spec.add_development_dependency "bundler", "~> 2.0"
33
35
  spec.add_development_dependency "rake", "~> 13.0"
@@ -1,27 +1,67 @@
1
1
  require 'thor'
2
2
  require 'google_drive'
3
+ require 'sinatra/base'
4
+ require 'launchy'
5
+
3
6
 
4
7
  module GoogleDriveDotenv
8
+ class App < Sinatra::Base
9
+ set :server, %w(webrick)
10
+
11
+ class << self
12
+ attr_accessor :credentials, :output, :key
13
+
14
+ def export_env(authorization_code)
15
+ credentials.code = authorization_code
16
+ credentials.fetch_access_token!
17
+
18
+ session = GoogleDrive::Session.from_credentials(credentials)
19
+
20
+ sheet = session.spreadsheet_by_key(key).worksheets[0]
21
+ File.open(output, 'wb') do |file|
22
+ (1..sheet.num_rows).each do |row|
23
+ key = sheet[row, 1]
24
+ value = sheet[row, 2]
25
+ file.puts([key, value].join('='))
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+ get '/' do
33
+ self.class.export_env(params['code'])
34
+ body "Successfully export env!"
35
+ self.class.quit!
36
+ end
37
+ end
38
+
5
39
  class CLI < Thor
6
40
  desc "export [key]", "Export Spreadsheet to env file"
7
41
  option "output", aliases: "o", type: :string, default: ".env"
42
+ option "config", aliases: "c", type: :string, default: "~/google_config.json"
8
43
  def export(key)
9
- config_path = File.expand_path("~/google_config.json")
44
+ config_path = File.expand_path(options['config'])
10
45
 
11
46
  unless File.exist?(config_path)
12
47
  raise "Please put #{config_path}"
13
48
  end
14
49
 
15
- session = GoogleDrive::Session.from_config(config_path)
50
+ auth_config = GoogleDrive::Config.new(config_path)
51
+ auth_config.scope ||= GoogleDrive::Session::DEFAULT_SCOPE
16
52
 
17
- sheet = session.spreadsheet_by_key(key).worksheets[0]
18
- File.open(options['output'], 'wb') do |file|
19
- (1..sheet.num_rows).each do |row|
20
- key = sheet[row, 1]
21
- value = sheet[row, 2]
22
- file.puts([key, value].join('='))
23
- end
24
- end
53
+ credentials = Google::Auth::UserRefreshCredentials.new(
54
+ client_id: auth_config.client_id,
55
+ client_secret: auth_config.client_secret,
56
+ scope: auth_config.scope,
57
+ redirect_uri: 'http://localhost:4567',
58
+ )
59
+
60
+ Launchy.open(credentials.authorization_uri)
61
+ App.credentials = credentials
62
+ App.output = options['output']
63
+ App.key = key
64
+ App.run!
25
65
  end
26
66
  end
27
67
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleDriveDotenv
2
- VERSION = "0.3.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_drive_dotenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - adorechic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2022-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: launchy
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +138,7 @@ metadata:
110
138
  homepage_uri: https://github.com/adorechic/google_drive_dotenv
111
139
  source_code_uri: https://github.com/adorechic/google_drive_dotenv
112
140
  changelog_uri: https://github.com/adorechic/google_drive_dotenv/blob/master/CHANGELOG.md
113
- post_install_message:
141
+ post_install_message:
114
142
  rdoc_options: []
115
143
  require_paths:
116
144
  - lib
@@ -125,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
153
  - !ruby/object:Gem::Version
126
154
  version: '0'
127
155
  requirements: []
128
- rubygems_version: 3.1.2
129
- signing_key:
156
+ rubygems_version: 3.3.13
157
+ signing_key:
130
158
  specification_version: 4
131
159
  summary: Exports .env file from Google Spreadsheet
132
160
  test_files: []