@@ -7,9 +7,13 @@ class << self
7
7
def parse ( options )
8
8
return Configuration . new ( options [ :dist_folder ] ) unless File . exist? '.deploy-now/config.yaml'
9
9
10
- config = YAML . safe_load ( File . read ( '.deploy-now/config.yaml' ) )
10
+ begin
11
+ config = YAML . safe_load ( File . read ( '.deploy-now/config.yaml' ) )
12
+ rescue Exception => e
13
+ abort "unable to pare the .deploy-now/config.yaml config file\n #{ e } "
14
+ end
11
15
12
- abort 'version must be specified' unless config . include? 'version'
16
+ abort 'version must be specified in .deploy-now/config.yaml config file ' unless config . include? 'version'
13
17
14
18
version = config [ 'version' ] . to_s
15
19
abort "unknown version: #{ version } " unless version == '1.0'
@@ -21,13 +25,18 @@ def parse(options)
21
25
22
26
def parse_1_0 ( config , dist_folder , bootstrap )
23
27
if config . include? 'deploy'
28
+ abort "only 'bootstrap' or 'recurring are allowed for deploy.force in .deploy-now/config.yaml" unless config [ 'deploy' ] [ 'force' ] . eql? ( 'bootstrap' ) || config [ 'deploy' ] [ 'force' ] . eql? ( 'recurring' ) || config [ 'deploy' ] [ 'force' ] . nil?
24
29
deploy_config = config [ 'deploy' ] [ 'force' ] || ( bootstrap ? 'bootstrap' : 'recurring' )
25
30
26
- abort "deploy configuration '#{ deploy_config } ' is missing" unless config [ 'deploy' ] . include? deploy_config
27
-
28
- Configuration . new ( dist_folder ,
29
- config [ 'deploy' ] [ deploy_config ] [ 'excludes' ] || [ ] ,
30
- config [ 'deploy' ] [ deploy_config ] [ 'remote-commands' ] )
31
+ if config [ 'deploy' ] . include? deploy_config
32
+ Configuration . new ( dist_folder ,
33
+ config [ 'deploy' ] [ deploy_config ] [ 'excludes' ] || [ ] ,
34
+ config [ 'deploy' ] [ deploy_config ] [ 'remote-commands' ] )
35
+ else
36
+ Configuration . new ( dist_folder ,
37
+ [ ] ,
38
+ nil )
39
+ end
31
40
else
32
41
Configuration . new ( dist_folder )
33
42
end
@@ -43,4 +52,14 @@ def initialize(dist_folder, excludes = [], remote_commands = nil)
43
52
@excludes = excludes
44
53
@remote_commands = remote_commands
45
54
end
55
+
56
+ def eql ( other )
57
+ self . dist_folder == other . dist_folder &&
58
+ self . excludes == other . excludes &&
59
+ self . remote_commands == other . remote_commands
60
+ end
61
+
62
+ def to_s
63
+ "{dist: \" #{ self . dist_folder } \" , excludes: #{ self . excludes . to_s } , remote_commands:#{ self . remote_commands . to_s } }"
64
+ end
46
65
end
0 commit comments