Module: Buckets
- Included in:
- CryptKeeper::Connection
- Defined in:
- lib/buckets.rb
Defined Under Namespace
Classes: Bucket, BucketMetaObject
Instance Method Summary collapse
-
#bucket_meta_objects(bucket_name, *args) ⇒ Object
GET Bucket lists the contents of a bucket or retrieves the ACLs that are applied to a bucket.
-
#buckets ⇒ Object
GET Service lists all of the buckets that you own return an array of Bucket objects.
- #create_bucket(*args) ⇒ Object
Instance Method Details
#bucket_meta_objects(bucket_name, *args) ⇒ Object
GET Bucket lists the contents of a bucket or retrieves the ACLs that are applied to a bucket. return an array of BucketObjects
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/buckets.rb', line 20 def (bucket_name, *args) = { :delimeter => nil, :marker => nil, :max_keys => nil, :prefix => nil } .merge!(args.pop) if args.last.is_a? Hash path = "/?" path << "delimeter=#{[:delimeter]}&" if ![:delimeter].nil? path << "marker=#{[:marker]}&" if ![:marker].nil? path << "max-keys=#{[:max_keys]}&" if ![:max_keys].nil? path << "prefix=#{[:prefix]}&" if ![:prefix].nil? path.gsub!(/[&]$/, '') hpr = Hpricot(CryptKeeper::Connection.http_instance.get(path, bucket_name)) obj_hashes = hpr.search("contents").map do |el| { :bucket_name => bucket_name, :key => el.search("key").inner_html, :last_modified => el.search("lastmodified").inner_html, :e_tag => el.search("etag").inner_html, :size => el.search("size").inner_html, :storage_class => el.search("storageclass").inner_html, :owner_id => el.search("id").inner_html, :owner_display_name => el.search("displayname").inner_html } end obj_hashes.map { |obj| BucketMetaObject.new(obj) } end |
#buckets ⇒ Object
GET Service lists all of the buckets that you own return an array of Bucket objects
6 7 8 9 10 11 12 13 14 |
# File 'lib/buckets.rb', line 6 def buckets Hpricot(CryptKeeper::Connection.http_instance.get("/")).search("bucket").map do |el| hsh = { :name => el.search("name").inner_html, :created_at => el.search("creationdate").inner_html } Bucket.new(hsh) end end |
#create_bucket(*args) ⇒ Object
52 53 54 |
# File 'lib/buckets.rb', line 52 def create_bucket(*args) end |