google_drive_dotenv 0.2.1 → 0.5.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.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/google_drive_dotenv.gemspec +2 -0
- data/lib/google_drive_dotenv/cli.rb +49 -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: e811d0accc2ca11709223a1ec703b3286e4f657c76baf17d14bba296670f25c0
|
4
|
+
data.tar.gz: 9ba49e5a2e6343c9cad4bd224828a2fb54628bc0d57eb01d7e29118be26f3ee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77d91698602cd71dc554c760b86e7285eae8083300ddeff055c89cdb9663b5f1073723605b1e2aff2c4b91850cd1544380256b755b81585d0e089321fd009e45
|
7
|
+
data.tar.gz: f7b1474735a4e084414a9f1c918911ccdcd70f489972415fa99c6e2f8d8d82c0f412da038e9970358a78007ed7a7b772680a78be786b0f133f9ed5473b2ac9ce
|
data/README.md
CHANGED
@@ -1,12 +1,20 @@
|
|
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
|
```
|
5
|
+
Commands:
|
6
|
+
google_drive_dotenv export [key] # Export Spreadsheet to env file
|
7
|
+
google_drive_dotenv help [COMMAND] # Describe available commands or one specific command
|
8
|
+
|
7
9
|
Usage:
|
8
10
|
google_drive_dotenv export [key]
|
9
11
|
|
12
|
+
Options:
|
13
|
+
o, [--output=OUTPUT]
|
14
|
+
# Default: .env
|
15
|
+
c, [--config=CONFIG]
|
16
|
+
# Default: ~/google_config.json
|
17
|
+
|
10
18
|
Export Spreadsheet to env file
|
11
19
|
```
|
12
20
|
|
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,26 +1,65 @@
|
|
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
|
+
class << self
|
10
|
+
attr_accessor :credentials, :output, :key
|
11
|
+
|
12
|
+
def export_env(authorization_code)
|
13
|
+
credentials.code = authorization_code
|
14
|
+
credentials.fetch_access_token!
|
15
|
+
|
16
|
+
session = GoogleDrive::Session.from_credentials(credentials)
|
17
|
+
|
18
|
+
sheet = session.spreadsheet_by_key(key).worksheets[0]
|
19
|
+
File.open(output, 'wb') do |file|
|
20
|
+
(1..sheet.num_rows).each do |row|
|
21
|
+
key = sheet[row, 1]
|
22
|
+
value = sheet[row, 2]
|
23
|
+
file.puts([key, value].join('='))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
get '/' do
|
31
|
+
self.class.export_env(params['code'])
|
32
|
+
body "Successfully export env!"
|
33
|
+
self.class.quit!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
5
37
|
class CLI < Thor
|
6
38
|
desc "export [key]", "Export Spreadsheet to env file"
|
39
|
+
option "output", aliases: "o", type: :string, default: ".env"
|
40
|
+
option "config", aliases: "c", type: :string, default: "~/google_config.json"
|
7
41
|
def export(key)
|
8
|
-
config_path = File.expand_path(
|
42
|
+
config_path = File.expand_path(options['config'])
|
9
43
|
|
10
44
|
unless File.exist?(config_path)
|
11
45
|
raise "Please put #{config_path}"
|
12
46
|
end
|
13
47
|
|
14
|
-
|
48
|
+
auth_config = GoogleDrive::Config.new(config_path)
|
49
|
+
auth_config.scope ||= GoogleDrive::Session::DEFAULT_SCOPE
|
15
50
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
51
|
+
credentials = Google::Auth::UserRefreshCredentials.new(
|
52
|
+
client_id: auth_config.client_id,
|
53
|
+
client_secret: auth_config.client_secret,
|
54
|
+
scope: auth_config.scope,
|
55
|
+
redirect_uri: 'http://localhost:4567',
|
56
|
+
)
|
57
|
+
|
58
|
+
Launchy.open(credentials.authorization_uri)
|
59
|
+
App.credentials = credentials
|
60
|
+
App.output = options['output']
|
61
|
+
App.key = key
|
62
|
+
App.run!
|
24
63
|
end
|
25
64
|
end
|
26
65
|
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.0
|
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: []
|