lib/vx/builder/script.rb in vx-builder-0.1.8 vs lib/vx/builder/script.rb in vx-builder-0.2.0
- old
+ new
@@ -2,10 +2,11 @@
module Vx
module Builder
class Script
+ autoload :Base, File.expand_path("../script/base", __FILE__)
autoload :Env, File.expand_path("../script/env", __FILE__)
autoload :Ruby, File.expand_path("../script/ruby", __FILE__)
autoload :Java, File.expand_path("../script/java", __FILE__)
autoload :Scala, File.expand_path("../script/scala", __FILE__)
autoload :Clojure, File.expand_path("../script/clojure", __FILE__)
@@ -13,10 +14,11 @@
autoload :Prepare, File.expand_path("../script/prepare", __FILE__)
autoload :Databases, File.expand_path("../script/databases", __FILE__)
autoload :Cache, File.expand_path("../script/cache", __FILE__)
autoload :Services, File.expand_path("../script/services", __FILE__)
autoload :Artifacts, File.expand_path("../script/artifacts", __FILE__)
+ autoload :Deploy, File.expand_path("../script/deploy", __FILE__)
include Common::Helper::Middlewares
middlewares do
use Builder::Script::Cache
@@ -26,10 +28,11 @@
use Builder::Script::Prepare
use Builder::Script::Java
use Builder::Script::Scala
use Builder::Script::Clojure
use Builder::Script::Ruby
+ use Builder::Script::Deploy
use Builder::Script::Script
end
attr_reader :source, :task
@@ -54,35 +57,54 @@
a += env.announce
a << "\n# install"
a += env.install
- a << "\n# before script"
+ if deploy?
+ a << "\n# before deploy"
+ else
+ a << "\n# before script"
+ end
a += env.before_script
+
a.join("\n")
end
def to_after_script
a = []
a << "\n# after script init"
a += env.after_script_init
- a << "\n# after script"
+
+ if deploy?
+ a << "\n# after deploy"
+ else
+ a << "\n# after script"
+ end
a += env.after_script
a.join("\n")
end
def to_script
a = []
- a << "\n# script"
- a += env.script
+ if deploy?
+ a << "\n# deploy"
+ a += env.deploy
+ else
+ a << "\n# script"
+ a += env.script
- a << "\n# after success"
- a += env.after_success
+ a << "\n# after success"
+ a += env.after_success
+ end
a.join("\n")
end
+ def deploy?
+ task.deploy?
+ end
+
private
def env
@env ||= run_middlewares(default_env) {|_| _ }
end
@@ -105,9 +127,12 @@
script: [],
after_success: [],
after_script_init: [],
after_script: [],
+
+ before_deploy: [],
+ deploy: [],
source: source,
task: task,
cache_key: [],
cached_directories: []