lib/dply/tasks.rb in dply-0.0.2 vs lib/dply/tasks.rb in dply-0.0.5
- old
+ new
@@ -2,20 +2,27 @@
module Dply
class Tasks
include Shell
- def deploy(target)
+ def deploy(target, env:{})
+ env.merge!(env_from_yml)
bundle_install
- cmd "#{rake_command} #{target}:deploy"
+ cmd "#{rake_command} #{target}:deploy", env: env
end
- def switch(target)
+ def switch(target, env:{})
+ env.merge!(env_from_yml)
bundle_install
- cmd "#{rake_command} #{target}:switch"
+ cmd "#{rake_command} #{target}:switch", env: env
end
+ def reload(target)
+ bundle_install
+ cmd "#{rake_command} #{target}:reload", env: env_from_yml
+ end
+
def gemfile_exists?
File.exists? "Gemfile"
end
def rake_command
@@ -30,8 +37,19 @@
return if not gemfile_exists?
exitstatus = system "bundle check > /dev/null"
return if exitstatus
cmd "bundle install"
end
+
+ def env_from_yml
+ path = "config/env.yml"
+ if not File.readable? path
+ logger.debug "skipped loading env from #{path}"
+ return {}
+ end
+ require 'yaml'
+ YAML.load_file(path)
+ end
+
end
end