lib/dply/tasks.rb in dply-0.0.5 vs lib/dply/tasks.rb in dply-0.0.7

- old
+ new

@@ -1,55 +1,52 @@ require 'dply/shell' +require 'dply/bundle' +require 'json' module Dply class Tasks include Shell - def deploy(target, env:{}) - env.merge!(env_from_yml) - bundle_install - cmd "#{rake_command} #{target}:deploy", env: env + def initialize(deployment: true) + @deployment = deployment end - def switch(target, env:{}) - env.merge!(env_from_yml) - bundle_install - cmd "#{rake_command} #{target}:switch", env: env + def deploy(target) + bundle.install + rake "#{target}:deploy" end def reload(target) - bundle_install - cmd "#{rake_command} #{target}:reload", env: env_from_yml + bundle.install + rake "#{target}:reload" end - def gemfile_exists? - File.exists? "Gemfile" + def task(task) + bundle.install + rake task end - def rake_command - if gemfile_exists? - "bundle exec rake -R dply" - else - "rake -R dply" - end + def build(task) + bundle.install + bundle.clean + rake task end - def bundle_install - return if not gemfile_exists? - exitstatus = system "bundle check > /dev/null" - return if exitstatus - cmd "bundle install" + def rake(task) + bundle.rake task 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) + def report_changes(previous_version, current_version) + info = {} + info[:current] = current_version + info[:previous] = previous_version + logger.remote "#{JSON.dump info}" end + private + + def bundle + @bundle ||= Bundle.new(deployment: @deployment) + end end end