Class: Appshot

Inherits:
Object
  • Object
show all
Defined in:
lib/appshot.rb,
lib/appshot/version.rb,
lib/appshot/app/mysql.rb,
lib/appshot/app/redis.rb,
lib/appshot/app/mongodb.rb,
lib/appshot/filesystem/dm.rb,
lib/appshot/volume/ebs_prune.rb,
lib/appshot/volume/ebs_volume.rb,
lib/appshot/volume/ebs_snapshot.rb

Defined Under Namespace

Classes: DM, EBS_Prune, EBS_Snapshot, EBS_Volume, MongoDB, Mysql, Redis

Constant Summary collapse

VERSION =
"0.0.7"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Appshot

Returns a new instance of Appshot.



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

def initialize(config)
  @appshots = {}
  @callables = []
  instance_eval(config)
end

Instance Method Details

#appshot(appshot_name, &block) ⇒ Object

DSL Keywords



28
29
30
31
32
33
# File 'lib/appshot.rb', line 28

def appshot(appshot_name, &block)
  if block_given?
    @callables = []
    @appshots[appshot_name.to_s] = instance_eval(&block)
  end
end

#appshot_countObject



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

def appshot_count
  @appshots.size
end

#appshot_namesObject



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

def appshot_names
  @appshots ? @appshots.keys : []
end

#appshotsObject

Internals



71
72
73
# File 'lib/appshot.rb', line 71

def appshots
  @appshots
end

#comment(arg) ⇒ Object



35
36
37
# File 'lib/appshot.rb', line 35

def comment(arg)
  @callables
end

#ebs_prune(args = {}) ⇒ Object



63
64
65
# File 'lib/appshot.rb', line 63

def ebs_prune(args={})
  @callables << Appshot::EBS_Prune.new(args)
end

#ebs_snapshot(args = {}) ⇒ Object



47
48
49
# File 'lib/appshot.rb', line 47

def ebs_snapshot(args={})
  @callables << Appshot::EBS_Snapshot.new(args)
end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  true
end

#execute_callablesObject



75
76
77
78
79
80
# File 'lib/appshot.rb', line 75

def execute_callables
  @appshots.each do |appshot, callable|
    first_call = callable.shift
    first_call.call(callable) unless first_call.nil?
  end
end

#ext4(args = {}) ⇒ Object



43
44
45
# File 'lib/appshot.rb', line 43

def ext4(args={})
  @callables << Appshot::DM.new(args)
end

#list_appshotsObject



90
91
92
93
94
95
96
97
98
99
# File 'lib/appshot.rb', line 90

def list_appshots
  case @appshots.count
  when 0
    "There are no appshots configured"
  when 1
    "There is one appshot configured: #{@appshots.keys.first.to_s}"
  else
    "There are #{@appshots.count} appshots configured: #{@appshots.keys.join(', ')}"
  end
end

#mongodb(args = {}) ⇒ Object



55
56
57
# File 'lib/appshot.rb', line 55

def mongodb(args={})
  @callables << Appshot::MongoDB.new(args)
end

#mysql(args = {}) ⇒ Object



51
52
53
# File 'lib/appshot.rb', line 51

def mysql(args={})
  @callables << Appshot::Mysql.new(args)
end

#redis(args = {}) ⇒ Object



59
60
61
# File 'lib/appshot.rb', line 59

def redis(args={})
  @callables << Appshot::Redis.new(args)
end

#run_pass(options, args) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/appshot.rb', line 82

def run_pass(options, args)
  if options["list-appshots"]
    puts list_appshots if options["list-appshots"]
  else
    execute_callables unless options["trial-run"]
  end
end

#xfs(args = {}) ⇒ Object



39
40
41
# File 'lib/appshot.rb', line 39

def xfs(args={})
  @callables << Appshot::DM.new(args)
end