Class: Yads::Deployer
- Inherits:
-
Object
show all
- Defined in:
- lib/yads/deployer.rb
Constant Summary
collapse
- CONFIG_FILE =
"config/deploy.yml"
Instance Method Summary
collapse
Constructor Details
#initialize(environment, logger = STDOUT) ⇒ Deployer
Returns a new instance of Deployer.
7
8
9
10
|
# File 'lib/yads/deployer.rb', line 7
def initialize(environment, logger = STDOUT)
@environment = environment
@logger = logger
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/yads/deployer.rb', line 29
def method_missing(name, *args)
if command_names.include?(name.to_s)
commands = ["cd #{config["path"]}", config["commands"][name.to_s]]
commands = commands.join(" && ")
@logger.puts("> #{commands}")
connection.execute(commands) do |output|
@logger.print(output)
end
else
super
end
end
|
Instance Method Details
#command_names ⇒ Object
50
51
52
|
# File 'lib/yads/deployer.rb', line 50
def command_names
config["commands"].keys
end
|
#deploy ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/yads/deployer.rb', line 18
def deploy
commands = config["commands"].values
commands.unshift("cd #{config["path"]}")
commands = commands.join(" && ")
@logger.puts("> #{commands}")
connection.execute(commands) do |output|
@logger.print(output)
end
end
|
#respond_to?(name) ⇒ Boolean
42
43
44
45
46
47
48
|
# File 'lib/yads/deployer.rb', line 42
def respond_to?(name)
if command_names.include?(name.to_s)
true
else
super
end
end
|
#setup ⇒ Object
12
13
14
15
16
|
# File 'lib/yads/deployer.rb', line 12
def setup
command = "mkdir -p #{config["path"]} && cd #{config["path"]} && git clone --depth 1 #{config['repository']} ."
@logger.puts("> #{command}")
@logger.puts(connection.execute(command))
end
|