Skip to content

Commit 34859e2

Browse files
committed
refactor: move executable logic into gem binaries
1 parent 3af4156 commit 34859e2

File tree

12 files changed

+357
-341
lines changed

12 files changed

+357
-341
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ pkg/
1313
# Offline dependency sources
1414
.codex/deps_src/
1515
.codex/internet_resources/
16-
17-
agents-workflow/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ recorder.flush_trace(Dir.pwd)
3636
you can currently use it directly with
3737

3838
```bash
39-
ruby gems/codetracer-pure-ruby-recorder/lib/trace.rb [--out-dir DIR] <path to ruby file>
39+
ruby gems/codetracer-pure-ruby-recorder/bin/codetracer-pure-ruby-recorder [--out-dir DIR] <path to ruby file>
4040
# produces several trace json files in DIR,
4141
# or in `$CODETRACER_RUBY_RECORDER_OUT_DIR` if DIR is not provided.
4242
# Defaults to the current directory.
@@ -47,7 +47,7 @@ You can also invoke a lightweight CLI that loads the native tracer extension
4747
directly:
4848

4949
```bash
50-
ruby gems/codetracer-ruby-recorder/lib/native_trace.rb [--out-dir DIR] <path to ruby file>
50+
ruby gems/codetracer-ruby-recorder/bin/codetracer-ruby-recorder [--out-dir DIR] <path to ruby file>
5151
# Uses DIR or `$CODETRACER_RUBY_RECORDER_OUT_DIR` to choose where traces are saved.
5252
```
5353

examples/selective_tracing.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# Load the native extension only if RubyRecorder is not already available
44
# (e.g., when running directly without the codetracer wrapper)
5-
unless defined?(RubyRecorder)
5+
unless defined?(CodeTracerNativeRecorder)
66
ext_base = File.expand_path('../gems/codetracer-ruby-recorder/ext/native_tracer/target/release/libcodetracer_ruby_recorder', __dir__)
77
require ext_base
88
end
99

10-
recorder = RubyRecorder.new
10+
recorder = CodeTracerNativeRecorder.new
1111

1212
puts 'start trace'
1313
recorder.disable_tracing

examples/selective_tracing_pure.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env ruby
22

33
# Load the pure Ruby tracer library if RubyRecorder is not already defined
4-
unless defined?(RubyRecorder)
4+
unless defined?(CodeTracerNativeRecorder)
55
lib_base = File.expand_path('../gems/codetracer-pure-ruby-recorder/lib/codetracer_pure_ruby_recorder', __dir__)
66
require lib_base
77
end
88

9-
recorder = RubyRecorder.new
9+
recorder = CodeTracerNativeRecorder.new
1010

1111
puts 'start trace'
1212
recorder.disable_tracing
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env ruby
2-
require 'rbconfig'
3-
script = File.expand_path('../lib/trace.rb', __dir__)
4-
exec RbConfig.ruby, script, *ARGV
2+
# SPDX-License-Identifier: MIT
3+
# CLI for the pure Ruby tracer
4+
5+
lib_dir = File.expand_path('../lib', __dir__)
6+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
7+
require 'trace'
8+
9+
exit Codetracer::PureRubyRecorder.parse_argv_and_trace_ruby_file(ARGV)

gems/codetracer-pure-ruby-recorder/lib/codetracer_pure_ruby_recorder.rb

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)