kameleon-builder 2.9.1 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b11eb6024451e8df957feaa54ba6f655569dd54
4
- data.tar.gz: 5f903059a1e2dd4cb01ea11d91fdcfa885b4bfa0
3
+ metadata.gz: 6d7458a3fde25cc58852865df6aa62bd43b03dc4
4
+ data.tar.gz: 20f4f7320bb696713b64e3894c202a1f7386a181
5
5
  SHA512:
6
- metadata.gz: 773ff3b250101855bc17abf0e468486a63642675d68463e2c7ac9f8b73663124cb34a6eaf2205856847c6b44f54f3c963168096bf45f2aaface7bbb5ee124dea
7
- data.tar.gz: 5a108c1268d2d40737e4744091e546a8db14bd581f9fdcfbdce382374efde9e19a110f45b7628325697149f7f823b753ab9673fc59ec438666ec50fdcafeeefc
6
+ metadata.gz: 0dd429c6424f1484c1b2fff7f124e2a2a0d6b6a8e7e546b9101eba8a5f5809587007a33395ad73125bd45830edbf03e18a0ed31e482ddda5025f7b582051edb7
7
+ data.tar.gz: 4be4b3d61a51e0b0959a2b17777d1891b34a9da08a60e6e532cf36360efbd85e99a8f4a9aedb5d27986f19dad0df3e676c78635c92db4435f68e65b003b7272a
@@ -1,7 +1,7 @@
1
1
  [bumpversion]
2
2
  commit = True
3
3
  tag = True
4
- current_version = 2.9.1
4
+ current_version = 2.9.2
5
5
  parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+))?
6
6
  serialize =
7
7
  {major}.{minor}.{patch}.{release}
data/CHANGES CHANGED
@@ -1,9 +1,19 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ Version 2.9.2
5
+ -------------
6
+
7
+ Released on February 21st 2018
8
+
9
+ - Enforce the number of sub commands for the rescue and test commands
10
+ - Support nested aliases
11
+
4
12
  Version 2.9.1
5
13
  -------------
6
14
 
15
+ Released on January 28st 2018
16
+
7
17
  - Make the test and group command work in the cleaning steps.
8
18
 
9
19
  Version 2.9.0
@@ -298,6 +298,10 @@ module Kameleon
298
298
  first_context.pipe(first_cmd.value, second_cmd.value, second_context, kwargs)
299
299
  end
300
300
  when "rescue"
301
+ unless cmd.value.length == 2
302
+ Kameleon.ui.error("Invalid 'rescue' command arguments. Expecting 2 sub commands")
303
+ fail ExecError
304
+ end
301
305
  first_cmd, second_cmd = cmd.value
302
306
  begin
303
307
  exec_cmd(first_cmd, kwargs)
@@ -305,6 +309,10 @@ module Kameleon
305
309
  safe_exec_cmd(second_cmd, kwargs)
306
310
  end
307
311
  when "test"
312
+ unless cmd.value.length == 2 or cmd.value.length == 3
313
+ Kameleon.ui.error("Invalid 'test' command arguments. Expecting 2 or 3 sub commands")
314
+ fail ExecError
315
+ end
308
316
  first_cmd, second_cmd, third_cmd = cmd.value
309
317
  begin
310
318
  Kameleon.ui.debug("Execute test condition")
@@ -313,8 +321,10 @@ module Kameleon
313
321
  # be executed rather than the "then" statement.
314
322
  exec_cmd(first_cmd, kwargs.reject {|k| k == :only_with_context})
315
323
  rescue ExecError
316
- Kameleon.ui.debug("Execute test 'else' statment'")
317
- exec_cmd(third_cmd, kwargs) unless third_cmd.nil?
324
+ unless third_cmd.nil?
325
+ Kameleon.ui.debug("Execute test 'else' statment'")
326
+ exec_cmd(third_cmd, kwargs)
327
+ end
318
328
  else
319
329
  Kameleon.ui.debug("Execute test 'then' statment'")
320
330
  exec_cmd(second_cmd, kwargs)
@@ -546,20 +546,18 @@ module Kameleon
546
546
  consistency_check
547
547
  resolve_checkpoint unless @checkpoint.nil?
548
548
 
549
- Kameleon.ui.verbose("Resolving variables")
549
+ Kameleon.ui.verbose("Resolving aliases")
550
550
  @sections.values.each do |section|
551
551
  section.macrosteps.each do |macrostep|
552
552
  # First pass : resolve aliases
553
553
  Kameleon.ui.debug("Resolving aliases for macrostep '#{macrostep.name}'")
554
554
  macrostep.microsteps.each do |microstep|
555
555
  microstep.commands.map! do |cmd|
556
- # resolve alias
557
- @aliases.keys.include?(cmd.key) ? resolve_alias(cmd) : cmd
556
+ resolve_alias(cmd)
558
557
  end
558
+ # flatten for multiple-command alias + variables
559
+ microstep.commands.flatten!
559
560
  end
560
- # flatten for multiple-command alias + variables
561
- Kameleon.ui.debug("Resolving check statements for macrostep '#{macrostep.name}'")
562
- macrostep.microsteps.each { |microstep| microstep.commands.flatten! }
563
561
  end
564
562
  end
565
563
 
@@ -641,26 +639,36 @@ module Kameleon
641
639
 
642
640
  def resolve_alias(cmd)
643
641
  name = cmd.key
644
- aliases_cmd = @aliases.fetch(name).clone
645
- aliases_cmd_str = aliases_cmd.to_yaml
646
- args = YAML.load(cmd.string_cmd)[name]
647
- args = [].push(args).flatten # convert args to array
648
- expected_args_number = aliases_cmd_str.scan(/@\d+/).uniq.count
649
- if expected_args_number != args.count
650
- if args.length == 0
651
- msg = "#{name} takes no arguments (#{args.count} given)"
652
- else
653
- msg = "#{name} takes exactly #{expected_args_number} arguments"
654
- " (#{args.count} given)"
642
+ if @aliases.keys.include?(name)
643
+ Kameleon.ui.debug("Resolving alias '#{name}'")
644
+ aliases_cmd = @aliases.fetch(name).clone
645
+ aliases_cmd_str = aliases_cmd.to_yaml
646
+ args = YAML.load(cmd.string_cmd)[name]
647
+ args = [].push(args).flatten # convert args to array
648
+ expected_args_number = aliases_cmd_str.scan(/@\d+/).uniq.count
649
+ if expected_args_number != args.count
650
+ if args.length == 0
651
+ msg = "#{name} takes no arguments (#{args.count} given)"
652
+ else
653
+ msg = "#{name} takes exactly #{expected_args_number} arguments"
654
+ " (#{args.count} given)"
655
+ end
656
+ raise RecipeError, msg
655
657
  end
656
- raise RecipeError, msg
657
- end
658
- microstep = Microstep.new({cmd.microstep_name => aliases_cmd})
659
- args.each_with_index do |arg, i|
660
- microstep.gsub!("@#{i+1}", arg)
661
- end
662
- microstep.commands.map do |escaped_cmd|
663
- Command.new(YAML.load(escaped_cmd.string_cmd), cmd.microstep_name)
658
+ aliases_cmd.map do |c|
659
+ nc = Command.new(c, cmd.microstep_name)
660
+ args.each_with_index do |arg, i|
661
+ nc.gsub!("@#{i+1}", arg)
662
+ end
663
+ resolve_alias(nc)
664
+ end
665
+ elsif cmd.value.kind_of?(Array)
666
+ Kameleon.ui.debug("Search for aliases in the sub-commands of '#{name}'")
667
+ cmd.value.map!{ |cmd| resolve_alias(cmd) }.flatten!
668
+ cmd.remaster_string_cmd_from_value!
669
+ else
670
+ Kameleon.ui.debug("Leaf command '#{name}' is not an alias")
671
+ cmd
664
672
  end
665
673
  end
666
674
 
@@ -669,10 +677,10 @@ module Kameleon
669
677
  if (cmd.key =~ /on_(.*)clean/ || cmd.key =~ /on_(.*)init/)
670
678
  cmds = []
671
679
  if cmd.value.kind_of?(Array)
672
- cmds = cmd.value.map do |c|
673
- @aliases.keys.include?(c.key) ? resolve_alias(c) : c
680
+ cmds = cmd.value.map do |cmd|
681
+ resolve_alias(cmd)
674
682
  end
675
- cmds = cmds.flatten
683
+ cmds.flatten!
676
684
  else
677
685
  fail RecipeError, "Invalid #{cmd.key} arguments"
678
686
  end
@@ -73,13 +73,24 @@ module Kameleon
73
73
  end
74
74
  end
75
75
 
76
+ def string_cmd=(str)
77
+ Kameleon.ui.debug("Set string_cmd to '#{str}' and clear cached value")
78
+ @string_cmd = str
79
+ @value = nil
80
+ end
81
+
82
+ def remaster_string_cmd_from_value!
83
+ self.string_cmd = YAML.dump(to_array).gsub("---", "").strip
84
+ return self
85
+ end
86
+
76
87
  def gsub!(arg1, arg2)
77
88
  if value.kind_of? Array
78
89
  value.each { |cmd| cmd.gsub!(arg1, arg2) }
79
90
  else
80
91
  @value.gsub!(arg1, arg2)
81
92
  end
82
- @string_cmd = YAML.dump(to_array).gsub("---", "").strip
93
+ remaster_string_cmd_from_value!
83
94
  return self
84
95
  end
85
96
 
@@ -1 +1 @@
1
- 2.9.1
1
+ 2.9.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salem Harrache
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-01-28 00:00:00.000000000 Z
15
+ date: 2018-02-21 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: childprocess