Class: MvcDeployment

Inherits:
Object
  • Object
show all
Defined in:
lib/configured_as/mvc_deployment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMvcDeployment

Returns a new instance of MvcDeployment.



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

def initialize()
  set_defaults
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



11
12
13
# File 'lib/configured_as/mvc_deployment.rb', line 11

def after
  @after
end

#beforeObject

Returns the value of attribute before.



10
11
12
# File 'lib/configured_as/mvc_deployment.rb', line 10

def before
  @before
end

#deploy_zip_pathObject

Returns the value of attribute deploy_zip_path.



9
10
11
# File 'lib/configured_as/mvc_deployment.rb', line 9

def deploy_zip_path
  @deploy_zip_path
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/configured_as/mvc_deployment.rb', line 7

def description
  @description
end

#environmentObject

Returns the value of attribute environment.



2
3
4
# File 'lib/configured_as/mvc_deployment.rb', line 2

def environment
  @environment
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#ipaddressObject

Returns the value of attribute ipaddress.



6
7
8
# File 'lib/configured_as/mvc_deployment.rb', line 6

def ipaddress
  @ipaddress
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/configured_as/mvc_deployment.rb', line 5

def port
  @port
end

#site_nameObject

Returns the value of attribute site_name.



8
9
10
# File 'lib/configured_as/mvc_deployment.rb', line 8

def site_name
  @site_name
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/configured_as/mvc_deployment.rb', line 4

def to
  @to
end

Instance Method Details

#add_machine_name_host_header(server, header) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/configured_as/mvc_deployment.rb', line 73

def add_machine_name_host_header(server, header)
  hostname = `hostname`
  updated_header = header.gsub("<machinename>", hostname.gsub("\n", ""))
      
  iis = IIS.server
  iis.set_extra_header(server, updated_header, self)    
end

#call_method(method_name, server, param) ⇒ Object



158
159
160
161
162
163
164
165
166
# File 'lib/configured_as/mvc_deployment.rb', line 158

def call_method(method_name, server, param)  
  if self.respond_to?(method_name)
    if self.method(method_name).arity == 2
      self.send(method_name, server, param) 
    else
      self.send(method_name, param) 
    end
  end
end

#cmd(server, command) ⇒ Object



99
100
101
# File 'lib/configured_as/mvc_deployment.rb', line 99

def cmd(server, command)
  `#{command}`
end

#deploy(server) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/configured_as/mvc_deployment.rb', line 126

def deploy(server)  
  execute_before_methods(server)
      
  location = get_location(server)
  
  fm = FileManager.new
  latest_version_location = fm.get_latest_version(location, self.site_name)
  
  fm.extract(latest_version_location, self.deploy_zip_path, self.environment)
  
  iis = IIS.new
  iis.deploy(server, latest_version_location, self)
  
  execute_after_methods(server)    
end

#execute_after_methods(server) ⇒ Object



150
151
152
153
154
155
156
# File 'lib/configured_as/mvc_deployment.rb', line 150

def execute_after_methods(server)
  unless self.after.nil?
    self.after.each do |k, v|
      call_method(k, server, v)
    end
  end
end

#execute_before_methods(server) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/configured_as/mvc_deployment.rb', line 142

def execute_before_methods(server)
  unless self.before.nil?
    self.before.each do |k, v|
      call_method(k, server, v)
    end
  end
end

#extra_header(server, header) ⇒ Object

Header will contain array of all the headers being added



81
82
83
84
# File 'lib/configured_as/mvc_deployment.rb', line 81

def extra_header(server, header) #Header will contain array of all the headers being added
  iis = IIS.server
  iis.set_extra_header(server, header, self)
end

#get_deploy_to_location(server) ⇒ Object



117
118
119
# File 'lib/configured_as/mvc_deployment.rb', line 117

def get_deploy_to_location(server)
  self.to.select{|t| t.server == server}
end

#get_location(server) ⇒ Object



121
122
123
124
# File 'lib/configured_as/mvc_deployment.rb', line 121

def get_location(server)
  servers = get_deploy_to_location(server)
  servers[0].path
end

#iis(server, command) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/configured_as/mvc_deployment.rb', line 103

def iis(server, command)
  iis = IIS.server
  
  i = 0
  while i < command.length
    type = command[i]
    cmd = command[i + 1]

    iis.execute_admin(type, cmd, self)
    i = i + 2
  end      

end

#set_after(block) ⇒ Object



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

def set_after(block)
  self.after = block
end

#set_before(block) ⇒ Object



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

def set_before(block)
  self.before = block
end

#set_defaultsObject



17
18
19
20
# File 'lib/configured_as/mvc_deployment.rb', line 17

def set_defaults()
  self.port = 80
  self.description = "MvcDeployment"
end

#set_deploy(path) ⇒ Object



26
27
28
# File 'lib/configured_as/mvc_deployment.rb', line 26

def set_deploy(path)
  self.deploy_zip_path = path    
end

#set_description(desc) ⇒ Object



30
31
32
# File 'lib/configured_as/mvc_deployment.rb', line 30

def set_description(desc)
  self.description = desc
end

#set_environment(env) ⇒ Object



46
47
48
# File 'lib/configured_as/mvc_deployment.rb', line 46

def set_environment(env)
  self.environment = env
end

#set_host(header) ⇒ Object



34
35
36
# File 'lib/configured_as/mvc_deployment.rb', line 34

def set_host(header)
  self.host = header
end

#set_ipaddress(address) ⇒ Object



38
39
40
# File 'lib/configured_as/mvc_deployment.rb', line 38

def set_ipaddress(address)
  self.ipaddress = address
end

#set_name(name) ⇒ Object



22
23
24
# File 'lib/configured_as/mvc_deployment.rb', line 22

def set_name(name)
  self.site_name = name
end

#set_port(num) ⇒ Object



42
43
44
# File 'lib/configured_as/mvc_deployment.rb', line 42

def set_port(num)
  self.port = num
end

#set_to(locations) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/configured_as/mvc_deployment.rb', line 50

def set_to(locations)
  self.to = []

  i = 0
  while i < locations.length
    location = DeployTo.new
    location.server = locations[i]
    location.path = locations[i + 1]
    location.ipaddress = locations[i + 2]

    self.to << location
    i = i + 3
  end      
end

#virtual_directory(server, vDirInfo) ⇒ Object

Directories will contain array of all the virtual directories being added



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/configured_as/mvc_deployment.rb', line 86

def virtual_directory(server, vDirInfo) #Directories will contain array of all the virtual directories being added    
  iis = IIS.server
  
  i = 0
  while i < vDirInfo.length
    name = vDirInfo[i]
    path = vDirInfo[i + 1]

    iis.create_virtual_directory(name, path, self)
    i = i + 2
  end      
end