Class: Stubby::Master

Inherits:
Object
  • Object
show all
Defined in:
lib/stubby/master.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environments) ⇒ Master

Returns a new instance of Master.



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/stubby/master.rb', line 145

def initialize(environments)
  @extensions = {
    default:    Stubby::Extensions::Default.new,
    dns:        Stubby::Extensions::DNS::Server.new,
    http:       Stubby::Extensions::HTTP::Server.new,
    https:      Stubby::Extensions::HTTP::SSLServer.new,
    smtp:       Stubby::Extensions::SMTP::Server.new
  }

  @config = Api
  @config.environments = environments
  @config.master = self
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



143
144
145
# File 'lib/stubby/master.rb', line 143

def config
  @config
end

#extensionsObject

Returns the value of attribute extensions.



143
144
145
# File 'lib/stubby/master.rb', line 143

def extensions
  @extensions
end

Instance Method Details

#environmentObject



171
172
173
# File 'lib/stubby/master.rb', line 171

def environment
  @config.environment
end

#environment=(environment) ⇒ Object



159
160
161
# File 'lib/stubby/master.rb', line 159

def environment=(environment)
  @config.environment = environment
end

#key(identifier) ⇒ Object



163
164
165
# File 'lib/stubby/master.rb', line 163

def key(identifier)
  Digest::MD5.hexdigest(user_key + identifier)
end

#restore!Object



183
184
185
# File 'lib/stubby/master.rb', line 183

def restore!
  restore_extensions
end

#run!(options = {}) ⇒ Object



175
176
177
178
179
180
181
# File 'lib/stubby/master.rb', line 175

def run!(options={})
  run_network do
    run_master do
      run_extensions
    end 
  end
end

#stop!Object



187
188
189
190
191
192
193
194
195
196
197
# File 'lib/stubby/master.rb', line 187

def stop!
  puts "Shutting down..."

  Api.stop!

  running.each do |process|
    Process.shutdown(process)
  end

  puts "Bye."
end

#user_keyObject



167
168
169
# File 'lib/stubby/master.rb', line 167

def user_key
  @user_key ||= read_key
end