drive_env 0.4.0 → 0.4.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 +4 -4
- data/README.md +38 -0
- data/lib/drive_env/cli/spreadsheet.rb +22 -6
- data/lib/drive_env/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8a55c9e4871eb5653df12a3565c57e8b1b833da4705949e3fcb0acfd89d3a71
|
4
|
+
data.tar.gz: ef4b83412f6da3e8a0f15327eb8d6890a285a8754f466631dc37f17711cbb139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1923957903414ee3d4eba96bfd50f7498c9854beb0ab10d18a9716a4c6326a52ac897dcd10fa1269902b14be87cfa415d6f0bad8fd180cf8bf34d3dffd00cc6
|
7
|
+
data.tar.gz: 668f4b68f42e20910bac21c9cbd3cb8722b92f66a45083692c90515a11610259edba556f2ed57559f2187dc897a7ad61c37a255d0b1a0e1094ccd03f3e631ae1
|
data/README.md
CHANGED
@@ -116,6 +116,44 @@ $ drive_env spreadsheet to_env sheet1 > .env
|
|
116
116
|
$ your-ruby-application-with-dotenv-gem
|
117
117
|
```
|
118
118
|
|
119
|
+
#### Output format
|
120
|
+
|
121
|
+
JSON output is available by `--format=json` option.
|
122
|
+
|
123
|
+
```
|
124
|
+
$ drive_env spreadsheet to_env sheet1 --format=json
|
125
|
+
[
|
126
|
+
{
|
127
|
+
"key": "RAILS_ENV",
|
128
|
+
"value": "production"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"key": "DATABASE_HOSTNAME",
|
132
|
+
"value": "x.x.x.x"
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"key": "DATABASE_USERNAME",
|
136
|
+
"value": "appuser"
|
137
|
+
},
|
138
|
+
{
|
139
|
+
"key": "DATABASE_PASSWORD",
|
140
|
+
"value": "appuser"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"key": "SMTP_HOST",
|
144
|
+
"value": "x.x.x.x"
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"key": "SMTP_USERNAME",
|
148
|
+
"value": "appuser"
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"key": "SMTP_PASSWORD",
|
152
|
+
"value": "appuser"
|
153
|
+
}
|
154
|
+
]
|
155
|
+
```
|
156
|
+
|
119
157
|
## Development
|
120
158
|
|
121
159
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
require 'text-table'
|
3
3
|
require 'google_drive'
|
4
4
|
require 'drive_env'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
module DriveEnv
|
7
8
|
module Cli
|
@@ -22,19 +23,34 @@ module DriveEnv
|
|
22
23
|
end
|
23
24
|
|
24
25
|
desc 'to_env SPREADSHEET_URL_OR_ALIAS', ''
|
26
|
+
option :format, type: 'string', default: 'dotenv', enum: %w[dotenv json],
|
27
|
+
desc: 'output format'
|
25
28
|
def to_env(url_or_alias)
|
26
29
|
ws = worksheet(url_or_alias)
|
30
|
+
|
31
|
+
envs = []
|
27
32
|
ws.rows.each.with_index do |row, idx|
|
28
33
|
row_to_env(row) do |key, value, comment|
|
34
|
+
envs << { key: key, value: value, comment: comment }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
case options[:format]
|
39
|
+
when 'dotenv'
|
40
|
+
envs.each do |env|
|
29
41
|
case
|
30
|
-
when key && value && comment
|
31
|
-
puts "#{key}=#{value} #{comment}"
|
32
|
-
when key && value && !comment
|
33
|
-
puts "#{key}=#{value}"
|
34
|
-
when !key && !value && comment
|
35
|
-
puts comment
|
42
|
+
when env[:key] && env[:value] && env[:comment]
|
43
|
+
puts "#{env[:key]}=#{env[:value]} #{env[:comment]}"
|
44
|
+
when env[:key] && env[:value] && !env[:comment]
|
45
|
+
puts "#{env[:key]}=#{env[:value]}"
|
46
|
+
when !env[:key] && !env[:value] && env[:comment]
|
47
|
+
puts "#{env[:comment]}"
|
36
48
|
end
|
37
49
|
end
|
50
|
+
when 'json'
|
51
|
+
puts JSON.pretty_generate(
|
52
|
+
envs.select{|env| env[:key] }.map{|env| { key: env[:key], value: env[:value] } }
|
53
|
+
)
|
38
54
|
end
|
39
55
|
end
|
40
56
|
|
data/lib/drive_env/version.rb
CHANGED