Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign method name as :id if the task is a method object #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.2.6

* Assign automatic `:id` to step if task is a method object.

# 0.2.5

* Patching now requires the [`:patch` option for `Subprocess`](http://2019.trailblazer.to/2.1/docs/activity.html#activity-dsl-options-patching
Expand Down
2 changes: 1 addition & 1 deletion lib/trailblazer/activity/dsl/linear/normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def wrap_task_with_step_interface((ctx, flow_options), **)
end

def normalize_id((ctx, flow_options), **)
id = ctx[:id] || ctx[:task]
id = ctx[:id] || ( ctx[:task].is_a?(Method) ? ctx[:task].name : ctx[:task] )

return Trailblazer::Activity::Right, [ctx.merge(id: id), flow_options]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/trailblazer/activity/dsl/linear/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Version
module Activity
module DSL
module Linear
VERSION = "0.2.5"
VERSION = "0.2.6"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/activity_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ActivityTest < Minitest::Spec
end
end

exception.message.sub(/0x\w+/, "0x").must_equal %{ID #<Method: #<Module:0x>.f> is already taken. Please specify an `:id`.}
exception.message.sub(/0x\w+/, "0x").must_equal %{ID f is already taken. Please specify an `:id`.}
end

it "accepts {:outputs}" do
Expand Down Expand Up @@ -614,7 +614,7 @@ def add_1(wrap_ctx, original_args)
step implementing.method(:b)
end

activity.to_h[:nodes].collect(&:id).must_equal ["Start.default", :a, implementing.method(:b), "End.success"]
activity.to_h[:nodes].collect(&:id).must_equal ["Start.default", :a, :b, "End.success"]
end

describe "#merge!" do
Expand Down