Skip to content
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.6, 2.7, '3.0', '3.1', '3.2', 'jruby']
ruby: [2.6, 2.7, "3.0", "3.2", "3.4", "jruby"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source "https://rubygems.org"

# Specify your gem's dependencies in trailblazer-developer.gemspec
Expand All @@ -13,3 +14,4 @@ gemspec


gem "benchmark-ips"
gem "rubocop", require: false
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"

Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "trailblazer/developer"
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "trailblazer/developer/version"

module Trailblazer
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/debugger.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
# Code in Debugger is only executed if the user wants to render the stack.
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/debugger/normalizer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module Debugger
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/introspect.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module Introspect
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/introspect/graph.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# NOTE: The Graph API might get deprecated and replaced.
module Trailblazer
module Developer
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/render/circuit.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module_function
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/render/linear.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
# Operation-specific circuit rendering. This is optimized for a linear railway circuit.
#
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/render/task_wrap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module Render
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module Trace
class << self
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace/node.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module Trace
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace/parent_map.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module Trace
Expand Down
3 changes: 2 additions & 1 deletion lib/trailblazer/developer/trace/present.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "hirb"
# frozen_string_literal: true
require "hirber"

module Trailblazer::Developer
module Trace
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace/snapshot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module Trace
# WARNING: the interfaces here are subject to change, we're still experimenting
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace/snapshot/value.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module Trace
class Snapshot
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace/snapshot/versions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module Trace
class Snapshot
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/trace/stack.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Developer
module Trace
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer
module Version
module Developer
Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/wtf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module_function

Expand Down
1 change: 1 addition & 0 deletions lib/trailblazer/developer/wtf/renderer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module Wtf

Expand Down
1 change: 1 addition & 0 deletions test/benchmark/hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark/ips"


Expand Down
1 change: 1 addition & 0 deletions test/benchmark/lib/deprecated_snapshot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Trailblazer::Developer
module Trace
class Snapshot
Expand Down
1 change: 1 addition & 0 deletions test/benchmark/snapshot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"
require_relative "lib/deprecated_snapshot"
require_relative "../trace_test"
Expand Down
1 change: 1 addition & 0 deletions test/docs/developer_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class DocsDeveloperTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/docs/graph_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class GraphTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/graph_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class IntrospectGraphTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/render_linear_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class RenderLinearTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/render_task_wrap_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class RenderTaskWrapTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/render_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class RenderCircuitTest < Minitest::Spec
Expand Down
13 changes: 13 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "trailblazer/developer"

Expand All @@ -17,6 +18,18 @@

Implementing = T.def_tasks(:b, :e, :B, :C)

# Helper to check hash inspect output across Ruby versions
# Ruby >= 3.4 uses {:key=>value} syntax, older versions use {key: value}
def assert_hash_inspect(actual, expected_old_syntax)
if RUBY_VERSION >= "3.4"
# Convert old syntax to new syntax for comparison
expected_new_syntax = expected_old_syntax.gsub(/(\w+): /, ':\1=>')
assert_equal actual, expected_new_syntax
else
assert_equal actual, expected_old_syntax
end
end

let(:flat_activity) do
Class.new(Trailblazer::Activity::Path) do
step task: Implementing.method(:B), id: :B
Expand Down
1 change: 1 addition & 0 deletions test/trace/debugger_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class DebuggerTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/trace/node_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class TraceNodeTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/trace/normalizer_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class TraceNormalizerTest < Minitest::Spec
Expand Down
1 change: 1 addition & 0 deletions test/trace/present_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

# Test {Trace::Present.call}
Expand Down
1 change: 1 addition & 0 deletions test/trace/stack_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class StackTest < Minitest::Spec
Expand Down
5 changes: 3 additions & 2 deletions test/trace/wtf_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class TraceWtfTest < Minitest::Spec
Expand Down Expand Up @@ -86,7 +87,7 @@ def <<(value)
# test returned values for #wtf?
assert_equal returned_args.size, 5
assert_equal returned_args[0].inspect, %(#<Trailblazer::Activity::End semantic=:failure>)
assert_equal returned_args[1][0].inspect, %({:seq=>[:a, :b, :c], :c=>false})
assert_hash_inspect returned_args[1][0].inspect, "{seq: [:a, :b, :c], c: false}"
assert_equal returned_args[1][1].class, Hash # flow_options
assert_equal returned_args[2].inspect, %({}) # circuit_options
assert_equal returned_args[3].chomp, output.chomp # fourth returned value is the trace output.
Expand Down Expand Up @@ -132,7 +133,7 @@ def <<(value)

assert_equal captured_output.chomp, %(Nodes: 15)
assert_equal signal.inspect, %(#<Trailblazer::Activity::End semantic=:success>)
assert_equal ctx.inspect, %({:seq=>[:a, :b, :c, :cc, :bb, :aa]})
assert_hash_inspect ctx.inspect, "{seq: [:a, :b, :c, :cc, :bb, :aa]}"
assert_equal circuit_options, {}
assert_equal output, captured_output.chomp
assert_equal returned_present_args, ["additional", "returned", "args"]
Expand Down
7 changes: 4 additions & 3 deletions test/trace_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

# Test {Trace.call} and {Trace::Present.call}
Expand All @@ -7,7 +8,7 @@ class TraceTest < Minitest::Spec

assert_equal signal.class.inspect, %{Trailblazer::Activity::End}

assert_equal ctx.inspect, %{{:seq=>[:B, :C]}}
assert_hash_inspect ctx.inspect, "{seq: [:B, :C]}"
assert_equal flow_options[:flow].inspect, %{true}

output = Dev::Trace::Present.(stack)
Expand All @@ -27,7 +28,7 @@ class TraceTest < Minitest::Spec

assert_equal signal.class.inspect, %{Trailblazer::Activity::End}

assert_equal ctx.inspect, %{{:seq=>[:B, :C]}}
assert_hash_inspect ctx.inspect, "{seq: [:B, :C]}"
assert_equal flow_options[:flow].inspect, %{true}

output = Dev::Trace::Present.(stack)
Expand Down Expand Up @@ -190,7 +191,7 @@ def authorize(ctx, current_user:, seq:, **)
assert_equal Trailblazer::Developer::Trace::Snapshot.snapshot_ctx_for(stack[11], stack_object.variable_versions), # asserted snapshot is for {After(:model)}.
{
current_user: {value: current_user.inspect, has_changed: false},
params: {value: "{:name=>\"Q & I\"}", has_changed: false},
params: {value: RUBY_VERSION >= "3.4" ? "{:name=>\"Q & I\"}" : "{name: \"Q & I\"}", has_changed: false},
seq: {value: "[:authenticate, :authorize, :model]", has_changed: true},
model: {value: "Object", has_changed: true}
}
Expand Down
3 changes: 2 additions & 1 deletion trailblazer-developer.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "trailblazer/developer/version"
Expand Down Expand Up @@ -25,5 +26,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "trailblazer-operation", ">= 0.10.0"

spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.2.0", "< 1.3.0"
spec.add_dependency "hirb"
spec.add_dependency "hirber"
end
Loading