Google Drive plugin for tumugi
tumugi-plugin-google_drive is a plugin for integrate Google Drive and tumugi.
Add this line to your application's Gemfile:
gem 'tumugi-plugin-google_drive'
And then execute bundle install
GoogleDriveFileTarget
represents file on Googl Drive.
name | type | required? | default | description |
---|---|---|---|---|
name | string | required | Filename | |
file_id | string | optional | File ID | |
parents | string or string array | optional | Parent folder ID(s) | |
mime_type | string | optional | MIME type of file |
mime_type
is specifiy default mime_type value for GoogleDriveFileTarget#open(mode="r", mime_type: @mime_type, &block)
method.
task :task1 do
param :day, type: :time, auto_bind: true, required: true
output do
target(:google_drive_file,
name: "test_#{day.strftime('%Y%m%d')}.txt",
parents: "xyz")
end
run do
log "task1#run"
output.open("w") {|f| f.puts("done") }
end
end
task :task1 do
param :day, type: :time, auto_bind: true, required: true
output do
target(:google_drive_file,
name: "test_#{day.strftime('%Y%m%d')}.csv",
mime_type: "application/vnd.google-apps.spreadsheet")
end
run do
log "task1#run"
output.open("w") {|f| f.puts("header1,header2"); f.puts("value1,value2") }
# You can also specify mime_type by argument of open method.
# output.open("w", mime_type: "application/vnd.google-apps.spreadsheet") { ... }
end
end
GoogleDriveFolderTarget
represents folder on Googl Drive.
name | type | required? | default | description |
---|---|---|---|---|
name | string | required | Filename | |
folder_id | string | optional | Folder ID | |
parents | string or string array | optional | Parent folder ID(s) |
GoogleDriveFolderTask
create a folder on Googl Drive.
Return value of output
must be instance of Tumugi::Plugin::GoogleDriveFolderTarget
name | type | required? | default | description |
---|---|---|---|---|
name | string | required | Filename | |
folder_id | string | optional | Folder ID | |
parents | string or string array | optional | Parent folder ID(s) |
task :task1, type: :google_drive_folder do
param :day, type: :time, auto_bind: true, required: true
name { "test_#{day.strftime('%Y%m%d')}.txt" }
parents "xyz"
end
Run this workflow via:
$ bundle exec tumugi run -f workflow.rb -p day:2016-07-01 task1
tumugi-plugin-google_drive provide config section named "google_drive" which can specified Google Drive autenticaion info.
Tumugi.config do |config|
config.section("google_drive") do |section|
section.project_id = "xxx"
section.client_email = "[email protected]"
section.private_key = "zzz"
end
end
Tumugi.configure do |config|
config.section("google_drive") do |section|
section.private_key_file = "/path/to/key.json"
end
end
After checking out the repo, run bundle install
to install dependencies. Then, run bundle exec rake test
to run the tests.
Bug reports and pull requests are welcome on GitHub at https://github.com/tumugi/tumugi-plugin-google_drive
The gem is available as open source under the terms of the Apache License Version 2.0.