lib/dply/tasks.rb in dply-0.0.8 vs lib/dply/tasks.rb in dply-0.1.0
- old
+ new
@@ -1,8 +1,11 @@
+require 'json'
require 'dply/shell'
require 'dply/bundle'
-require 'json'
+require 'dply/yum'
+require 'dply/pkgs_config'
+
module Dply
class Tasks
include Shell
@@ -37,16 +40,40 @@
def report_changes(previous_version, current_version)
info = {}
info[:current] = current_version
info[:previous] = previous_version
- logger.remote "#{JSON.dump info}"
+ logger.remote "#{previous_version} => #{current_version}"
end
+ def install_pkgs(build_mode: false, use_yum: false)
+ drake_exists = File.exists? (drake_command)
+ if use_yum || !drake_exists
+ yum_install build_mode
+ else
+ command_install build_mode
+ end
+ end
+
private
def bundle
@bundle ||= Bundle.new(deployment: @deployment)
+ end
+
+ def yum_install(build_mode)
+ pkgs = PkgsConfig.new(build_mode: build_mode).pkgs
+ Yum.new(pkgs, sudo: true).install
+ end
+
+ def command_install(build_mode)
+ command = "sudo -n #{drake_command} install-pkgs"
+ command << " -b" if build_mode
+ cmd command
+ end
+
+ def drake_command
+ @drake_command ||= (ENV["DRAKE_COMMAND"] || "/opt/ruby/bin/drake")
end
end
end