lib/grumlin/steps_serializers/string.rb in grumlin-0.17.0 vs lib/grumlin/steps_serializers/string.rb in grumlin-0.18.0
- old
+ new
@@ -8,18 +8,25 @@
# TODO: add pretty
def serialize
steps = @params[:apply_shortcuts] ? ShortcutsApplyer.call(@steps) : @steps
- configuration_steps = serialize_steps(steps.configuration_steps)
- regular_steps = serialize_steps(steps.steps)
+ steps = [steps.configuration_steps, steps.steps].map do |stps|
+ stps.map { |step| serialize_step(step) }
+ end
- "#{prefix}.#{(configuration_steps + regular_steps).join(".")}"
+ "#{prefix}.#{(steps[0] + steps[1]).join(".")}"
end
private
+ def serialize_step(step)
+ "#{step.name}(#{(step.args + [step.params.any? ? step.params : nil].compact).map do |a|
+ serialize_arg(a)
+ end.join(", ")})"
+ end
+
def prefix
@prefix ||= @params[:anonymous] ? "__" : "g"
end
def serialize_arg(arg)
@@ -28,15 +35,9 @@
return arg.to_s if arg.is_a?(Grumlin::Expressions::WithOptions)
return arg unless arg.is_a?(Steps)
StepsSerializers::String.new(arg, anonymous: true, **@params).serialize
- end
-
- def serialize_steps(steps)
- steps.map do |step|
- "#{step.name}(#{step.arguments.map { |a| serialize_arg(a) }.join(", ")})"
- end
end
end
end
end