Class: Scalarium

Inherits:
Object
  • Object
show all
Includes:
Api
Defined in:
lib/scalarium/api.rb,
lib/scalarium.rb,
lib/scalarium/app.rb,
lib/scalarium/cli.rb,
lib/scalarium/rol.rb,
lib/scalarium/cloud.rb,
lib/scalarium/version.rb,
lib/scalarium/instance.rb,
lib/scalarium/resource.rb

Defined Under Namespace

Modules: Api Classes: App, CLI, Cloud, CloudNotFound, Resource

Constant Summary collapse

VERSION =
"0.4.4"

Instance Method Summary collapse

Methods included from Api

#get, #post

Constructor Details

#initialize(token) ⇒ Scalarium

Returns a new instance of Scalarium.



19
20
21
# File 'lib/scalarium.rb', line 19

def initialize(token)
  @token = token
end

Instance Method Details

#appsObject



41
42
43
44
# File 'lib/scalarium.rb', line 41

def apps
  return @apps if @apps
  @apps = get('applications').map{ |app|  App.new(@token,app) }
end

#cloudsObject



23
24
25
26
# File 'lib/scalarium.rb', line 23

def clouds
  return @clouds if @clouds
  @clouds = get('clouds').map{|c| Cloud.new(@token,c) }
end

#find_app(name) ⇒ Object



46
47
48
# File 'lib/scalarium.rb', line 46

def find_app(name)
  apps.find{|c| c.name.downcase == name.downcase}
end

#find_cloud(name) ⇒ Object



28
29
30
# File 'lib/scalarium.rb', line 28

def find_cloud(name)
  clouds.find{|c| c.name.downcase == name.downcase}
end

#find_clouds(names) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/scalarium.rb', line 32

def find_clouds(names)
  return clouds if names == "all"
  clouds = []
  names.split(",").each do |cloud_name|
    clouds << find_cloud(cloud_name) or raise CloudNotFound.new(cloud_names)
  end
  clouds
end