google_drive_dotenv 0.3.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/google_drive_dotenv.gemspec +2 -0
- data/lib/google_drive_dotenv/cli.rb +50 -10
- data/lib/google_drive_dotenv/version.rb +1 -1
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b9031fb2ec54382d971e6a7aef38ce233ef3c11432131bcf30fb4e6236205b
|
4
|
+
data.tar.gz: bb35aaecb7d879cd670457c5a7400689afc270cafb61970962d1d3e0d9632ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
```
|
data/google_drive_dotenv.gemspec
CHANGED
@@ -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(
|
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
|
-
|
50
|
+
auth_config = GoogleDrive::Config.new(config_path)
|
51
|
+
auth_config.scope ||= GoogleDrive::Session::DEFAULT_SCOPE
|
16
52
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
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.
|
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:
|
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.
|
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: []
|