sparqcode-waz-storage 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +7 -0
  2. data/CHANGELOG.rdoc +72 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +36 -0
  5. data/LICENSE +19 -0
  6. data/README.rdoc +299 -0
  7. data/lib/waz-blobs.rb +5 -0
  8. data/lib/waz-queues.rb +6 -0
  9. data/lib/waz-storage.rb +39 -0
  10. data/lib/waz-tables.rb +5 -0
  11. data/lib/waz/blobs/blob_object.rb +121 -0
  12. data/lib/waz/blobs/container.rb +160 -0
  13. data/lib/waz/blobs/exceptions.rb +11 -0
  14. data/lib/waz/blobs/service.rb +156 -0
  15. data/lib/waz/queues/exceptions.rb +29 -0
  16. data/lib/waz/queues/message.rb +65 -0
  17. data/lib/waz/queues/queue.rb +165 -0
  18. data/lib/waz/queues/service.rb +106 -0
  19. data/lib/waz/storage/base.rb +70 -0
  20. data/lib/waz/storage/core_service.rb +122 -0
  21. data/lib/waz/storage/exceptions.rb +33 -0
  22. data/lib/waz/storage/validation_rules.rb +26 -0
  23. data/lib/waz/storage/version.rb +11 -0
  24. data/lib/waz/tables/edm_type_helper.rb +45 -0
  25. data/lib/waz/tables/exceptions.rb +45 -0
  26. data/lib/waz/tables/service.rb +178 -0
  27. data/lib/waz/tables/table.rb +75 -0
  28. data/lib/waz/tables/table_array.rb +11 -0
  29. data/rakefile +23 -0
  30. data/tests/configuration.rb +14 -0
  31. data/tests/waz/blobs/blob_object_test.rb +80 -0
  32. data/tests/waz/blobs/container_test.rb +162 -0
  33. data/tests/waz/blobs/service_test.rb +282 -0
  34. data/tests/waz/queues/message_test.rb +33 -0
  35. data/tests/waz/queues/queue_test.rb +206 -0
  36. data/tests/waz/queues/service_test.rb +299 -0
  37. data/tests/waz/storage/base_tests.rb +81 -0
  38. data/tests/waz/storage/shared_key_core_service_test.rb +142 -0
  39. data/tests/waz/tables/service_test.rb +614 -0
  40. data/tests/waz/tables/table_test.rb +98 -0
  41. data/waz-storage.gemspec +29 -0
  42. metadata +187 -0
@@ -0,0 +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
98
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'lib/waz/storage/version'
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Johnny G. Halife']
6
+ gem.email = ['johnny.halife@me.com']
7
+ 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.}
8
+ gem.summary = %q{Client library for Windows Azure's Storage Service REST API}
9
+ gem.homepage = 'http://waz-storage.heroku.com'
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "sparqcode-waz-storage"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Gem::Version.new(WAZ::Storage::Version)
17
+
18
+ gem.test_files = Dir['tests/**/*']
19
+
20
+ gem.has_rdoc = true
21
+ gem.rdoc_options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
22
+
23
+ gem.add_dependency 'rest-client'
24
+ gem.add_dependency 'ruby-hmac'
25
+
26
+ gem.add_development_dependency 'rspec'
27
+ gem.add_development_dependency 'rcov'
28
+ gem.add_development_dependency 'mocha'
29
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sparqcode-waz-storage
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 1
10
+ version: 1.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Johnny G. Halife
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-04 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rest-client
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: ruby-hmac
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rcov
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: mocha
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ type: :development
89
+ version_requirements: *id005
90
+ 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.
91
+ email:
92
+ - johnny.halife@me.com
93
+ executables: []
94
+
95
+ extensions: []
96
+
97
+ extra_rdoc_files: []
98
+
99
+ files:
100
+ - .gitignore
101
+ - CHANGELOG.rdoc
102
+ - Gemfile
103
+ - Gemfile.lock
104
+ - LICENSE
105
+ - README.rdoc
106
+ - lib/waz-blobs.rb
107
+ - lib/waz-queues.rb
108
+ - lib/waz-storage.rb
109
+ - lib/waz-tables.rb
110
+ - lib/waz/blobs/blob_object.rb
111
+ - lib/waz/blobs/container.rb
112
+ - lib/waz/blobs/exceptions.rb
113
+ - lib/waz/blobs/service.rb
114
+ - lib/waz/queues/exceptions.rb
115
+ - lib/waz/queues/message.rb
116
+ - lib/waz/queues/queue.rb
117
+ - lib/waz/queues/service.rb
118
+ - lib/waz/storage/base.rb
119
+ - lib/waz/storage/core_service.rb
120
+ - lib/waz/storage/exceptions.rb
121
+ - lib/waz/storage/validation_rules.rb
122
+ - lib/waz/storage/version.rb
123
+ - lib/waz/tables/edm_type_helper.rb
124
+ - lib/waz/tables/exceptions.rb
125
+ - lib/waz/tables/service.rb
126
+ - lib/waz/tables/table.rb
127
+ - lib/waz/tables/table_array.rb
128
+ - rakefile
129
+ - tests/configuration.rb
130
+ - tests/waz/blobs/blob_object_test.rb
131
+ - tests/waz/blobs/container_test.rb
132
+ - tests/waz/blobs/service_test.rb
133
+ - tests/waz/queues/message_test.rb
134
+ - tests/waz/queues/queue_test.rb
135
+ - tests/waz/queues/service_test.rb
136
+ - tests/waz/storage/base_tests.rb
137
+ - tests/waz/storage/shared_key_core_service_test.rb
138
+ - tests/waz/tables/service_test.rb
139
+ - tests/waz/tables/table_test.rb
140
+ - waz-storage.gemspec
141
+ homepage: http://waz-storage.heroku.com
142
+ licenses: []
143
+
144
+ post_install_message:
145
+ rdoc_options:
146
+ - --line-numbers
147
+ - --inline-source
148
+ - -A cattr_accessor=object
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ hash: 3
157
+ segments:
158
+ - 0
159
+ version: "0"
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ requirements: []
170
+
171
+ rubyforge_project:
172
+ rubygems_version: 1.8.21
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: Client library for Windows Azure's Storage Service REST API
176
+ test_files:
177
+ - tests/configuration.rb
178
+ - tests/waz/blobs/blob_object_test.rb
179
+ - tests/waz/blobs/container_test.rb
180
+ - tests/waz/blobs/service_test.rb
181
+ - tests/waz/queues/message_test.rb
182
+ - tests/waz/queues/queue_test.rb
183
+ - tests/waz/queues/service_test.rb
184
+ - tests/waz/storage/base_tests.rb
185
+ - tests/waz/storage/shared_key_core_service_test.rb
186
+ - tests/waz/tables/service_test.rb
187
+ - tests/waz/tables/table_test.rb