class Tumugi::Plugin::GoogleCloudStorageFileTarget

Attributes

bucket[R]
key[R]
path[R]

Public Class Methods

new(bucket:, key:, fs: nil) click to toggle source
# File lib/tumugi/plugin/target/google_cloud_storage_file.rb, line 15
def initialize(bucket:, key:, fs: nil)
  @bucket = bucket
  @key = key
  @path = "gs://#{File.join(bucket, key)}"
  @fs = fs unless fs.nil?
end

Public Instance Methods

fs() click to toggle source
# File lib/tumugi/plugin/target/google_cloud_storage_file.rb, line 22
def fs
  @fs ||= Tumugi::Plugin::GoogleCloudStorage::FileSystem.new(Tumugi.config.section('google_cloud_storage'))
end
open(mode="r", &block) click to toggle source
# File lib/tumugi/plugin/target/google_cloud_storage_file.rb, line 26
def open(mode="r", &block)
  if mode.include? 'r'
    fs.download(path, mode: mode, &block)
  elsif mode.include? 'w'
    Tumugi::Plugin::GoogleCloudStorage::AtomicFile.new(path, fs).open(&block)
  else
    raise Tumugi::TumugiError.new('Invalid mode: #{mode}')
  end
end
to_s() click to toggle source
# File lib/tumugi/plugin/target/google_cloud_storage_file.rb, line 36
def to_s
  path
end