Class: Placer
- Inherits:
-
Object
- Object
- Placer
- Defined in:
- lib/placer.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Placer
constructor
A new instance of Placer.
- #parse_options(args) ⇒ Object
- #run ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(args) ⇒ Placer
Returns a new instance of Placer.
6 7 8 9 |
# File 'lib/placer.rb', line 6 def initialize(args) @args, @params = (args) @logger = @params[:log] ? MyLogger.new : MyLogger.new(:all) end |
Instance Method Details
#parse_options(args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/placer.rb', line 28 def (args) opts = OptionParser.new params = {} = "placer - a simpler deployment\ndeployment back to the basics\n\nIf you have no config, just start off by the example in the repo/placer.yaml.\nIn case you are wondering, public/private key auth is the only way.\nWe don't support manual solutions. This tool is thought for automated use.\n\nUsage: placer [options]\n" opts. = params[:log] = true opts.on('-q', '--[no-]log', 'toggle logging') do |val| params[:log] = val end params[:config_path] = 'placer.rb' opts.on('-c', '--config FILE', 'path to config FILE to use default: ' << params[:config_path]) do |file| params[:config_path] = file end params[:debug] = false opts.on('--debug', 'enable debugging') do params[:debug] = true end opts.on_tail('-h', '--help', 'shows this message') do puts opts exit end args = opts.parse(args) [args, params] end |
#run ⇒ Object
24 25 26 |
# File 'lib/placer.rb', line 24 def run PlacerDSL.new(File.read(@params[:config_path]), @logger) end |
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/placer.rb', line 11 def start @logger.log(:info, "Loading config file #{@params[:config_path]}") if @params[:debug] run else begin run rescue => e @logger.log(:error, e) end end end |