Class: EmberCliDeploy::Index
- Inherits:
-
Object
- Object
- EmberCliDeploy::Index
- Defined in:
- lib/ember_cli_deploy.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #activate(version) ⇒ Object
- #active ⇒ Object
- #deactivate ⇒ Object
- #html(version = nil) ⇒ Object
-
#initialize(namespace, redis_url) ⇒ Index
constructor
A new instance of Index.
- #latest ⇒ Object
- #revisions ⇒ Object
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
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/ember_cli_deploy.rb', line 6 def namespace @namespace end |
#redis ⇒ Object (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 |
#active ⇒ Object
21 22 23 |
# File 'lib/ember_cli_deploy.rb', line 21 def active redis.get("#{namespace}:current") end |
#deactivate ⇒ Object
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 |
#latest ⇒ Object
17 18 19 |
# File 'lib/ember_cli_deploy.rb', line 17 def latest revisions.first end |
#revisions ⇒ Object
13 14 15 |
# File 'lib/ember_cli_deploy.rb', line 13 def revisions redis.zrevrange("#{namespace}:revisions", 0, -1) end |