snapshot-ruby 0.3.1 → 0.3.2
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/snapshot.rb +3 -3
- data/lib/snapshot/connection.rb +4 -4
- data/lib/snapshot/token.rb +9 -0
- data/lib/snapshot/version.rb +1 -1
- metadata +1 -1
data/lib/snapshot.rb
CHANGED
@@ -17,15 +17,15 @@ module Snapshot
|
|
17
17
|
# ==== Examples
|
18
18
|
#
|
19
19
|
# # Using a String:
|
20
|
-
# Snapshot.configure('http://access_key:secret_ket@subdomain.
|
20
|
+
# Snapshot.configure('http://access_key:secret_ket@subdomain.snapshotapi.com/')
|
21
21
|
#
|
22
22
|
# # Using a Hash:
|
23
|
-
# Snapshot.configure(:access_key => 'access_key', :
|
23
|
+
# Snapshot.configure(:access_key => 'access_key', :container => 'subdomain', :secret_key => 'secret_key')
|
24
24
|
#
|
25
25
|
# # Using a block:
|
26
26
|
# Snapshot.configure do |config|
|
27
27
|
# config.access_key = 'access_key'
|
28
|
-
# config.
|
28
|
+
# config.container = 'subdomain'
|
29
29
|
# config.secret_key = 'secret_key
|
30
30
|
# end
|
31
31
|
#
|
data/lib/snapshot/connection.rb
CHANGED
@@ -6,7 +6,7 @@ require 'time'
|
|
6
6
|
|
7
7
|
module Snapshot
|
8
8
|
class Connection
|
9
|
-
attr_accessor :access_key, :
|
9
|
+
attr_accessor :access_key, :container, :secret_key
|
10
10
|
|
11
11
|
# Creates a new Connection object.
|
12
12
|
#
|
@@ -21,8 +21,8 @@ module Snapshot
|
|
21
21
|
end
|
22
22
|
else
|
23
23
|
uri = URI.parse(opts)
|
24
|
-
self.
|
25
|
-
self.
|
24
|
+
self.container = uri.host.match(/(.+)\.snapshotapi\.com/)[1]
|
25
|
+
self.access_key, self.secret_key = uri.user, uri.password
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -41,7 +41,7 @@ module Snapshot
|
|
41
41
|
# Returns a URL to Snapshot for the connection
|
42
42
|
#
|
43
43
|
def url
|
44
|
-
"http://#{
|
44
|
+
"http://#{container}.snapshotapi.com"
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
data/lib/snapshot/token.rb
CHANGED
@@ -15,5 +15,14 @@ module Snapshot
|
|
15
15
|
def to_s
|
16
16
|
token
|
17
17
|
end
|
18
|
+
|
19
|
+
# Allow the Token object to be serialized by Rails.
|
20
|
+
if defined?(ActiveModel::Serialization)
|
21
|
+
include ActiveModel::Serialization
|
22
|
+
|
23
|
+
def attributes
|
24
|
+
{ expires_in: expires_in, token: token }
|
25
|
+
end
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
data/lib/snapshot/version.rb
CHANGED