waz-storage 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/waz-blobs.rb CHANGED
@@ -1,16 +1,5 @@
1
- require 'time'
2
- require 'cgi'
3
- require 'base64'
4
- require 'rexml/document'
5
- require 'rexml/xpath'
6
- require 'restclient'
7
- require 'hmac-sha2'
8
-
9
1
  $:.unshift(File.dirname(__FILE__))
10
2
  require 'waz-storage'
11
- require 'waz/blobs/blob_object'
12
- require 'waz/blobs/container'
13
- require 'waz/blobs/exceptions'
14
- require 'waz/blobs/service'
15
-
16
-
3
+ # Application Files (massive include)
4
+ app_files = File.expand_path(File.join('lib', 'waz', 'blobs', '*.rb'))
5
+ Dir[app_files].each(&method(:load))
data/lib/waz-queues.rb CHANGED
@@ -1,17 +1,6 @@
1
- require 'time'
2
- require 'cgi'
3
- require 'base64'
4
- require 'rexml/document'
5
- require 'rexml/xpath'
6
-
7
- require 'restclient'
8
- require 'hmac-sha2'
9
-
10
1
  $:.unshift(File.dirname(__FILE__))
11
2
  require 'waz-storage'
12
- require 'waz/queues/exceptions'
13
- require 'waz/queues/message'
14
- require 'waz/queues/queue'
15
- require 'waz/queues/service'
16
-
3
+ # Application Files (massive include)
4
+ app_files = File.expand_path(File.join('lib', 'waz', 'queues', '*.rb'))
5
+ Dir[app_files].each(&method(:load))
17
6
 
data/lib/waz-storage.rb CHANGED
@@ -1,11 +1,6 @@
1
- require 'net/http'
2
-
3
- $:.unshift(File.dirname(__FILE__))
4
- require 'waz/storage/base'
5
- require 'waz/storage/core_service'
6
- require 'waz/storage/exceptions'
7
- require 'waz/storage/version'
8
- require 'waz/storage/validation_rules'
1
+ %w{time cgi base64 rexml/document rexml/xpath restclient hmac-sha2 net/http}.each(&method(:require))
2
+ app_files = File.expand_path(File.join('lib', 'waz', 'storage', '*.rb'))
3
+ Dir[app_files].each(&method(:load))
9
4
 
10
5
  # It will depende on which version of Ruby (or if you have Rails)
11
6
  # but this method is required so we will add it the String class.
@@ -28,4 +23,9 @@ module Net
28
23
  RESPONSE_HAS_BODY = false
29
24
  end
30
25
  end
31
- end
26
+ end
27
+
28
+ # extendes the Symbol class to assign a type to an entity field
29
+ class Symbol
30
+ attr_accessor :edm_type
31
+ end
data/lib/waz-tables.rb CHANGED
@@ -1,20 +1,5 @@
1
- require 'time'
2
- require 'cgi'
3
- require 'base64'
4
- require 'rexml/document'
5
- require 'rexml/xpath'
6
- require 'restclient'
7
- require 'hmac-sha2'
8
-
9
1
  $:.unshift(File.dirname(__FILE__))
10
2
  require 'waz-storage'
11
- require 'waz/tables/exceptions'
12
- require 'waz/tables/table'
13
- require 'waz/tables/table_array'
14
- require 'waz/tables/service'
15
- require 'waz/tables/edm_type_helper'
16
-
17
- # extendes the Symbol class to assign a type to an entity field
18
- class Symbol
19
- attr_accessor :edm_type
20
- end
3
+ # Application Files (massive include)
4
+ app_files = File.expand_path(File.join('lib', 'waz', 'tables', '*.rb'))
5
+ Dir[app_files].each(&method(:load))
@@ -112,5 +112,4 @@ module WAZ
112
112
  end
113
113
  end
114
114
  end
115
- end
116
-
115
+ end
@@ -7,12 +7,12 @@ module WAZ
7
7
 
8
8
  # Creates a container on the current Windows Azure Storage account.
9
9
  def create_container(container_name)
10
- execute :put, container_name
10
+ execute :put, container_name, {:restype => 'container'}, {:x_ms_version => '2009-09-19'}
11
11
  end
12
12
 
13
13
  # Retrieves all the properties existing on the container.
14
14
  def get_container_properties(container_name)
15
- execute(:get, container_name).headers
15
+ execute(:get, container_name, {:restype => 'container'}, {:x_ms_version => '2009-09-19'}).headers
16
16
  end
17
17
 
18
18
  # Set the container properties (metadata).
@@ -20,14 +20,14 @@ module WAZ
20
20
  # Remember that custom properties should be named as :x_ms_meta_{propertyName} in order
21
21
  # to have Windows Azure to persist them.
22
22
  def set_container_properties(container_name, properties = {})
23
- execute :put, container_name, { :comp => 'metadata' }, properties
23
+ execute :put, container_name, { :restype => 'container', :comp => 'metadata' }, properties.merge!({:x_ms_version => '2009-09-19'})
24
24
  end
25
25
 
26
26
  # Retrieves the value of the :x_ms_prop_publicaccess header from the
27
27
  # container properties indicating whether the container is publicly
28
28
  # accessible or not.
29
29
  def get_container_acl(container_name)
30
- headers = execute(:get, container_name, { :comp => 'acl' }).headers
30
+ headers = execute(:get, container_name, { :restype => 'container', :comp => 'acl' }, {:x_ms_version => '2009-09-19'}).headers
31
31
  headers[:x_ms_prop_publicaccess].downcase == true.to_s
32
32
  end
33
33
 
@@ -37,7 +37,7 @@ module WAZ
37
37
  #
38
38
  # Default is _false_
39
39
  def set_container_acl(container_name, public_available = false)
40
- execute :put, container_name, { :comp => 'acl' }, { :x_ms_prop_publicaccess => public_available.to_s }
40
+ execute :put, container_name, { :restype => 'container', :comp => 'acl' }, { :x_ms_prop_publicaccess => public_available.to_s, :x_ms_version => '2009-09-19' }
41
41
  end
42
42
 
43
43
  # Lists all the containers existing on the current storage account.
@@ -55,7 +55,7 @@ module WAZ
55
55
 
56
56
  # Deletes the given container from the Windows Azure Storage account.
57
57
  def delete_container(container_name)
58
- execute :delete, container_name
58
+ execute :delete, container_name, {:restype => 'container'}, {:x_ms_version => '2009-09-19'}
59
59
  end
60
60
 
61
61
  # Lists all the blobs inside the given container.
@@ -95,12 +95,12 @@ module WAZ
95
95
 
96
96
  # Retrieves the properties associated with the blob at the given path.
97
97
  def get_blob_properties(path, options = {})
98
- execute(:head, path, options).headers
98
+ execute(:head, path, options, {:x_ms_version => "2009-09-19"}).headers
99
99
  end
100
100
 
101
101
  # Sets the properties (metadata) associated to the blob at given path.
102
102
  def set_blob_properties(path, properties ={})
103
- execute :put, path, { :comp => 'metadata' }, properties
103
+ execute :put, path, { :comp => 'properties' }, properties.merge({:x_ms_version => "2009-09-19"})
104
104
  end
105
105
 
106
106
  # Copies a blob within the same account (not necessarily to the same container)
@@ -71,6 +71,11 @@ module WAZ
71
71
  end
72
72
  end
73
73
 
74
+ # Syntax's sugar for find(:queue_name) or create(:queue_name)
75
+ def ensure(queue_name)
76
+ return (self.find(queue_name) or self.create(queue_name))
77
+ end
78
+
74
79
  # This method is internally used by this class. It's the way we keep a single instance of the
75
80
  # service that wraps the calls the Windows Azure Queues API. It's initialized with the values
76
81
  # from the default_connection on WAZ::Storage::Base initialized thru establish_connection!
@@ -31,11 +31,7 @@ module WAZ
31
31
  # Creates a queue on the current storage account. Throws WAZ::Queues::QueueAlreadyExists when
32
32
  # existing metadata and given metadata differ.
33
33
  def create_queue(queue_name, metadata = {})
34
- begin
35
- execute :put, queue_name, nil, metadata.merge!(:x_ms_version => '2009-09-19')
36
- rescue RestClient::RequestFailed
37
- raise WAZ::Queues::QueueAlreadyExists, queue_name if $!.http_code == 409
38
- end
34
+ execute(:put, queue_name, nil, metadata.merge!(:x_ms_version => '2009-09-19'))
39
35
  end
40
36
 
41
37
  # Deletes the given queue from the current storage account.
@@ -104,7 +104,7 @@ module WAZ
104
104
  # Generates a Windows Azure Storage call, it internally calls url generation method
105
105
  # and the request generation message.
106
106
  def execute(verb, path, query = {}, headers = {}, payload = nil)
107
- url = generate_request_uri(path, query)
107
+ url = generate_request_uri(path, query)
108
108
  request = generate_request(verb, url, headers, payload)
109
109
  request.execute()
110
110
  end
@@ -3,7 +3,7 @@ module WAZ
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = '1'
5
5
  MINOR = '0'
6
- TINY = '0'
6
+ TINY = '2'
7
7
  end
8
8
 
9
9
  Version = [VERSION::MAJOR, VERSION::MINOR, VERSION::TINY].compact * '.'
data/rakefile CHANGED
@@ -5,15 +5,16 @@ require 'rake/gempackagetask'
5
5
  require 'rake/rdoctask'
6
6
  require 'lib/waz-storage'
7
7
 
8
- namespace :test do
9
- Spec::Rake::SpecTask.new('run_with_rcov') do |t|
10
- t.spec_files = FileList['tests/waz/queues/*.rb', 'tests/waz/blobs/*.rb', 'tests/waz/tables/*.rb', 'tests/waz/storage/*.rb']
11
- t.rcov = true
12
- t.rcov_opts = ['--text-report', '--exclude', "exclude.*/.gem,test,Library,#{ENV['GEM_HOME']}", '--sort', 'coverage' ]
13
- t.spec_opts = ['-cfn']
14
- end
8
+ task :default => [:specs]
9
+
10
+ Spec::Rake::SpecTask.new('specs') do |t|
11
+ t.spec_files = FileList['tests/waz/blobs/*.rb', 'tests/waz/queues/*.rb', 'tests/waz/tables/*.rb', 'tests/waz/storage/*.rb']
12
+ t.rcov = true
13
+ t.rcov_opts = ['--text-report', '--exclude', "exclude.*/.gem,test,Library,#{ENV['GEM_HOME']}", '--sort', 'coverage' ]
14
+ t.spec_opts = ['-cfn']
15
15
  end
16
16
 
17
+
17
18
  namespace :dist do
18
19
  spec = Gem::Specification.new do |s|
19
20
  s.name = 'waz-storage'
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waz-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 2
9
+ version: 1.0.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Johnny G. Halife
@@ -9,29 +14,33 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-04 00:00:00 -03:00
17
+ date: 2010-10-02 00:00:00 -03:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rest-client
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: ruby-hmac
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :runtime
43
+ version_requirements: *id002
35
44
  description: A simple implementation of Windows Azure Storage API for Ruby, inspired by the S3 gems and self experience of dealing with queues. The major goal of the whole gem is to enable ruby developers [like me =)] to leverage Windows Azure Storage features and have another option for cloud storage.
36
45
  email: johnny.halife@me.com
37
46
  executables: []
@@ -79,18 +88,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
88
  requirements:
80
89
  - - ">="
81
90
  - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
82
93
  version: "0"
83
- version:
84
94
  required_rubygems_version: !ruby/object:Gem::Requirement
85
95
  requirements:
86
96
  - - ">="
87
97
  - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
88
100
  version: "0"
89
- version:
90
101
  requirements: []
91
102
 
92
103
  rubyforge_project:
93
- rubygems_version: 1.3.5
104
+ rubygems_version: 1.3.6
94
105
  signing_key:
95
106
  specification_version: 3
96
107
  summary: Client library for Windows Azure's Storage Service REST API