Class: FubuRake::BottleServices

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BottleServices

Returns a new instance of BottleServices.



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/fuburake.rb', line 269

def initialize(options)
  @directory = options[:dir]
  @prefix = options.fetch(:prefix, 'service')
    @command = File.join(@directory, 'BottleServiceRunner')

    consoleTask = Rake::Task.define_task "#{@prefix}:console" do
 sh "start #{@command}"
    end
    consoleTask.add_description "Run service in console at #{@directory}"

  to_task 'install', to_install_args(options), "Install the service locally"
     to_task 'start', to_start_stop_args('start', options), "Start the service locally"
    to_task 'stop', to_start_stop_args('stop', options), "Stop the service locally"
    to_task 'uninstall', to_start_stop_args('uninstall', options), "Stop the service locally"
    
    cleanTask = Rake::Task.define_task "#{@prefix}:clean" do
 dir = File.join(@directory, 'fubu-content')
 cleanDirectory dir
    end
    cleanTask.add_description "Cleans out any exploded bottle content at fubu-content"
end

Instance Method Details

#to_install_args(options) ⇒ Object



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/fuburake.rb', line 305

def to_install_args(options)
  args = "install";
    
    if (options[:name] != nil)
 args += " -servicename:#{options[:name]}"
    end
    
    if (options[:instance] != nil)
 args += " -i:#{options[:instance]}"
    end
    
    if (options[:user] != nil)
 args += " -u:#{options[:user]}"
    end
  
    if (options[:password] != nil)
 args += " -p:#{options[:password]}"
    end

  if (options[:autostart] == true)
 args += " --autostart"
    end
    
    if (options[:manual] == true)
 args += " --manual"
    end
  
    if (options[:disabled] == true)
 args += " --disabled"
    end

    if (options[:delayed] == true)
 args += " --delayed"
    end
    
    if (options[:local_service] == true)
 args += " --localservice"
    end
    
    if (options[:network_service] == true)
 args += " --networkservice"
    end
    
    if (options[:interactive] == true)
 args += " --interactive"
    end
    
    if (options[:description] != nil)
 args += ' -d:"' + options[:description] + "'"
    end
    
    return args
end

#to_start_stop_args(verb, options) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/fuburake.rb', line 291

def to_start_stop_args(verb, options)
  args = "#{verb}"
    
    if (options[:name] != nil)
 args += " -servicename:#{options[:name]}"
    end
    
    if (options[:instance] != nil)
 args += " -i:#{options[:instance]}"
    end
    
    return args
end

#to_task(name, args, description) ⇒ Object



359
360
361
362
363
364
365
366
# File 'lib/fuburake.rb', line 359

def to_task(name, args, description)
  task = Rake::Task.define_task "#{@prefix}:#{name}" do
 sh "#{@command} #{args}"
  end
    
  task.add_description description
  return task
end