Class: GitMedia::Transport::AtmosClient
- Defined in:
- lib/git-media/transport/atmos_client.rb
Instance Method Summary collapse
- #get_file(sha, to_file) ⇒ Object
- #get_unpushed(files) ⇒ Object
-
#initialize(endpoint, uid, secret, tag) ⇒ AtmosClient
constructor
A new instance of AtmosClient.
- #put_file(sha, from_file) ⇒ Object
- #read? ⇒ Boolean
- #write ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(endpoint, uid, secret, tag) ⇒ AtmosClient
Returns a new instance of AtmosClient.
14 15 16 17 18 19 20 21 22 |
# File 'lib/git-media/transport/atmos_client.rb', line 14 def initialize(endpoint, uid, secret, tag) = { :url => endpoint, :uid => uid, :secret => secret } @tag = tag @atmos_client = Atmos::Store.new() end |
Instance Method Details
#get_file(sha, to_file) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/git-media/transport/atmos_client.rb', line 28 def get_file(sha, to_file) dst_file = File.new(to_file, File::CREAT|File::RDWR) @atmos_client.get(:namespace => sha).data_as_stream do |chunck| dst_file.write(chunck) end end |
#get_unpushed(files) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/git-media/transport/atmos_client.rb', line 46 def get_unpushed(files) unpushed = [] files.each do |file| begin @atmos_client.get(:namespace => file) rescue Atmos::Exceptions::AtmosException unpushed << file end end unpushed end |
#put_file(sha, from_file) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/git-media/transport/atmos_client.rb', line 39 def put_file(sha, from_file) src_file = File.open(from_file) obj_conf = {:data => src_file, :length => File.size(from_file), :namespace => sha} obj_conf[:listable_metadata] = {@tag => true} if @tag @atmos_client.create(obj_conf) end |
#read? ⇒ Boolean
24 25 26 |
# File 'lib/git-media/transport/atmos_client.rb', line 24 def read? reachable? end |
#write ⇒ Object
35 36 37 |
# File 'lib/git-media/transport/atmos_client.rb', line 35 def write reachable? end |