drive_env 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +115 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/drive_env.gemspec +39 -0
- data/exe/drive_env +6 -0
- data/lib/drive_env/cli/auth.rb +47 -0
- data/lib/drive_env/cli/command.rb +24 -0
- data/lib/drive_env/cli/config.rb +32 -0
- data/lib/drive_env/cli/spreadsheet.rb +145 -0
- data/lib/drive_env/cli.rb +8 -0
- data/lib/drive_env/config.rb +50 -0
- data/lib/drive_env/version.rb +3 -0
- data/lib/drive_env.rb +13 -0
- data/spreadsheet.png +0 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 535703d25f647836939114b16807a889f37e7299
|
4
|
+
data.tar.gz: 2d85523a0ac558537e504c6a31b0ac40d949c901
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5a292adf7028ae6d917ec25e5b711f71c118c86a0637b0822bb0448c265a26bf4cde4197115ae936bb1446c95c0767033d49549a216e4a7f1bc954c4a6cb9b1
|
7
|
+
data.tar.gz: 1aca98931755a8934fb6a9ff3972971a966e786145211fd91b9f56a865480a0e3ad95bcde8b707c29871496ff9fa31298180021c8434c4ffd48c891be53f399a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 YAMADA Tsuyoshi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# DriveEnv
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/drive_env.png)](https://rubygems.org/gems/drive_env)
|
4
|
+
[![Build Status](https://travis-ci.org/groovenauts/drive_env.svg?branch=master)](https://travis-ci.org/groovenauts/drive_env)
|
5
|
+
|
6
|
+
Generate `.env` file from Spreadsheet in Google Drive.
|
7
|
+
|
8
|
+
```
|
9
|
+
$ drive_env spreadsheet to_env 'https://docs.google.com/spreadsheets/d/*********/edit#gid=0'
|
10
|
+
# name value comment
|
11
|
+
RAILS_ENV=production # production or testing or development
|
12
|
+
DATABASE_HOSTNAME=x.x.x.x # IP address of Database
|
13
|
+
DATABASE_USERNAME=appuser # Username of Database
|
14
|
+
DATABASE_PASSWORD=appuser # Password of Database
|
15
|
+
DATABASE_NAME=foo_production # Name of Database
|
16
|
+
SMTP_HOST=x.x.x.x
|
17
|
+
SMTP_USERNAME=appuser
|
18
|
+
SMTP_PASSWORD=appuser
|
19
|
+
```
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'drive_env'
|
27
|
+
```
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install drive_env
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
First, you need to login Google Cloud Platform and enable APIs.
|
40
|
+
|
41
|
+
1. Open https://console.developers.google.com/project
|
42
|
+
2. Create/Select project
|
43
|
+
3. Visit APIs & auth -> APIs
|
44
|
+
4. Grant access to `Drive API`
|
45
|
+
5. Visit APIs & auth -> Credentials
|
46
|
+
6. Oauth -> Create new Client ID
|
47
|
+
7. Choose Installed application (Other)
|
48
|
+
8. Note CLIENT ID, CLIENT_SECRET
|
49
|
+
|
50
|
+
Setup client_id, client_secret, and login.
|
51
|
+
|
52
|
+
```
|
53
|
+
$ drive_env config set client_id YOUR_CLIENT_ID
|
54
|
+
$ drive_env config set client_secret YOUR_CLIENT_SECRET
|
55
|
+
$ drive_env auth login
|
56
|
+
```
|
57
|
+
|
58
|
+
Now you have access token and refresh token, you can access to Google APIs.
|
59
|
+
|
60
|
+
Show Spreadsheet in Google Drive:
|
61
|
+
|
62
|
+
```
|
63
|
+
$ drive_env spreadsheet show 'https://docs.google.com/spreadsheets/d/*********/edit#gid=0'
|
64
|
+
```
|
65
|
+
|
66
|
+
You can add alias for Spreadsheet.
|
67
|
+
|
68
|
+
```
|
69
|
+
$ drive_env spreadsheet alias sheet1 'https://docs.google.com/spreadsheets/d/*********/edit#gid=0'
|
70
|
+
$ drive_env spreadsheet show sheet1
|
71
|
+
```
|
72
|
+
|
73
|
+
### `drive_env spreadsheet to_env`
|
74
|
+
|
75
|
+
`drive_env spreadsheet to_env` with following Spreadsheet
|
76
|
+
|
77
|
+
![Spreadsheet](spreadsheet.png)
|
78
|
+
|
79
|
+
will generate dotenv gem friendly format.
|
80
|
+
|
81
|
+
```
|
82
|
+
$ drive_env spreadsheet to_env sheet1
|
83
|
+
# name value comment
|
84
|
+
RAILS_ENV=production # production or testing or development
|
85
|
+
DATABASE_HOSTNAME=x.x.x.x # IP address of Database
|
86
|
+
DATABASE_USERNAME=appuser # Username of Database
|
87
|
+
DATABASE_PASSWORD=appuser # Password of Database
|
88
|
+
DATABASE_NAME=foo_production # Name of Database
|
89
|
+
SMTP_HOST=x.x.x.x
|
90
|
+
SMTP_USERNAME=appuser
|
91
|
+
SMTP_PASSWORD=appuser
|
92
|
+
```
|
93
|
+
|
94
|
+
Redirect to file `.env`, and then you can use with dotenv gem.
|
95
|
+
|
96
|
+
```
|
97
|
+
$ drive_env spreadsheet to_env sheet1 > .env
|
98
|
+
$ your-ruby-application-with-dotenv-gem
|
99
|
+
```
|
100
|
+
|
101
|
+
## Development
|
102
|
+
|
103
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
104
|
+
|
105
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
106
|
+
|
107
|
+
## Contributing
|
108
|
+
|
109
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/groovenauts/drive_env.
|
110
|
+
|
111
|
+
|
112
|
+
## License
|
113
|
+
|
114
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
115
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "drive_env"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/drive_env.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'drive_env/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "drive_env"
|
8
|
+
spec.version = DriveEnv::VERSION
|
9
|
+
spec.authors = ["YAMADA Tsuyoshi"]
|
10
|
+
spec.email = ["tyamada@minimum2scp.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generate `.env` file from Spreadsheet in Google Drive}
|
13
|
+
spec.description = %q{Generate `.env` file from Spreadsheet in Google Drive}
|
14
|
+
spec.homepage = "https://github.com/groovenauts/drive_env"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# # delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "google_drive", "~> 1.0.1"
|
31
|
+
spec.add_dependency "google-api-client", "~> 0.8.6"
|
32
|
+
spec.add_dependency "thor", "~> 0.19.1"
|
33
|
+
spec.add_dependency "text-table", "~> 1.2.4"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec"
|
38
|
+
spec.add_development_dependency "pry"
|
39
|
+
end
|
data/exe/drive_env
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'drive_env'
|
3
|
+
|
4
|
+
module DriveEnv
|
5
|
+
module Cli
|
6
|
+
class Auth < Thor
|
7
|
+
desc 'login', ''
|
8
|
+
def login
|
9
|
+
if !config.client_id
|
10
|
+
abort "please set client_id: #{$0} config set client_id YOUR_CLIENT_ID"
|
11
|
+
end
|
12
|
+
if !config.client_secret
|
13
|
+
abort "please set client_secret: #{$0} config set client_secret YOUR_CLIENT_SECRET"
|
14
|
+
end
|
15
|
+
print("1. Open this page:\n%s\n\n" % auth.authorization_uri)
|
16
|
+
print("2. Enter the authorization code shown in the page: ")
|
17
|
+
auth.code = $stdin.gets.chomp
|
18
|
+
auth.fetch_access_token!
|
19
|
+
config.access_token = auth.access_token
|
20
|
+
config.refresh_token = auth.refresh_token
|
21
|
+
config.expires_at = auth.issued_at + auth.expires_in
|
22
|
+
config.save
|
23
|
+
end
|
24
|
+
|
25
|
+
no_commands do
|
26
|
+
def config
|
27
|
+
@config ||= DriveEnv::Config.load(options[:config])
|
28
|
+
end
|
29
|
+
|
30
|
+
def auth
|
31
|
+
unless @auth
|
32
|
+
@auth = ::DriveEnv.client.authorization
|
33
|
+
@auth.client_id = config.client_id
|
34
|
+
@auth.client_secret = config.client_secret
|
35
|
+
@auth.scope = %w[
|
36
|
+
https://www.googleapis.com/auth/drive
|
37
|
+
https://spreadsheets.google.com/feeds/
|
38
|
+
].join(' ')
|
39
|
+
@auth.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'
|
40
|
+
end
|
41
|
+
@auth
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'drive_env'
|
3
|
+
|
4
|
+
module DriveEnv
|
5
|
+
module Cli
|
6
|
+
class Command < Thor
|
7
|
+
class_option :config, :aliases =>['c'], :required => false, :type => :string, :default => DriveEnv::Config::DEFAULT_CONFIG_FILE
|
8
|
+
|
9
|
+
desc 'auth SUBCOMMAND ...ARGS', ''
|
10
|
+
subcommand 'auth', ::DriveEnv::Cli::Auth
|
11
|
+
|
12
|
+
desc 'config SUBCOMMAND ...ARGS', ''
|
13
|
+
subcommand 'config', ::DriveEnv::Cli::Config
|
14
|
+
|
15
|
+
desc 'spreadsheet SUBCOMMAND ...ARGS', ''
|
16
|
+
subcommand 'spreadsheet', ::DriveEnv::Cli::Spreadsheet
|
17
|
+
|
18
|
+
desc 'version', ''
|
19
|
+
def version
|
20
|
+
puts "drive_env v#{::DriveEnv::VERSION}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'drive_env'
|
3
|
+
|
4
|
+
module DriveEnv
|
5
|
+
module Cli
|
6
|
+
class Config < Thor
|
7
|
+
desc 'set key value', ''
|
8
|
+
def set(key, value)
|
9
|
+
config.instance_variable_set("@#{key}", value)
|
10
|
+
config.save
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'unset key', ''
|
14
|
+
def unset(key)
|
15
|
+
config.remove_instance_variable("@#{key}")
|
16
|
+
config.save
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'list', ''
|
20
|
+
def list
|
21
|
+
puts YAML.dump(config)
|
22
|
+
end
|
23
|
+
|
24
|
+
no_commands do
|
25
|
+
def config
|
26
|
+
@config ||= DriveEnv::Config.load(options[:config])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'text-table'
|
3
|
+
require 'google_drive'
|
4
|
+
require 'drive_env'
|
5
|
+
|
6
|
+
module DriveEnv
|
7
|
+
module Cli
|
8
|
+
class Spreadsheet < Thor
|
9
|
+
desc 'show SPREADSHEET_URL_OR_ALIAS', ''
|
10
|
+
def show(url_or_alias)
|
11
|
+
ws = worksheet(url_or_alias)
|
12
|
+
table = Text::Table.new
|
13
|
+
ws.rows.each.with_index do |row, idx|
|
14
|
+
if idx == 0
|
15
|
+
table.head = row
|
16
|
+
else
|
17
|
+
table.rows << row
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
puts table.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'to_env SPREADSHEET_URL_OR_ALIAS', ''
|
25
|
+
def to_env(url_or_alias)
|
26
|
+
ws = worksheet(url_or_alias)
|
27
|
+
ws.rows.each.with_index do |row, idx|
|
28
|
+
row_to_env(row) do |key, value, comment|
|
29
|
+
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
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'runner SPREADSHEET_URL_OR_ALIAS COMMANDS', ''
|
42
|
+
def runner(url_or_alias, *commands)
|
43
|
+
ws = worksheet(url_or_alias)
|
44
|
+
ws.rows.each.with_index do |row, idx|
|
45
|
+
row_to_env(row) do |key, value, comment|
|
46
|
+
case
|
47
|
+
when key && value
|
48
|
+
ENV[key] = value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
system(*commands)
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'alias NAME SPREADSHEET_URL', ''
|
56
|
+
def alias(name, url)
|
57
|
+
config.set_alias_for_spreadsheet(name, url)
|
58
|
+
config.save
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'unalias NAME', ''
|
62
|
+
def unalias(name)
|
63
|
+
config.unset_alias_for_spreadsheet(name)
|
64
|
+
config.save
|
65
|
+
end
|
66
|
+
|
67
|
+
no_commands do
|
68
|
+
def config
|
69
|
+
@config ||= DriveEnv::Config.load(options[:config])
|
70
|
+
end
|
71
|
+
|
72
|
+
def auth
|
73
|
+
unless @auth
|
74
|
+
@auth = ::DriveEnv.client.authorization
|
75
|
+
@auth.client_id = config.client_id
|
76
|
+
@auth.client_secret = config.client_secret
|
77
|
+
end
|
78
|
+
@auth
|
79
|
+
end
|
80
|
+
|
81
|
+
def access_token
|
82
|
+
unless @access_token
|
83
|
+
auth.expires_at = config.expires_at
|
84
|
+
if auth.expired?
|
85
|
+
auth.refresh_token = config.refresh_token
|
86
|
+
auth.fetch_access_token!
|
87
|
+
config.access_token = auth.access_token
|
88
|
+
config.expires_at = auth.issued_at + auth.expires_in
|
89
|
+
config.save
|
90
|
+
end
|
91
|
+
@access_token = config.access_token
|
92
|
+
end
|
93
|
+
@access_token
|
94
|
+
end
|
95
|
+
|
96
|
+
def session
|
97
|
+
if !config.access_token
|
98
|
+
abort "please set access_token: #{$0} auth login"
|
99
|
+
end
|
100
|
+
@session ||= GoogleDrive.login_with_oauth(access_token)
|
101
|
+
end
|
102
|
+
|
103
|
+
def worksheet(url_or_alias)
|
104
|
+
url = config.lookup_spreadsheet_url_by_alias(url_or_alias) || url_or_alias
|
105
|
+
spreadsheet = session.spreadsheet_by_url(url)
|
106
|
+
if url =~ /#gid=(\d+)/
|
107
|
+
spreadsheet.worksheet_by_gid($1)
|
108
|
+
else
|
109
|
+
spreadsheet.worksheets[0]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def row_to_env(row)
|
114
|
+
if row[0] =~ /\A\s*#/
|
115
|
+
comment = row.join(' ')
|
116
|
+
yield nil, nil, comment
|
117
|
+
else
|
118
|
+
key = row[0]
|
119
|
+
value = row[1]
|
120
|
+
others = row[2..-1].join(' ')
|
121
|
+
case [key, value, others].map{|v| !v.strip.empty?}
|
122
|
+
when [true, true, true]
|
123
|
+
yield key, value, "# #{others}"
|
124
|
+
when [true, true, false]
|
125
|
+
yield key, value, nil
|
126
|
+
when [true, false, true]
|
127
|
+
yield key, '', "# #{others}"
|
128
|
+
when [true, false, false]
|
129
|
+
yield nil, nil, "# #{key}="
|
130
|
+
when [false, true, true]
|
131
|
+
# ignore
|
132
|
+
when [false, true, false]
|
133
|
+
# ignore
|
134
|
+
when [false, false, true]
|
135
|
+
yield nil, nil, "# #{others}"
|
136
|
+
when [false, false, false]
|
137
|
+
# ignore
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module DriveEnv
|
5
|
+
class Config
|
6
|
+
DEFAULT_CONFIG_FILE = File.expand_path('~/.config/drive_env/config')
|
7
|
+
|
8
|
+
attr_accessor :client_id
|
9
|
+
attr_accessor :client_secret
|
10
|
+
attr_accessor :access_token
|
11
|
+
attr_accessor :refresh_token
|
12
|
+
attr_accessor :expires_at
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@spreadsheet_aliases = {}
|
16
|
+
@config_file = DEFAULT_CONFIG_FILE
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_alias_for_spreadsheet(name, url)
|
20
|
+
@spreadsheet_aliases[name] = url
|
21
|
+
end
|
22
|
+
|
23
|
+
def unset_alias_for_spreadsheet(name)
|
24
|
+
@spreadsheet_aliases.delete(name)
|
25
|
+
end
|
26
|
+
|
27
|
+
def lookup_spreadsheet_url_by_alias(name)
|
28
|
+
@spreadsheet_aliases[name]
|
29
|
+
end
|
30
|
+
|
31
|
+
def save
|
32
|
+
dir = File.dirname(@config_file)
|
33
|
+
if !File.directory?(dir)
|
34
|
+
FileUtils.mkdir_p(dir)
|
35
|
+
end
|
36
|
+
|
37
|
+
File.open(@config_file, 'w') do |fh|
|
38
|
+
fh << YAML.dump(self)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class << self
|
43
|
+
def load(file)
|
44
|
+
obj = File.exist?(file) ? YAML.load(File.read(file)) : self.new
|
45
|
+
obj.instance_variable_set("@config_file", file)
|
46
|
+
obj
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/drive_env.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'drive_env/version'
|
2
|
+
require 'google/api_client'
|
3
|
+
|
4
|
+
module DriveEnv
|
5
|
+
autoload :Cli, 'drive_env/cli'
|
6
|
+
autoload :Config, 'drive_env/config'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def client
|
10
|
+
@client ||= Google::APIClient.new(:application_name => 'drive_env', :application_version => DriveEnv::VERSION)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spreadsheet.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drive_env
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- YAMADA Tsuyoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google_drive
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: google-api-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.19.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.19.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: text-table
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Generate `.env` file from Spreadsheet in Google Drive
|
126
|
+
email:
|
127
|
+
- tyamada@minimum2scp.org
|
128
|
+
executables:
|
129
|
+
- drive_env
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/setup
|
142
|
+
- drive_env.gemspec
|
143
|
+
- exe/drive_env
|
144
|
+
- lib/drive_env.rb
|
145
|
+
- lib/drive_env/cli.rb
|
146
|
+
- lib/drive_env/cli/auth.rb
|
147
|
+
- lib/drive_env/cli/command.rb
|
148
|
+
- lib/drive_env/cli/config.rb
|
149
|
+
- lib/drive_env/cli/spreadsheet.rb
|
150
|
+
- lib/drive_env/config.rb
|
151
|
+
- lib/drive_env/version.rb
|
152
|
+
- spreadsheet.png
|
153
|
+
homepage: https://github.com/groovenauts/drive_env
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.2.2
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Generate `.env` file from Spreadsheet in Google Drive
|
177
|
+
test_files: []
|