waz-storage 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/waz-storage.rb +11 -0
- data/lib/waz/blobs/blob_object.rb +3 -2
- data/lib/waz/blobs/container.rb +2 -1
- data/lib/waz/queues/message.rb +2 -1
- data/lib/waz/queues/queue.rb +2 -1
- data/lib/waz/storage/base.rb +33 -3
- data/lib/waz/storage/version.rb +1 -1
- data/rakefile +0 -1
- metadata +2 -2
data/lib/waz-storage.rb
CHANGED
@@ -3,3 +3,14 @@ require 'waz/storage/base'
|
|
3
3
|
require 'waz/storage/core_service'
|
4
4
|
require 'waz/storage/exceptions'
|
5
5
|
require 'waz/storage/version'
|
6
|
+
|
7
|
+
# It will depende on which version of Ruby (or if you have Rails)
|
8
|
+
# but this method is required so we will add it the String class.
|
9
|
+
unless String.method_defined? :start_with?
|
10
|
+
class String
|
11
|
+
def starts_with?(prefix)
|
12
|
+
prefix = prefix.to_s
|
13
|
+
self[0, prefix.length] == prefix
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -30,8 +30,9 @@ module WAZ
|
|
30
30
|
# service that wraps the calls the Windows Azure Blobs API. It's initialized with the values
|
31
31
|
# from the default_connection on WAZ::Storage::Base initialized thru establish_connection!
|
32
32
|
def service_instance
|
33
|
-
|
34
|
-
|
33
|
+
options = WAZ::Storage::Base.default_connection.merge(:type_of_service => "blob")
|
34
|
+
(@service_instances ||= {})[:account_name] ||= Service.new(options)
|
35
|
+
end
|
35
36
|
end
|
36
37
|
|
37
38
|
attr_accessor :name, :url, :content_type
|
data/lib/waz/blobs/container.rb
CHANGED
@@ -64,7 +64,8 @@ module WAZ
|
|
64
64
|
# service that wraps the calls the Windows Azure Blobs API. It's initialized with the values
|
65
65
|
# from the default_connection on WAZ::Storage::Base initialized thru establish_connection!
|
66
66
|
def service_instance
|
67
|
-
|
67
|
+
options = WAZ::Storage::Base.default_connection.merge(:type_of_service => "blob")
|
68
|
+
(@service_instances ||= {})[:account_name] ||= Service.new(options)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
data/lib/waz/queues/message.rb
CHANGED
@@ -28,7 +28,8 @@ module WAZ
|
|
28
28
|
# service that wraps the calls the Windows Azure Queues API. It's initialized with the values
|
29
29
|
# from the default_connection on WAZ::Storage::Base initialized thru establish_connection!
|
30
30
|
def service_instance
|
31
|
-
|
31
|
+
options = WAZ::Storage::Base.default_connection.merge(:type_of_service => "queue")
|
32
|
+
(@service_instances ||= {})[:account_name] ||= Service.new(options)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
data/lib/waz/queues/queue.rb
CHANGED
@@ -71,7 +71,8 @@ module WAZ
|
|
71
71
|
# service that wraps the calls the Windows Azure Queues API. It's initialized with the values
|
72
72
|
# from the default_connection on WAZ::Storage::Base initialized thru establish_connection!
|
73
73
|
def service_instance
|
74
|
-
|
74
|
+
options = WAZ::Storage::Base.default_connection.merge(:type_of_service => "queue")
|
75
|
+
(@service_instances ||= {})[:account_name] ||= Service.new(options)
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
data/lib/waz/storage/base.rb
CHANGED
@@ -18,19 +18,49 @@ module WAZ
|
|
18
18
|
raise InvalidOption, :account_name unless options.keys.include? :account_name
|
19
19
|
raise InvalidOption, :access_key unless options.keys.include? :access_key
|
20
20
|
options[:use_ssl] = false unless options.keys.include? :use_ssl
|
21
|
-
@
|
21
|
+
(@connections ||= []) << options
|
22
|
+
end
|
23
|
+
|
24
|
+
# Block Syntax
|
25
|
+
#
|
26
|
+
# Pushes the named repository onto the context-stack,
|
27
|
+
# yields a new session, and pops the context-stack.
|
28
|
+
#
|
29
|
+
# This helps you set contextual operations like in the following sample
|
30
|
+
#
|
31
|
+
# Base.establish_connection(options) do
|
32
|
+
# # do some operations on the given context
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# The context is restored to the previous one (what you configured on establish_connection!)
|
36
|
+
# or nil.
|
37
|
+
#
|
38
|
+
# Non-Block Syntax
|
39
|
+
#
|
40
|
+
# Behaves exactly as establish_connection!
|
41
|
+
def establish_connection(options = {}) # :yields: current_context
|
42
|
+
establish_connection!(options)
|
43
|
+
if (block_given?)
|
44
|
+
begin
|
45
|
+
return yield
|
46
|
+
ensure
|
47
|
+
@connections.pop() if connected?
|
48
|
+
end
|
49
|
+
end
|
22
50
|
end
|
23
51
|
|
24
52
|
# Returns the default connection (last set) parameters. It will raise an exception WAZ::Storage::NotConnected
|
25
53
|
# when there's no connection information registered.
|
26
54
|
def default_connection
|
27
55
|
raise NotConnected unless connected?
|
28
|
-
return @
|
56
|
+
return @connections.last
|
29
57
|
end
|
30
58
|
|
31
59
|
# Returns a value indicating whether the current connection information has been set or not.
|
32
60
|
def connected?
|
33
|
-
return
|
61
|
+
return false if (@connections.nil?)
|
62
|
+
return false if (@connections.empty?)
|
63
|
+
return true
|
34
64
|
end
|
35
65
|
end
|
36
66
|
end
|
data/lib/waz/storage/version.rb
CHANGED
data/rakefile
CHANGED
@@ -8,7 +8,6 @@ require 'lib/waz-storage'
|
|
8
8
|
|
9
9
|
namespace :test do
|
10
10
|
Spec::Rake::SpecTask.new('run_with_rcov') do |t|
|
11
|
-
puts "running tests and code coverage"
|
12
11
|
t.spec_files = FileList['tests/waz/queues/*.rb', 'tests/waz/blobs/*.rb', 'tests/waz/storage/*.rb']
|
13
12
|
t.rcov = true
|
14
13
|
t.rcov_opts = ['--text-report', '--exclude', "exclude.*/.gem,test,Library,#{ENV['GEM_HOME']}", '--sort', 'coverage' ]
|
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: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnny G. Halife
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-17 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|