Class: AmazonRelease
- Inherits:
-
Release
show all
- Defined in:
- lib/cluster/infrastructures/amazon_release.rb
Instance Attribute Summary collapse
Attributes inherited from Release
#environment, #label, #tag
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Release
#initialize
Constructor Details
This class inherits a constructor from Release
Instance Attribute Details
#aws_id ⇒ Object
Returns the value of attribute aws_id.
2
3
4
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 2
def aws_id
@aws_id
end
|
Class Method Details
.create(*params) ⇒ Object
40
41
42
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 40
def create(*params)
self.new(*params).save
end
|
.current(environment = 'staging') ⇒ Object
44
45
46
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 44
def current(environment = 'staging')
query_for_release "entry = 'release' AND environment = '#{environment}' AND sdb_created_at IS NOT NULL ORDER BY sdb_created_at DESC limit 1"
end
|
.find(env, tag) ⇒ Object
48
49
50
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 48
def find(env, tag)
query_for_release "entry = 'release' AND environment = '#{env}' AND tag = '#{tag}'"
end
|
.query_for_release(clause) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 52
def query_for_release(clause)
amazon = Infrastructure.current
res = amazon.sdb.select("SELECT * FROM #{amazon.domain} WHERE #{clause}")
args = Amazon.from_sdb_results(res)
if args.empty?
nil
else
self.new(args.first)
end
end
|
Instance Method Details
#amazon ⇒ Object
16
17
18
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 16
def amazon
Infrastructure.current
end
|
#created_at ⇒ Object
4
5
6
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 4
def created_at
@created_at ||= Time.now
end
|
#new? ⇒ Boolean
31
32
33
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 31
def new?
@new_release
end
|
#save ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 20
def save
fields = %w(aws_id label sdb_created_at environment tag)
args = fields.inject({'entry' => 'release'}) {|m, attr|
m.merge attr => self.send(attr)
}
attributes = Amazon.to_sdb_attributes(args)
amazon.sdb.put_attributes(amazon.domain, aws_id, attributes, :replace)
@new_release = true
self
end
|
#sdb_created_at ⇒ Object
8
9
10
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 8
def sdb_created_at
created_at.xmlschema(3)
end
|
#sdb_created_at=(time) ⇒ Object
12
13
14
|
# File 'lib/cluster/infrastructures/amazon_release.rb', line 12
def sdb_created_at=(time)
self.created_at = Time.parse(time)
end
|