waz-storage 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -9
- data/CHANGELOG.rdoc +72 -72
- data/Gemfile +4 -4
- data/Gemfile.lock +46 -46
- data/LICENSE +18 -18
- data/README.rdoc +310 -310
- data/lib/waz-blobs.rb +4 -4
- data/lib/waz-queues.rb +6 -6
- data/lib/waz-storage.rb +39 -39
- data/lib/waz-tables.rb +4 -4
- data/lib/waz/blobs/blob_object.rb +122 -122
- data/lib/waz/blobs/container.rb +172 -172
- data/lib/waz/blobs/exceptions.rb +10 -10
- data/lib/waz/blobs/service.rb +181 -181
- data/lib/waz/queues/exceptions.rb +28 -28
- data/lib/waz/queues/message.rb +64 -64
- data/lib/waz/queues/queue.rb +164 -164
- data/lib/waz/queues/service.rb +105 -105
- data/lib/waz/storage/base.rb +70 -70
- data/lib/waz/storage/core_service.rb +2 -1
- data/lib/waz/storage/exceptions.rb +33 -33
- data/lib/waz/storage/validation_rules.rb +25 -25
- data/lib/waz/tables/edm_type_helper.rb +44 -44
- data/lib/waz/tables/exceptions.rb +44 -44
- data/lib/waz/tables/service.rb +178 -178
- data/lib/waz/tables/table.rb +74 -74
- data/lib/waz/tables/table_array.rb +10 -10
- data/rakefile +7 -7
- data/spec/configuration.rb +22 -22
- data/spec/waz/blobs/blob_object_spec.rb +80 -80
- data/spec/waz/blobs/container_spec.rb +175 -175
- data/spec/waz/blobs/service_spec.rb +336 -336
- data/spec/waz/queues/message_spec.rb +32 -32
- data/spec/waz/queues/queue_spec.rb +205 -205
- data/spec/waz/queues/service_spec.rb +298 -298
- data/spec/waz/storage/base_tests.rb +81 -81
- data/spec/waz/storage/shared_key_core_service_spec.rb +141 -141
- data/spec/waz/tables/service_spec.rb +613 -613
- data/spec/waz/tables/table_spec.rb +97 -97
- data/waz-storage.gemspec +29 -29
- metadata +3 -3
@@ -1,98 +1,98 @@
|
|
1
|
-
# enabling the load of files from root (on RSpec)
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../')
|
3
|
-
require 'spec/configuration'
|
4
|
-
require 'lib/waz-tables'
|
5
|
-
|
6
|
-
describe "Table object behavior" do
|
7
|
-
it "should initialize a new table" do
|
8
|
-
table = WAZ::Tables::Table.new({:name => 'tablename', :url => 'http://localhost' })
|
9
|
-
table.name.should == 'tablename'
|
10
|
-
table.url.should == 'http://localhost'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should list tables" do
|
14
|
-
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
15
|
-
result = [ {:name => 'table1', :url => 'url1'}, {:name => 'table2', :url => 'url2'} ], nil
|
16
|
-
WAZ::Tables::Service.any_instance.expects(:list_tables).returns(result)
|
17
|
-
tables = WAZ::Tables::Table.list
|
18
|
-
tables.size.should == 2
|
19
|
-
tables.first().name.should == "table1"
|
20
|
-
tables.first().url.should == "url1"
|
21
|
-
tables.last().name.should == "table2"
|
22
|
-
tables.last().url.should == "url2"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should find a table by its name and return a WAZ::Tables::Table instance" do
|
26
|
-
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
27
|
-
WAZ::Tables::Service.any_instance.expects(:get_table).with('table1').returns({:name => 'table1', :url => 'url1'})
|
28
|
-
table = WAZ::Tables::Table.find('table1')
|
29
|
-
table.name.should == "table1"
|
30
|
-
table.url.should == "url1"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should return nil when looking for an unexisting table" do
|
34
|
-
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
35
|
-
WAZ::Tables::Service.any_instance.expects(:get_table).with('unexistingtable').raises(WAZ::Tables::TableDoesNotExist.new('unexistingtable'))
|
36
|
-
table = WAZ::Tables::Table.find('unexistingtable')
|
37
|
-
table.nil?.should == true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should create table" do
|
41
|
-
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
42
|
-
WAZ::Tables::Service.any_instance.expects(:create_table).returns({:name => 'table1', :url => 'http://foo'})
|
43
|
-
table = WAZ::Tables::Table.create('table1')
|
44
|
-
table.name.should == "table1"
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should destroy a table" do
|
48
|
-
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"})
|
49
|
-
WAZ::Tables::Service.any_instance.expects(:delete_table).with("tabletodelete")
|
50
|
-
WAZ::Tables::Service.any_instance.expects(:get_table).returns({:name => 'tabletodelete', :url => 'http://localhost'})
|
51
|
-
table = WAZ::Tables::Table.find('tabletodelete')
|
52
|
-
table.destroy!
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should throw when not name provided for the table" do
|
56
|
-
lambda { WAZ::Tables::Table.new({:foo => "bar"}) }.should raise_error(WAZ::Storage::InvalidOption)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should raise an exception when table name starts with no lower/upper char" do
|
60
|
-
lambda { WAZ::Tables::Table.create('9table') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should raise an exception when table contains any other char than letters or digits" do
|
64
|
-
lambda { WAZ::Tables::Table.create('table-name') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should raise an exception when table name is less than 3" do
|
68
|
-
lambda { WAZ::Tables::Table.create('t') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should raise an exception when table name is longer than 63" do
|
72
|
-
lambda { WAZ::Tables::Table.create('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should raise an exception when :url option is not provided" do
|
76
|
-
lambda { WAZ::Tables::Table.new({:name => 'name'}) }.should raise_error(WAZ::Storage::InvalidOption)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should raise an exception when :name option is not provided" do
|
80
|
-
lambda { WAZ::Tables::Table.new({:url => 'url'}) }.should raise_error(WAZ::Storage::InvalidOption)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should raise an exception when :name is empty" do
|
84
|
-
lambda { WAZ::Tables::Table.new({:name => '', :url => 'url'}) }.should raise_error(WAZ::Storage::InvalidOption)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should raise an exception when :url is empty" do
|
88
|
-
lambda { WAZ::Tables::Table.new({:name => 'name', :url => ''}) }.should raise_error(WAZ::Storage::InvalidOption)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should raise an exception when invalid table name is provided" do
|
92
|
-
INVALID_TABLE_ERROR_MESSAGE = "must start with at least one lower/upper characted, can have character or any digit starting from the second position, must be from 3 through 63 characters long"
|
93
|
-
options = {:name => '1invalidname', :url => 'url'}
|
94
|
-
options.stubs(:keys).returns([:name, :url])
|
95
|
-
WAZ::Tables::Table.any_instance.stubs(:new).with(options).raises(WAZ::Storage::InvalidParameterValue)
|
96
|
-
lambda { WAZ::Tables::Table.new(options) }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
97
|
-
end
|
1
|
+
# enabling the load of files from root (on RSpec)
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../')
|
3
|
+
require 'spec/configuration'
|
4
|
+
require 'lib/waz-tables'
|
5
|
+
|
6
|
+
describe "Table object behavior" do
|
7
|
+
it "should initialize a new table" do
|
8
|
+
table = WAZ::Tables::Table.new({:name => 'tablename', :url => 'http://localhost' })
|
9
|
+
table.name.should == 'tablename'
|
10
|
+
table.url.should == 'http://localhost'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should list tables" do
|
14
|
+
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
15
|
+
result = [ {:name => 'table1', :url => 'url1'}, {:name => 'table2', :url => 'url2'} ], nil
|
16
|
+
WAZ::Tables::Service.any_instance.expects(:list_tables).returns(result)
|
17
|
+
tables = WAZ::Tables::Table.list
|
18
|
+
tables.size.should == 2
|
19
|
+
tables.first().name.should == "table1"
|
20
|
+
tables.first().url.should == "url1"
|
21
|
+
tables.last().name.should == "table2"
|
22
|
+
tables.last().url.should == "url2"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should find a table by its name and return a WAZ::Tables::Table instance" do
|
26
|
+
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
27
|
+
WAZ::Tables::Service.any_instance.expects(:get_table).with('table1').returns({:name => 'table1', :url => 'url1'})
|
28
|
+
table = WAZ::Tables::Table.find('table1')
|
29
|
+
table.name.should == "table1"
|
30
|
+
table.url.should == "url1"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return nil when looking for an unexisting table" do
|
34
|
+
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
35
|
+
WAZ::Tables::Service.any_instance.expects(:get_table).with('unexistingtable').raises(WAZ::Tables::TableDoesNotExist.new('unexistingtable'))
|
36
|
+
table = WAZ::Tables::Table.find('unexistingtable')
|
37
|
+
table.nil?.should == true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should create table" do
|
41
|
+
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my-account", :access_key => "key"})
|
42
|
+
WAZ::Tables::Service.any_instance.expects(:create_table).returns({:name => 'table1', :url => 'http://foo'})
|
43
|
+
table = WAZ::Tables::Table.create('table1')
|
44
|
+
table.name.should == "table1"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should destroy a table" do
|
48
|
+
WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"})
|
49
|
+
WAZ::Tables::Service.any_instance.expects(:delete_table).with("tabletodelete")
|
50
|
+
WAZ::Tables::Service.any_instance.expects(:get_table).returns({:name => 'tabletodelete', :url => 'http://localhost'})
|
51
|
+
table = WAZ::Tables::Table.find('tabletodelete')
|
52
|
+
table.destroy!
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should throw when not name provided for the table" do
|
56
|
+
lambda { WAZ::Tables::Table.new({:foo => "bar"}) }.should raise_error(WAZ::Storage::InvalidOption)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should raise an exception when table name starts with no lower/upper char" do
|
60
|
+
lambda { WAZ::Tables::Table.create('9table') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should raise an exception when table contains any other char than letters or digits" do
|
64
|
+
lambda { WAZ::Tables::Table.create('table-name') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should raise an exception when table name is less than 3" do
|
68
|
+
lambda { WAZ::Tables::Table.create('t') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should raise an exception when table name is longer than 63" do
|
72
|
+
lambda { WAZ::Tables::Table.create('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should raise an exception when :url option is not provided" do
|
76
|
+
lambda { WAZ::Tables::Table.new({:name => 'name'}) }.should raise_error(WAZ::Storage::InvalidOption)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should raise an exception when :name option is not provided" do
|
80
|
+
lambda { WAZ::Tables::Table.new({:url => 'url'}) }.should raise_error(WAZ::Storage::InvalidOption)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should raise an exception when :name is empty" do
|
84
|
+
lambda { WAZ::Tables::Table.new({:name => '', :url => 'url'}) }.should raise_error(WAZ::Storage::InvalidOption)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should raise an exception when :url is empty" do
|
88
|
+
lambda { WAZ::Tables::Table.new({:name => 'name', :url => ''}) }.should raise_error(WAZ::Storage::InvalidOption)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should raise an exception when invalid table name is provided" do
|
92
|
+
INVALID_TABLE_ERROR_MESSAGE = "must start with at least one lower/upper characted, can have character or any digit starting from the second position, must be from 3 through 63 characters long"
|
93
|
+
options = {:name => '1invalidname', :url => 'url'}
|
94
|
+
options.stubs(:keys).returns([:name, :url])
|
95
|
+
WAZ::Tables::Table.any_instance.stubs(:new).with(options).raises(WAZ::Storage::InvalidParameterValue)
|
96
|
+
lambda { WAZ::Tables::Table.new(options) }.should raise_error(WAZ::Storage::InvalidParameterValue)
|
97
|
+
end
|
98
98
|
end
|
data/waz-storage.gemspec
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
Gem::Specification.new do |gem|
|
3
|
-
gem.authors = ['Johnny G. Halife']
|
4
|
-
gem.email = ['johnny.halife@me.com']
|
5
|
-
gem.description = %q{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.}
|
6
|
-
gem.summary = %q{Client library for Windows Azure's Storage Service REST API}
|
7
|
-
gem.homepage = 'http://waz-storage.heroku.com'
|
8
|
-
|
9
|
-
gem.files = `git ls-files`.split($\)
|
10
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
11
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
12
|
-
gem.name = "waz-storage"
|
13
|
-
gem.require_paths = ["lib"]
|
14
|
-
gem.version = "1.3.
|
15
|
-
|
16
|
-
gem.test_files = Dir['tests/**/*']
|
17
|
-
|
18
|
-
gem.has_rdoc = true
|
19
|
-
gem.rdoc_options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
20
|
-
|
21
|
-
gem.add_dependency 'rest-client'
|
22
|
-
gem.add_dependency 'ruby-hmac'
|
23
|
-
|
24
|
-
gem.add_development_dependency 'rake'
|
25
|
-
gem.add_development_dependency 'rspec'
|
26
|
-
gem.add_development_dependency 'rdoc'
|
27
|
-
gem.add_development_dependency 'simplecov'
|
28
|
-
gem.add_development_dependency 'mocha'
|
29
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.authors = ['Johnny G. Halife']
|
4
|
+
gem.email = ['johnny.halife@me.com']
|
5
|
+
gem.description = %q{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.}
|
6
|
+
gem.summary = %q{Client library for Windows Azure's Storage Service REST API}
|
7
|
+
gem.homepage = 'http://waz-storage.heroku.com'
|
8
|
+
|
9
|
+
gem.files = `git ls-files`.split($\)
|
10
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
11
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
12
|
+
gem.name = "waz-storage"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
gem.version = "1.3.2"
|
15
|
+
|
16
|
+
gem.test_files = Dir['tests/**/*']
|
17
|
+
|
18
|
+
gem.has_rdoc = true
|
19
|
+
gem.rdoc_options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
20
|
+
|
21
|
+
gem.add_dependency 'rest-client'
|
22
|
+
gem.add_dependency 'ruby-hmac'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'rake'
|
25
|
+
gem.add_development_dependency 'rspec'
|
26
|
+
gem.add_development_dependency 'rdoc'
|
27
|
+
gem.add_development_dependency 'simplecov'
|
28
|
+
gem.add_development_dependency 'mocha'
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waz-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 1.8.
|
199
|
+
rubygems_version: 1.8.24
|
200
200
|
signing_key:
|
201
201
|
specification_version: 3
|
202
202
|
summary: Client library for Windows Azure's Storage Service REST API
|