Module: Inf
- Defined in:
- lib/inf.rb,
lib/version.rb
Defined Under Namespace
Modules: AWS, Migrations
Classes: Domains, Env, Fleet, LoadBalancer
Constant Summary
collapse
- VERSION =
'0.0.21'
Class Method Summary
collapse
Class Method Details
.app_name ⇒ Object
12
13
14
|
# File 'lib/inf.rb', line 12
def self.app_name
ENV['APP_NAME'].downcase
end
|
.cache ⇒ Object
4
5
6
|
# File 'lib/inf.rb', line 4
def self.cache
@cache ||= MiniCache::Store.new
end
|
.delete_state(k) ⇒ Object
53
54
55
|
# File 'lib/inf.rb', line 53
def self.delete_state(k)
s3.delete_object(bucket: state_bucket, key: k) rescue nil
end
|
.get_state(k, opts = {}) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/inf.rb', line 38
def self.get_state(k, opts={})
cache.get_or_set(k) do
begin
object = s3.get_object(bucket: state_bucket, key: k)
if opts[:raw]
object
else
object.body.read
end
rescue Aws::S3::Errors::NoSuchKey
end
end
end
|
.list_state(prefix) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/inf.rb', line 29
def self.list_state(prefix)
s3.list_objects_v2(
bucket: state_bucket,
prefix: prefix,
).contents.map do |it|
yield it.key
end
end
|
.put_state(k, v) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/inf.rb', line 16
def self.put_state(k, v)
v = v.to_s
s3.put_object(
bucket: state_bucket,
key: k,
body: v
)
summary = v.lines.count > 1 ? '[multiline]' : v
cache.unset k
puts "#{k} -> #{summary}".gray
end
|
.state_bucket ⇒ Object
8
9
10
|
# File 'lib/inf.rb', line 8
def self.state_bucket
ENV['STATE_BUCKET'].downcase
end
|