waz-storage 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +9 -9
  2. data/CHANGELOG.rdoc +72 -72
  3. data/Gemfile +4 -4
  4. data/Gemfile.lock +46 -40
  5. data/LICENSE +18 -18
  6. data/README.rdoc +310 -310
  7. data/lib/waz-blobs.rb +4 -4
  8. data/lib/waz-queues.rb +6 -6
  9. data/lib/waz-storage.rb +39 -39
  10. data/lib/waz-tables.rb +4 -4
  11. data/lib/waz/blobs/blob_object.rb +122 -122
  12. data/lib/waz/blobs/container.rb +172 -161
  13. data/lib/waz/blobs/exceptions.rb +10 -10
  14. data/lib/waz/blobs/service.rb +181 -156
  15. data/lib/waz/queues/exceptions.rb +28 -28
  16. data/lib/waz/queues/message.rb +64 -64
  17. data/lib/waz/queues/queue.rb +164 -164
  18. data/lib/waz/queues/service.rb +105 -105
  19. data/lib/waz/storage/base.rb +70 -70
  20. data/lib/waz/storage/exceptions.rb +33 -33
  21. data/lib/waz/storage/validation_rules.rb +25 -25
  22. data/lib/waz/tables/edm_type_helper.rb +44 -44
  23. data/lib/waz/tables/exceptions.rb +44 -44
  24. data/lib/waz/tables/service.rb +178 -178
  25. data/lib/waz/tables/table.rb +74 -74
  26. data/lib/waz/tables/table_array.rb +10 -10
  27. data/rakefile +8 -21
  28. data/{tests → spec}/configuration.rb +22 -22
  29. data/{tests/waz/blobs/blob_object_test.rb → spec/waz/blobs/blob_object_spec.rb} +80 -80
  30. data/{tests/waz/blobs/container_test.rb → spec/waz/blobs/container_spec.rb} +175 -162
  31. data/{tests/waz/blobs/service_test.rb → spec/waz/blobs/service_spec.rb} +336 -282
  32. data/{tests/waz/queues/message_test.rb → spec/waz/queues/message_spec.rb} +32 -32
  33. data/{tests/waz/queues/queue_test.rb → spec/waz/queues/queue_spec.rb} +205 -205
  34. data/{tests/waz/queues/service_test.rb → spec/waz/queues/service_spec.rb} +298 -298
  35. data/{tests → spec}/waz/storage/base_tests.rb +81 -81
  36. data/{tests/waz/storage/shared_key_core_service_test.rb → spec/waz/storage/shared_key_core_service_spec.rb} +141 -141
  37. data/{tests/waz/tables/service_test.rb → spec/waz/tables/service_spec.rb} +613 -613
  38. data/{tests/waz/tables/table_test.rb → spec/waz/tables/table_spec.rb} +97 -97
  39. data/waz-storage.gemspec +29 -27
  40. metadata +47 -26
@@ -1,98 +1,98 @@
1
- # enabling the load of files from root (on RSpec)
2
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../')
3
- require 'tests/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,27 +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.2.0"
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 'rspec'
25
- gem.add_development_dependency 'simplecov'
26
- gem.add_development_dependency 'mocha'
27
- 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.0"
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.2.0
4
+ version: 1.3.0
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: 2012-12-19 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rspec
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +75,22 @@ dependencies:
59
75
  - - ! '>='
60
76
  - !ruby/object:Gem::Version
61
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
62
94
  - !ruby/object:Gem::Dependency
63
95
  name: simplecov
64
96
  requirement: !ruby/object:Gem::Requirement
@@ -129,17 +161,17 @@ files:
129
161
  - lib/waz/tables/table.rb
130
162
  - lib/waz/tables/table_array.rb
131
163
  - rakefile
132
- - tests/configuration.rb
133
- - tests/waz/blobs/blob_object_test.rb
134
- - tests/waz/blobs/container_test.rb
135
- - tests/waz/blobs/service_test.rb
136
- - tests/waz/queues/message_test.rb
137
- - tests/waz/queues/queue_test.rb
138
- - tests/waz/queues/service_test.rb
139
- - tests/waz/storage/base_tests.rb
140
- - tests/waz/storage/shared_key_core_service_test.rb
141
- - tests/waz/tables/service_test.rb
142
- - tests/waz/tables/table_test.rb
164
+ - spec/configuration.rb
165
+ - spec/waz/blobs/blob_object_spec.rb
166
+ - spec/waz/blobs/container_spec.rb
167
+ - spec/waz/blobs/service_spec.rb
168
+ - spec/waz/queues/message_spec.rb
169
+ - spec/waz/queues/queue_spec.rb
170
+ - spec/waz/queues/service_spec.rb
171
+ - spec/waz/storage/base_tests.rb
172
+ - spec/waz/storage/shared_key_core_service_spec.rb
173
+ - spec/waz/tables/service_spec.rb
174
+ - spec/waz/tables/table_spec.rb
143
175
  - waz-storage.gemspec
144
176
  homepage: http://waz-storage.heroku.com
145
177
  licenses: []
@@ -164,19 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
196
  version: '0'
165
197
  requirements: []
166
198
  rubyforge_project:
167
- rubygems_version: 1.8.24
199
+ rubygems_version: 1.8.23
168
200
  signing_key:
169
201
  specification_version: 3
170
202
  summary: Client library for Windows Azure's Storage Service REST API
171
- test_files:
172
- - tests/configuration.rb
173
- - tests/waz/blobs/blob_object_test.rb
174
- - tests/waz/blobs/container_test.rb
175
- - tests/waz/blobs/service_test.rb
176
- - tests/waz/queues/message_test.rb
177
- - tests/waz/queues/queue_test.rb
178
- - tests/waz/queues/service_test.rb
179
- - tests/waz/storage/base_tests.rb
180
- - tests/waz/storage/shared_key_core_service_test.rb
181
- - tests/waz/tables/service_test.rb
182
- - tests/waz/tables/table_test.rb
203
+ test_files: []