Class: Scalarium

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

Defined Under Namespace

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

Constant Summary

VERSION =
"0.4.1"

Instance Method Summary (collapse)

Methods included from Api

#get, #post

Constructor Details

- (Scalarium) initialize(token)

Returns a new instance of Scalarium



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

def initialize(token)
  @token = token
end

Instance Method Details

- (Object) apps



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

- (Object) clouds



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

- (Object) find_app(name)



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

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

- (Object) find_cloud(name)



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

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

- (Object) find_clouds(names)



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