class SakurraForm::Storage
Public Class Methods
source_root()
click to toggle source
# File lib/sakurraform/cli/storage.rb, line 7 def self.source_root File.expand_path("../../", __FILE__) end
Public Instance Methods
cat(path)
click to toggle source
# File lib/sakurraform/cli/storage.rb, line 34 def cat(path) s3 = init_s3 bucket = s3.buckets[Fog.credentials[:sakura_object_storage_bucket]] obj = bucket.objects.find {|a| a.key == path } say(obj.read) if obj end
create()
click to toggle source
# File lib/sakurraform/cli/storage.rb, line 12 def create system('open https://secure.sakura.ad.jp/storage/#!/namespace/manage/') end
delete(path)
click to toggle source
# File lib/sakurraform/cli/storage.rb, line 53 def delete(path) s3 = init_s3 bucket = s3.buckets[Fog.credentials[:sakura_object_storage_bucket]] obj = bucket.objects.find {|a| a.key == path } if obj say("deleting #{obj.key}") obj.delete else say("Object #{path} Not found.") end end
ls()
click to toggle source
# File lib/sakurraform/cli/storage.rb, line 17 def ls s3 = init_s3 bucket = s3.buckets[Fog.credentials[:sakura_object_storage_bucket]] table = bucket.objects.entries.map do |ent| { :key => ent.key, :content_type => ent.content_type, :content_length => ent.content_length, :last_modified => ent.last_modified, :public_url => ent.public_url.to_s } end Formatador.display_table(table, [:key, :content_length, :content_type, :last_modified, :public_url]) end
put(file, key = file)
click to toggle source
# File lib/sakurraform/cli/storage.rb, line 43 def put(file, key = file) s3 = init_s3 bucket = s3.buckets[Fog.credentials[:sakura_object_storage_bucket]] obj = bucket.objects[key] obj.write(Pathname.new(file)) say("File #{file} was put to #{key}.") end