Skip to content

Commit fd41339

Browse files
committed
fix: Update readme and fix fmt
1 parent 8d4706b commit fd41339

6 files changed

Lines changed: 18 additions & 19 deletions

File tree

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ stacktower parse javascript yup -o yup.json
4040

4141
# PHP (Packagist/Composer)
4242
stacktower parse php monolog/monolog -o monolog.json
43+
44+
# Ruby (RubyGems)
45+
stacktower parse ruby rspec -o rspec.json
4346
```
4447

4548
Add `--enrich` with a `GITHUB_TOKEN` to pull repository metadata (stars, maintainers, last commit) for richer visualizations.
@@ -162,7 +165,7 @@ The `--detailed` flag (node-link only) displays **all** meta keys in the node la
162165

163166
## How It Works
164167

165-
1. **Parse** — Fetch package metadata from registries (PyPI, crates.io, npm)
168+
1. **Parse** — Fetch package metadata from registries (PyPI, crates.io, npm, Packagist, RubyGems)
166169
2. **Reduce** — Remove transitive edges to show only direct dependencies
167170
3. **Layer** — Assign each package to a row based on its depth
168171
4. **Order** — Minimize edge crossings using branch-and-bound with PQ-tree pruning
@@ -184,16 +187,16 @@ HTTP responses are cached in `~/.cache/stacktower/` with a 24-hour TTL. Use `--r
184187

185188
## Adding New Languages
186189

187-
To add support for a new package manager (e.g., Ruby/RubyGems):
190+
To add support for a new package manager (e.g., Go/pkg.go.dev):
188191

189-
1. **Create a registry client** in `pkg/integrations/rubygems/client.go` — parse the registry API, extract dependencies, use `integrations.BaseClient` for HTTP + caching
192+
1. **Create a registry client** in `pkg/integrations/<registry>/client.go` — parse the registry API, extract dependencies, use `integrations.BaseClient` for HTTP + caching
190193

191-
2. **Create a source parser** in `pkg/source/ruby/ruby.go` — implement the `source.PackageInfo` interface (`GetName`, `GetVersion`, `GetDependencies`, `ToMetadata`, `ToRepoInfo`)
194+
2. **Create a source parser** in `pkg/source/<lang>/<lang>.go` — implement the `source.PackageInfo` interface (`GetName`, `GetVersion`, `GetDependencies`, `ToMetadata`, `ToRepoInfo`)
192195

193196
3. **Wire into CLI** in `internal/cli/parse.go`:
194197
```go
195-
cmd.AddCommand(newParserCmd("ruby <gem>", "Parse Ruby dependencies",
196-
func() (source.Parser, error) { return ruby.NewParser(source.DefaultCacheTTL) }, &opts))
198+
cmd.AddCommand(newParserCmd("<lang> <package>", "Parse <Lang> dependencies",
199+
func() (source.Parser, error) { return <lang>.NewParser(source.DefaultCacheTTL) }, &opts))
197200
```
198201

199202
The generic `source.Parse()` handles concurrent fetching, depth limits, and graph construction automatically.

internal/cli/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"github.com/matzehuels/stacktower/pkg/source/metadata"
1515
"github.com/matzehuels/stacktower/pkg/source/php"
1616
"github.com/matzehuels/stacktower/pkg/source/python"
17-
"github.com/matzehuels/stacktower/pkg/source/rust"
1817
"github.com/matzehuels/stacktower/pkg/source/ruby"
18+
"github.com/matzehuels/stacktower/pkg/source/rust"
1919
)
2020

2121
type parseOpts struct {

pkg/integrations/rubygems/client.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import (
1111
)
1212

1313
type GemInfo struct {
14-
Name string
15-
Version string
16-
Dependencies []string
14+
Name string
15+
Version string
16+
Dependencies []string
1717
SourceCodeURI string
18-
HomepageURI string
19-
Description string
20-
License string
21-
Downloads int
22-
Authors string
18+
HomepageURI string
19+
Description string
20+
License string
21+
Downloads int
22+
Authors string
2323
}
2424

2525
type Client struct {
@@ -127,4 +127,3 @@ type dependencyInfo struct {
127127
Name string `json:"name"`
128128
Requirements string `json:"requirements"`
129129
}
130-

pkg/integrations/rubygems/client_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,3 @@ func TestJoinLicenses(t *testing.T) {
149149
}
150150
}
151151
}
152-

pkg/source/ruby/ruby.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,3 @@ func (gi *gemInfo) ToRepoInfo() *source.RepoInfo {
7474
ManifestFile: "Gemfile",
7575
}
7676
}
77-

pkg/source/ruby/ruby_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ func TestNewParser(t *testing.T) {
1414
t.Error("client not initialized")
1515
}
1616
}
17-

0 commit comments

Comments
 (0)