lib/planter/string.rb in planter-cli-3.0.5 vs lib/planter/string.rb in planter-cli-3.0.7
- old
+ new
@@ -237,27 +237,30 @@
##
def apply_operator_logic(variables = nil)
variables = variables.nil? ? Planter.variables : variables
op_rx = ' *(?<content>c(?:opy)?|o(?:ver(?:write)?)?|i(?:gnore)?|m(?:erge)?)? *'
- strip.gsub(/^if .*?(?:end(?: ?if)?|$)/mi) do |construct|
+ output = strip.gsub(/^if .*?(?:end(?: ?if)?|$)/mi) do |construct|
# Get the condition and the content
output = construct.match(/else:#{op_rx}/m) ? Regexp.last_match(1) : ''
conditions = construct.to_enum(:scan,
/(?<statement>(?:els(?:e )?)?if) +(?<condition>.*?):#{op_rx}(?=;|$)/mi).map do
Regexp.last_match
end
apply_conditions(conditions, variables, output)
- end.gsub(/^#{op_rx} +if .*?(end( ?if)?|$)/mi) do |construct|
+ end
+ output = output.gsub(/^#{op_rx} +if .*?(end( ?if)?|$)/mi) do |construct|
# Get the condition and the content
output = construct.match(/else[; ]+(#{op_rx})/m) ? Regexp.last_match(1) : :ignore
condition = construct.match(/^#{op_rx}(?<statement>if) +(?<condition>.*?)(?=;|$)/mi)
apply_conditions([condition], variables, output)
- end.normalize_operator
+ end
+
+ output.normalize_operator
end
##
## Apply conditions
##
@@ -693,10 +696,10 @@
#
# Test if a string has a parenthetical selector
#
# @return [Boolean] has selector
#
- def has_selector?
+ def selector?
self =~ /\(.\)/ ? true : false
end
end
end