Class: EmberCliDeploy::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/ember_cli_deploy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, redis_url) ⇒ Index

Returns a new instance of Index.



8
9
10
11
# File 'lib/ember_cli_deploy.rb', line 8

def initialize(namespace, redis_url)
  @namespace = "#{namespace}:index"
  @redis = Redis.new(url: redis_url)
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/ember_cli_deploy.rb', line 6

def namespace
  @namespace
end

#redisObject (readonly)

Returns the value of attribute redis.



6
7
8
# File 'lib/ember_cli_deploy.rb', line 6

def redis
  @redis
end

Instance Method Details

#activate(version) ⇒ Object



25
26
27
# File 'lib/ember_cli_deploy.rb', line 25

def activate(version)
  redis.set("#{namespace}:current", version)
end

#activeObject



21
22
23
# File 'lib/ember_cli_deploy.rb', line 21

def active
  redis.get("#{namespace}:current")
end

#deactivateObject



29
30
31
# File 'lib/ember_cli_deploy.rb', line 29

def deactivate
  redis.del("#{namespace}:current")
end

#html(version = nil) ⇒ Object



33
34
35
36
37
# File 'lib/ember_cli_deploy.rb', line 33

def html(version = nil)
  version = active if version.blank?
  version = latest if version == 'latest'
  redis.get("#{namespace}:#{version}")
end

#latestObject



17
18
19
# File 'lib/ember_cli_deploy.rb', line 17

def latest
  revisions.first
end

#revisionsObject



13
14
15
# File 'lib/ember_cli_deploy.rb', line 13

def revisions
  redis.zrevrange("#{namespace}:revisions", 0, -1)
end