Class: Glitter::Server
- Inherits:
-
Object
- Object
- Glitter::Server
- Defined in:
- lib/glitter/server.rb
Constant Summary collapse
- DEFAULT_S3_TIMEOUT =
60
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
readonly
Returns the value of attribute access_key_id.
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#secret_access_key ⇒ Object
readonly
Returns the value of attribute secret_access_key.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #bucket ⇒ Object
- #channel(name) ⇒ Object
-
#channel_versions ⇒ Object
Iterate through the objects in S3 and return a hash of channels containing their respective released versions.
-
#initialize(access_key_id = ENV['AWS_ACCESS_KEY_ID'], secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'], bucket_name = ENV['AWS_BUCKET_NAME'], timeout: DEFAULT_S3_TIMEOUT) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(access_key_id = ENV['AWS_ACCESS_KEY_ID'], secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'], bucket_name = ENV['AWS_BUCKET_NAME'], timeout: DEFAULT_S3_TIMEOUT) ⇒ Server
Returns a new instance of Server.
12 13 14 15 16 17 |
# File 'lib/glitter/server.rb', line 12 def initialize(access_key_id = ENV['AWS_ACCESS_KEY_ID'], secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'], bucket_name = ENV['AWS_BUCKET_NAME'], timeout: DEFAULT_S3_TIMEOUT) @access_key_id = access_key_id @secret_access_key = secret_access_key @bucket_name = bucket_name @timeout = timeout end |
Instance Attribute Details
#access_key_id ⇒ Object (readonly)
Returns the value of attribute access_key_id.
8 9 10 |
# File 'lib/glitter/server.rb', line 8 def access_key_id @access_key_id end |
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
8 9 10 |
# File 'lib/glitter/server.rb', line 8 def bucket_name @bucket_name end |
#secret_access_key ⇒ Object (readonly)
Returns the value of attribute secret_access_key.
8 9 10 |
# File 'lib/glitter/server.rb', line 8 def secret_access_key @secret_access_key end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/glitter/server.rb', line 8 def timeout @timeout end |
Instance Method Details
#bucket ⇒ Object
23 24 25 |
# File 'lib/glitter/server.rb', line 23 def bucket @bucket ||= s3.buckets.find bucket_name end |
#channel(name) ⇒ Object
19 20 21 |
# File 'lib/glitter/server.rb', line 19 def channel(name) channels[name] end |
#channel_versions ⇒ Object
Iterate through the objects in S3 and return a hash of channels containing their respective released versions.
29 30 31 32 33 34 35 |
# File 'lib/glitter/server.rb', line 29 def channel_versions bucket.objects.inject Hash.new { |h,k| h[k] = Set.new } do |hash, object| channel, version, _ = Release.object_segments(object.key) hash[channel].add(version) if channel and version hash end end |