Module: Gitploy

Extended by:
Gitploy
Included in:
Gitploy
Defined in:
lib/gitploy.rb

Defined Under Namespace

Classes: Config

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/gitploy.rb', line 3

def config
  @config
end

Instance Method Details

#actionObject



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

def action
  ARGV[1]
end

#configure {|config| ... } ⇒ Object

Yields:



21
22
23
24
25
26
27
28
29
# File 'lib/gitploy.rb', line 21

def configure
  config = Config.new
  yield config; config.check!

  config.local_branch ||= current_branch
  config.remote_branch ||= 'master'

  self.config = config
end

#current_stageObject



31
32
33
# File 'lib/gitploy.rb', line 31

def current_stage
  ARGV[0]
end

#deployObject



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

def deploy
  yield unless action == 'setup'
end

#localObject



56
57
58
59
# File 'lib/gitploy.rb', line 56

def local
  yield
  pretty_run("LOCAL", flush_run_queue)
end

#push!Object



73
74
75
# File 'lib/gitploy.rb', line 73

def push!
  local { run "git push #{config.user}@#{config.host}:#{config.path}/.git #{config.local_branch}:#{config.remote_branch}" }
end

#rake(task) ⇒ Object



69
70
71
# File 'lib/gitploy.rb', line 69

def rake(task)
  run("rake #{task}")
end

#remoteObject



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

def remote
  yield
  pretty_run(config.host, "ssh #{config.user}@#{config.host} '#{flush_run_queue}'")
end

#run(cmd) ⇒ Object



61
62
63
# File 'lib/gitploy.rb', line 61

def run(cmd)
  run_queue << cmd
end

#setupObject



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

def setup
  yield if action == 'setup'
end

#stage(name) ⇒ Object



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

def stage(name)
  yield if name.to_s == current_stage
end

#sudo(cmd) ⇒ Object



65
66
67
# File 'lib/gitploy.rb', line 65

def sudo(cmd)
  run("sudo #{cmd}")
end