Sha256: 70db45a051b01f60bd8f25308fd66be82c7889de763d39cb7668a3b83b98ce6a
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 KB
Contents
module Hem module Helper def get_run_environment [ ENV['HEM_RUN_ENV'], Hem.project_config.run_environment, Hem.user_config.run_environment, 'vm' ].each do |env| return env unless env.nil? end end def run command, opts = {} create_command(command, opts).run end alias_method :run_command, :run def create_mysql_command opts = {} opts = { :auto_echo => true, :db => "", :user => maybe(Hem.project_config.mysql.username) || "", :pass => maybe(Hem.project_config.mysql.password) || "", :mysql => 'mysql' }.merge(opts) opts[:user] = "-u#{opts[:user].shellescape}" unless opts[:user].empty? opts[:pass] = "-p#{opts[:pass].shellescape}" unless opts[:pass].empty? opts[:db] = opts[:db].shellescape unless opts[:db].empty? create_command "#{opts[:mysql]} #{opts[:user]} #{opts[:pass]} #{opts[:db]}".strip, opts end def create_command command = nil, opts = {} run_env = opts[:run_environment] || get_run_environment case run_env when 'vm' ::Hem::Lib::Vm::Command.new command, opts when 'local' ::Hem::Lib::Local::Command.new command, opts else raise Hem::InvalidCommandOrOpt.new "run_environment #{run_env}" end end end end include Hem::Helper
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hem-1.2.0 | lib/hem/helper/command.rb |
hem-1.1.2 | lib/hem/helper/command.rb |
hem-1.1.1 | lib/hem/helper/command.rb |
hem-1.1.0 | lib/hem/helper/command.rb |