Simplify subclassing by adding all arguments to the initializer. Also, clean up the method signatures for existing exporters.
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ class Foreman::CLI < Thor
|
||||
error "Unknown export format: #{format} (unable to load file 'foreman/export/#{ format.tr('-', '_') }')."
|
||||
end
|
||||
|
||||
formatter.new(engine, options).export(location)
|
||||
formatter.new(location, engine, options).export
|
||||
rescue Foreman::Export::Exception => ex
|
||||
error ex.message
|
||||
end
|
||||
|
||||
@@ -3,10 +3,12 @@ require "foreman/utils"
|
||||
|
||||
class Foreman::Export::Base
|
||||
|
||||
attr_reader :engine, :app, :log, :port, :user, :template, :concurrency
|
||||
attr_reader :location, :engine, :options, :app, :log, :port, :user, :template, :concurrency
|
||||
|
||||
def initialize(engine, options={})
|
||||
def initialize(location, engine, options={})
|
||||
@location = location
|
||||
@engine = engine
|
||||
@options = options
|
||||
@app = options[:app]
|
||||
@log = options[:log]
|
||||
@port = options[:port]
|
||||
|
||||
@@ -3,7 +3,7 @@ require "foreman/export"
|
||||
|
||||
class Foreman::Export::Bluepill < Foreman::Export::Base
|
||||
|
||||
def export(location, options={})
|
||||
def export
|
||||
error("Must specify a location") unless location
|
||||
|
||||
FileUtils.mkdir_p location
|
||||
|
||||
@@ -2,7 +2,7 @@ require "foreman/export"
|
||||
|
||||
class Foreman::Export::Inittab < Foreman::Export::Base
|
||||
|
||||
def export(fname=nil, options={})
|
||||
def export
|
||||
app = self.app || File.basename(engine.directory)
|
||||
user = self.user || app
|
||||
log_root = self.log || "/var/log/#{app}"
|
||||
|
||||
@@ -4,7 +4,7 @@ require "foreman/export"
|
||||
class Foreman::Export::Runit < Foreman::Export::Base
|
||||
ENV_VARIABLE_REGEX = /([a-zA-Z_]+[a-zA-Z0-9_]*)=(\S+)/
|
||||
|
||||
def export(location, options={})
|
||||
def export
|
||||
error("Must specify a location") unless location
|
||||
|
||||
app = self.app || File.basename(engine.directory)
|
||||
|
||||
@@ -3,7 +3,7 @@ require "foreman/export"
|
||||
|
||||
class Foreman::Export::Upstart < Foreman::Export::Base
|
||||
|
||||
def export(location, options={})
|
||||
def export
|
||||
error("Must specify a location") unless location
|
||||
|
||||
FileUtils.mkdir_p location
|
||||
|
||||
Reference in New Issue
Block a user