Class: Cloudspeq
- Inherits:
-
Object
show all
- Defined in:
- lib/cloudspeq.rb,
lib/cloudspeq/version.rb,
lib/cloudspeq/providers/base.rb,
lib/cloudspeq/providers/base.rb,
lib/cloudspeq/rspec_outputter.rb,
lib/cloudspeq/distributed_testing.rb,
lib/cloudspeq/providers/digital_ocean.rb
Defined Under Namespace
Classes: DistributedTesting, Providers, RspecOutputter
Constant Summary
collapse
- VERSION =
"0.0.16"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(settings_path = 'cloudspeq.yml') ⇒ Cloudspeq
15
16
17
18
19
20
21
|
# File 'lib/cloudspeq.rb', line 15
def initialize(settings_path= 'cloudspeq.yml')
@settings = Cloudspeq.settings(settings_path)
provider_key = @settings['provider_key']
provider = Object.const_get "Cloudspeq::Providers::" + provider_key.to_s.split("_").collect(&:capitalize).join
@provider = provider.new(@settings)
end
|
Class Method Details
.backup_ssh ⇒ Object
copies current ssh known_hosts to a backup
102
103
104
|
# File 'lib/cloudspeq.rb', line 102
def self.backup_ssh
`cp ~/.ssh/known_hosts ~/.ssh/known_hosts.backup`
end
|
.install ⇒ Object
23
24
25
26
27
|
# File 'lib/cloudspeq.rb', line 23
def self.install
File.open('cloudspeq.yml',"w") do |f|
f.write(DEFAULT_SETTINGS.to_yaml)
end
end
|
.reset_ssh ⇒ Object
restores known_hosts file, keeping backup
110
111
112
|
# File 'lib/cloudspeq.rb', line 110
def self.reset_ssh
`cp ~/.ssh/known_hosts.backup ~/.ssh/known_hosts`
end
|
.restore_ssh ⇒ Object
restores known_hosts file, destroying backup
106
107
108
|
# File 'lib/cloudspeq.rb', line 106
def self.restore_ssh
`mv ~/.ssh/known_hosts.backup ~/.ssh/known_hosts`
end
|
.settings(path = nil) ⇒ Object
29
30
31
|
# File 'lib/cloudspeq.rb', line 29
def self.settings(path=nil)
@settings ||= OpenStruct.new DEFAULT_SETTINGS.merge( YAML.load_file(path) )
end
|
Instance Method Details
#execute(cmd) ⇒ Object
93
94
95
|
# File 'lib/cloudspeq.rb', line 93
def execute(cmd)
provider.exec cmd
end
|
#local_clean_up ⇒ Object
71
72
73
74
75
|
# File 'lib/cloudspeq.rb', line 71
def local_clean_up
@settings['local_clean_up'].each do |command|
`#{command}`
end
end
|
#local_prepare ⇒ Object
64
65
66
67
68
69
|
# File 'lib/cloudspeq.rb', line 64
def local_prepare
output = []
@settings['local_prepare'].each do |command|
`#{command}`
end
end
|
#provider ⇒ Object
42
43
44
|
# File 'lib/cloudspeq.rb', line 42
def provider
@provider
end
|
#refresh ⇒ Object
85
86
87
|
# File 'lib/cloudspeq.rb', line 85
def refresh
provider.refresh
end
|
#remote_clean_up ⇒ Object
58
59
60
61
62
|
# File 'lib/cloudspeq.rb', line 58
def remote_clean_up
@settings['remote_cleanup'].each do |command|
provider.exec(command)
end
end
|
#remote_prepare ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/cloudspeq.rb', line 50
def remote_prepare
output = []
@settings['remote_prepare'].each do |command|
output << provider.exec(command)
end
output
end
|
#root_execute(cmd) ⇒ Object
97
98
99
|
# File 'lib/cloudspeq.rb', line 97
def root_execute(cmd)
provider.root_exec cmd
end
|
#run_tests(n = 1) ⇒ Object
114
115
116
117
118
119
120
|
# File 'lib/cloudspeq.rb', line 114
def run_tests(n=1) output = []
n.times do
output << Cloudspeq::DistributedTesting.perform(@settings, provider.machines)
end
n == 1 ? output.first : output
end
|
#settings ⇒ Object
33
34
35
|
# File 'lib/cloudspeq.rb', line 33
def settings
@settings
end
|
#spool_down(n = ) ⇒ Object
77
78
79
|
# File 'lib/cloudspeq.rb', line 77
def spool_down(n=provider.provider_settings['machine_count'])
provider.destroy provider.machines.first(n)
end
|
#spool_down_all ⇒ Object
81
82
83
|
# File 'lib/cloudspeq.rb', line 81
def spool_down_all
provider.spool_down_all
end
|
#spool_up(n = provider.provider_settings['machine_count']) ⇒ Object
46
47
48
|
# File 'lib/cloudspeq.rb', line 46
def spool_up(n=provider.provider_settings['machine_count'])
provider.create n
end
|
#status ⇒ Object
37
38
39
40
|
# File 'lib/cloudspeq.rb', line 37
def status
refresh
provider.status
end
|
#sync ⇒ Object
89
90
91
|
# File 'lib/cloudspeq.rb', line 89
def sync
provider.sync
end
|