Class: Albacore::Tools::FluentMigrator::Cmd
- Inherits:
-
Object
- Object
- Albacore::Tools::FluentMigrator::Cmd
- Includes:
- CrossPlatformCmd
- Defined in:
- lib/albacore/tools/fluent_migrator.rb
Constant Summary
Constants included from CrossPlatformCmd
CrossPlatformCmd::KILL_TIMEOUT
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Attributes included from CrossPlatformCmd
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(*args) ⇒ Cmd
constructor
A new instance of Cmd.
Methods included from CrossPlatformCmd
#chdir, #make_command, #normalise_slashes, #sh, #shie, #stop, #system, #which
Methods included from Logging
#debug, #err, #error, #fatal, #info, #puts, #trace, #warn
Constructor Details
#initialize(*args) ⇒ Cmd
Returns a new instance of Cmd.
17 18 19 20 21 22 23 24 25 26 27 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 69 70 71 72 |
# File 'lib/albacore/tools/fluent_migrator.rb', line 17 def initialize *args opts = Map.(args) # defaults opts = opts.apply :extras => [], :silent => ENV.fetch('MIGRATE_SILENT', teamcity?), :conn => ENV['CONN'], :timeout => 200, :direction => 'migrate:up', :dll => ENV.fetch('MIGRATE_DLL','src/migrations/Migrations/bin/Debug/Migrations.dll'), :db => ENV.fetch('MIGRATE_DB', 'SqlServer2008'), :exe => ENV.fetch('MIGRATE_EXE', 'src/packages/FluentMigrator.1.0.6.0/tools/Migrate.exe'), :task_override => nil, :interactive => ENV.fetch('MIGRATE_INTERACTIVE', true), :work_dir => nil e = opts.getopt(:extras) opts.set(:extras, e.is_a?(Array) ? e : [e]) @opts = opts @executable = opts.get(:exe) conn = opts.get :conn if opts.get :interactive conn = ask "Give connection string: " do |q| q.validate = /\A.+\Z/ end unless opts.get(:silent) or conn conn = munge_windows conn unless opts.get(:silent) unless opts.get :silent or confirm opts.get(:direction) raise 'didn\'t confirm: exiting migrations' end end raise ArgumentError, 'cannot execute with empty connection string' if nil_or_white conn raise ArgumentError, 'cannot execute with no dll file specified' if nil_or_white(opts.get(:dll)) @parameters = %W[-a #{opts.get(:dll)} -db #{opts.get(:db)} -conn #{conn} --timeout=#{opts.get(:timeout)}] unless opts.get :task_override @parameters.push '--task' @parameters.push opts.get(:direction) else @parameters.push opts.get(:task_override) end opts.get(:extras).each{ |e| @parameters.push e} trace { "configured Albacore::FluentMigrator::Cmd with exe: '#{@executable}', params: #{@parameters.join(' ')}" } prepare_verify @executable, opts mono_command end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
15 16 17 |
# File 'lib/albacore/tools/fluent_migrator.rb', line 15 def opts @opts end |
Instance Method Details
#execute ⇒ Object
74 75 76 77 |
# File 'lib/albacore/tools/fluent_migrator.rb', line 74 def execute verify_exists system @executable, @parameters, :work_dir => opts.get(:work_dir) end |