Class: UcbDeployer::Deployer Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ucb_deployer/deployer.rb

Overview

This class is abstract.

Subclass and override {#export, #build, #configure, #deploy,

#rollback} to implement a custom UcbDeployer class

Author:

  • Steven Hansen

Direct Known Subclasses

ConfluenceDeployer, JiraDeployer

Constant Summary collapse

CONFIG_OPTIONS =
[
  :build_dir,
  :deploy_dir,
  :war_name,
  :cas_service_url,
  :cas_server_url,
  :data_dir,
  :maintenance_file_dir,                      
  :svn_project_url,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debug_modeObject

Returns the value of attribute debug_mode.



23
24
25
# File 'lib/ucb_deployer/deployer.rb', line 23

def debug_mode
  @debug_mode
end

#versionObject

Returns the value of attribute version.



23
24
25
# File 'lib/ucb_deployer/deployer.rb', line 23

def version
  @version
end

Instance Method Details

#buildObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/ucb_deployer/deployer.rb', line 34

def build()
  raise NotImplementedError
end

#configureObject

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/ucb_deployer/deployer.rb', line 30

def configure()
  raise NotImplementedError
end

#debug(str) ⇒ Object



83
84
85
# File 'lib/ucb_deployer/deployer.rb', line 83

def debug(str)
  UcbDeployer.debug(str)
end

#deployObject

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/ucb_deployer/deployer.rb', line 42

def deploy()
  raise NotImplementedError
end

#deployer_homeObject



75
76
77
# File 'lib/ucb_deployer/deployer.rb', line 75

def deployer_home()
  ::UcbDeployer::DEPLOYER_HOME
end

#disable_webObject



91
92
93
94
95
96
97
98
# File 'lib/ucb_deployer/deployer.rb', line 91

def disable_web()
  return unless maintenance_file_dir()
  maint_start = Time.now.strftime("%m-%d-%Y %H:%M:%S")
  template = ERB.new(maintenance_template)
  File.open("#{maintenance_file_dir}/maintenance.html", "w") do |f|
    f.puts template.result(binding)
  end
end

#enable_webObject



100
101
102
103
# File 'lib/ucb_deployer/deployer.rb', line 100

def enable_web()
  return unless maintenance_file_dir()      
  FileUtils.rm("#{maintenance_file_dir}/maintenance.html")
end

#exportObject

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/ucb_deployer/deployer.rb', line 26

def export()
  raise NotImplementedError
end

#info(str) ⇒ Object



87
88
89
# File 'lib/ucb_deployer/deployer.rb', line 87

def info(str)
  UcbDeployer.info(str)
end

#load_config(config_file) ⇒ Object

Configuration options are:

build_dir deploy_dir war_name svn_project_url cas_service_url cas_server_url maintenance_file_dir

data_dir



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ucb_deployer/deployer.rb', line 58

def load_config(config_file)
  if !(hash = YAML.load_file(config_file))
    raise(ConfigError, "Config file [#{config_file}] contains no options.")
  end
  
  debug("Config options:")
  debug("")      
  hash.each do |key, val|
    debug("#{key}: #{val}")      
    if CONFIG_OPTIONS.include?(key.to_sym)
      self.send("#{key}=", val)
    else
      raise(ConfigError, "Unrecognized Option: #{key}")
    end
  end
end

#maintenance_templateObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/ucb_deployer/deployer.rb', line 105

def maintenance_template()
  %q{
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>Site Maintenance</title>
  <style type="text/css">
  body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  div.dialog {
  width: 35em;
  padding: 0 3em;
  margin: 3em auto 0 auto;
  border: 1px solid #ccc;
  border-right-color: #999;
  border-bottom-color: #999;
  }
  h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  </style>
</head>

<body>
  <div class="dialog">
<h1>Site Maintenance</h1>
<p>
    The site is down for maintenance as of: <strong><%= maint_start %></strong> <br/>
    it should be available shortly.
</p>
  </div>
</body>
</html>
}
end

#resources_dirObject



79
80
81
# File 'lib/ucb_deployer/deployer.rb', line 79

def resources_dir()
  ::UcbDeployer::RESOURCES_DIR
end

#rollbackObject

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/ucb_deployer/deployer.rb', line 38

def rollback()
  raise NotImplementedError
end