njtransit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.claude/commands/njtransit.md +196 -0
- data/.mcp.json.example +12 -0
- data/.mcp.json.sample +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +87 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +37 -0
- data/CLAUDE.md +159 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +148 -0
- data/Rakefile +12 -0
- data/docs/plans/2025-01-24-njtransit-gem-design.md +112 -0
- data/docs/plans/2026-01-24-bus-api-design.md +119 -0
- data/docs/plans/2026-01-24-gtfs-implementation.md +2216 -0
- data/docs/plans/2026-01-24-gtfs-loader-design.md +351 -0
- data/docs/superpowers/plans/2026-03-26-dev-infra-and-agent.md +480 -0
- data/lefthook.yml +17 -0
- data/lib/njtransit/client.rb +291 -0
- data/lib/njtransit/configuration.rb +49 -0
- data/lib/njtransit/error.rb +50 -0
- data/lib/njtransit/gtfs/database.rb +145 -0
- data/lib/njtransit/gtfs/importer.rb +124 -0
- data/lib/njtransit/gtfs/models/route.rb +59 -0
- data/lib/njtransit/gtfs/models/stop.rb +63 -0
- data/lib/njtransit/gtfs/queries/routes_between.rb +62 -0
- data/lib/njtransit/gtfs/queries/schedule.rb +75 -0
- data/lib/njtransit/gtfs.rb +119 -0
- data/lib/njtransit/railtie.rb +9 -0
- data/lib/njtransit/resources/base.rb +35 -0
- data/lib/njtransit/resources/bus/enrichment.rb +105 -0
- data/lib/njtransit/resources/bus.rb +95 -0
- data/lib/njtransit/resources/bus_gtfs.rb +34 -0
- data/lib/njtransit/resources/rail.rb +47 -0
- data/lib/njtransit/resources/rail_gtfs.rb +27 -0
- data/lib/njtransit/tasks.rb +74 -0
- data/lib/njtransit/version.rb +5 -0
- data/lib/njtransit.rb +40 -0
- data/sig/njtransit.rbs +4 -0
- metadata +177 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: cd302f71e7ea318a5704152bab2cb76a4e94562ec509c7e21a3c0b3aa68d65d1
|
|
4
|
+
data.tar.gz: cc4154a3674e08bac0ebd0edd2b0962377ee96aea941835826e438c490951ab7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3c6bb8539d7b15520888030783b52415daf70a9d8b52946fbef63c7ab72155d3750d1612a4381158eed51db7a36c7430990abbe3efdd8e8e5086620eca4fa70f
|
|
7
|
+
data.tar.gz: b92982f20309a47272575d0421002ebe27607453e924bc260b4c85001ddeb8bfc03d7517b83cc53e062a491b68f9f2f223fc9e99af1c21a664fb32c9b213bbd3
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Ask NJ Transit questions - buses, trains, light rail, schedules, real-time arrivals. Uses the njtransit gem to query live data.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are an NJ Transit assistant. The user is asking a transit question from their terminal. Your job is to answer it by writing and executing Ruby code using the `njtransit` gem in this repository.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
The gem is in the current directory. Credentials come from environment variables. Before making any API call, run this setup:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require "dotenv"
|
|
13
|
+
Dotenv.load
|
|
14
|
+
|
|
15
|
+
$LOAD_PATH.unshift(File.join(Dir.pwd, "lib"))
|
|
16
|
+
require "njtransit"
|
|
17
|
+
|
|
18
|
+
NJTransit.configure do |config|
|
|
19
|
+
config.username = ENV["NJTRANSIT_USERNAME"]
|
|
20
|
+
config.password = ENV["NJTRANSIT_PASSWORD"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Bus/Light Rail client (pcsdata.njtransit.com)
|
|
24
|
+
client = NJTransit.client
|
|
25
|
+
|
|
26
|
+
# Rail/Train client (raildata.njtransit.com)
|
|
27
|
+
rail_client = NJTransit.rail_client
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If credentials are missing, tell the user to set `NJTRANSIT_USERNAME` and `NJTRANSIT_PASSWORD` in their `.env` file. They can register at https://developer.njtransit.com/registration
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## BUS API (client.bus)
|
|
35
|
+
|
|
36
|
+
### Routes & Directions
|
|
37
|
+
```ruby
|
|
38
|
+
client.bus.routes # All bus routes
|
|
39
|
+
client.bus.routes(mode: "ALL") # All modes (bus + light rail)
|
|
40
|
+
client.bus.routes(mode: "HBLR") # Hudson-Bergen Light Rail only
|
|
41
|
+
# Valid modes: "BUS", "NLR", "HBLR", "RL", "ALL"
|
|
42
|
+
|
|
43
|
+
client.bus.directions(route: "197")
|
|
44
|
+
# => [{"Direction_1"=>"New York", "Direction_2"=>"Willowbrook Mall"}]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Stops
|
|
48
|
+
```ruby
|
|
49
|
+
client.bus.stops(route: "197", direction: "New York", enrich: false)
|
|
50
|
+
client.bus.stop_name(stop_number: "19159", enrich: false)
|
|
51
|
+
client.bus.stops_nearby(lat: 40.8523, lon: -74.2567, radius: 2000, enrich: false)
|
|
52
|
+
# radius is in feet. mode: "ALL" includes light rail stops
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Real-Time Departures (most useful for "when is my bus?")
|
|
56
|
+
```ruby
|
|
57
|
+
client.bus.departures(stop: "PABT", enrich: false)
|
|
58
|
+
# Returns trips active in next hour
|
|
59
|
+
# Can filter: route: "197", direction: "New York"
|
|
60
|
+
# Response: public_route, header (destination), departuretime ("in 18 mins"),
|
|
61
|
+
# lanegate, vehicle_id, passload, sched_dep_time
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Trip Tracking
|
|
65
|
+
```ruby
|
|
66
|
+
client.bus.route_trips(location: "PABT", route: "113")
|
|
67
|
+
client.bus.trip_stops(internal_trip_number: "19624134", sched_dep_time: "6/22/2023 12:50:00 AM")
|
|
68
|
+
client.bus.vehicles_nearby(lat: 40.8523, lon: -74.2567, radius: 5000, enrich: false)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Locations (terminals/hubs)
|
|
72
|
+
```ruby
|
|
73
|
+
client.bus.locations # Bus terminals
|
|
74
|
+
client.bus.locations(mode: "ALL") # All transit locations
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## RAIL/TRAIN API (rail_client.rail)
|
|
80
|
+
|
|
81
|
+
### Station List
|
|
82
|
+
```ruby
|
|
83
|
+
rail_client.rail.stations
|
|
84
|
+
# => [{"STATION_2CHAR"=>"NP", "STATIONNAME"=>"Newark Penn Station", ...}, ...]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Station Messages & Alerts
|
|
88
|
+
```ruby
|
|
89
|
+
rail_client.rail.station_messages(station: "NP") # By station code
|
|
90
|
+
rail_client.rail.station_messages(line: "NE") # By line code (NEC)
|
|
91
|
+
# Returns alerts, delays, service advisories
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Train Schedules (most useful for "when is my train?")
|
|
95
|
+
```ruby
|
|
96
|
+
# Real-time schedule with full detail
|
|
97
|
+
rail_client.rail.train_schedule(station: "NP")
|
|
98
|
+
|
|
99
|
+
# Lighter version - next 19 departures
|
|
100
|
+
rail_client.rail.train_schedule_19(station: "NP")
|
|
101
|
+
|
|
102
|
+
# Full 27-hour station schedule
|
|
103
|
+
rail_client.rail.station_schedule(station: "NP")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Train Tracking
|
|
107
|
+
```ruby
|
|
108
|
+
# All stops for a specific train
|
|
109
|
+
rail_client.rail.train_stop_list(train_id: "3837")
|
|
110
|
+
|
|
111
|
+
# Real-time positions of all active trains
|
|
112
|
+
rail_client.rail.vehicle_data
|
|
113
|
+
# Returns: lat/lon, speed, next station, seconds late, train line
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Common Station Codes
|
|
117
|
+
- **NY** -- New York Penn Station
|
|
118
|
+
- **NP** -- Newark Penn Station
|
|
119
|
+
- **HB** -- Hoboken Terminal
|
|
120
|
+
- **SC** -- Secaucus Junction
|
|
121
|
+
- **TR** -- Trenton
|
|
122
|
+
- **NA** -- Newark Airport
|
|
123
|
+
- **LB** -- Long Branch
|
|
124
|
+
- **DO** -- Dover
|
|
125
|
+
- **MP** -- Metropark
|
|
126
|
+
|
|
127
|
+
### Train Line Codes
|
|
128
|
+
- **NE** -- Northeast Corridor
|
|
129
|
+
- **NC** -- North Jersey Coast
|
|
130
|
+
- **ME** -- Morris & Essex / Gladstone
|
|
131
|
+
- **ML** -- Main Line
|
|
132
|
+
- **BC** -- Bergen County Line
|
|
133
|
+
- **PV** -- Pascack Valley Line
|
|
134
|
+
- **RV** -- Raritan Valley Line
|
|
135
|
+
- **MC** -- Montclair-Boonton Line
|
|
136
|
+
- **AC** -- Atlantic City Line
|
|
137
|
+
- **PR** -- Princeton Branch
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## GTFS-RT (real-time feeds, binary data)
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
# Bus GTFS-RT (returns binary protobuf/zip data)
|
|
145
|
+
client.bus_gtfs.schedule_data # Static GTFS ZIP
|
|
146
|
+
client.bus_gtfs.alerts # Real-time alerts (protobuf)
|
|
147
|
+
client.bus_gtfs.trip_updates # Real-time trip updates (protobuf)
|
|
148
|
+
client.bus_gtfs.vehicle_positions # Real-time positions (protobuf)
|
|
149
|
+
|
|
150
|
+
# Bus GTFS-RT G2 (newer version with improved data)
|
|
151
|
+
client.bus_gtfs_g2.schedule_data
|
|
152
|
+
client.bus_gtfs_g2.alerts
|
|
153
|
+
client.bus_gtfs_g2.trip_updates
|
|
154
|
+
client.bus_gtfs_g2.vehicle_positions
|
|
155
|
+
|
|
156
|
+
# Rail GTFS-RT
|
|
157
|
+
rail_client.rail_gtfs.schedule_data
|
|
158
|
+
rail_client.rail_gtfs.alerts
|
|
159
|
+
rail_client.rail_gtfs.trip_updates
|
|
160
|
+
rail_client.rail_gtfs.vehicle_positions
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## GTFS Static Data (offline queries, requires import)
|
|
166
|
+
```ruby
|
|
167
|
+
gtfs = NJTransit::GTFS.new
|
|
168
|
+
gtfs.stops.find_by_code("WBRK")
|
|
169
|
+
gtfs.routes.find("197")
|
|
170
|
+
gtfs.routes_between(from: "WBRK", to: "PABT")
|
|
171
|
+
gtfs.schedule(route: "197", stop: "WBRK", date: Date.today)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## How to Answer Questions
|
|
177
|
+
|
|
178
|
+
1. **"When is my bus?"** -- Use `client.bus.departures` with stop and optionally route
|
|
179
|
+
2. **"When is my train?"** -- Use `rail_client.rail.train_schedule_19(station: code)` for next departures
|
|
180
|
+
3. **"Is my train delayed?"** -- Use `rail_client.rail.station_messages(station: code)` for alerts
|
|
181
|
+
4. **"Where is train X?"** -- Use `rail_client.rail.train_stop_list(train_id: id)` or `rail_client.rail.vehicle_data`
|
|
182
|
+
5. **"What stops are near me?"** -- Use `client.bus.stops_nearby` with coordinates
|
|
183
|
+
6. **"What buses/trains go from X to Y?"** -- Combine station/stop lookups with route queries
|
|
184
|
+
7. **Light rail questions** -- Use bus API with `mode: "HBLR"` / `"NLR"` / `"RL"`
|
|
185
|
+
|
|
186
|
+
## Response Style
|
|
187
|
+
|
|
188
|
+
- Be concise -- the user is in a terminal, probably in a hurry
|
|
189
|
+
- Format as clean tables
|
|
190
|
+
- Highlight the NEXT departure prominently
|
|
191
|
+
- Show delay info when available
|
|
192
|
+
- Always use `enrich: false` for bus API calls to avoid GTFS dependency
|
|
193
|
+
|
|
194
|
+
## User's Question
|
|
195
|
+
|
|
196
|
+
$ARGUMENTS
|
data/.mcp.json.example
ADDED
data/.mcp.json.sample
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 3.2
|
|
6
|
+
NewCops: enable
|
|
7
|
+
SuggestExtensions: false
|
|
8
|
+
|
|
9
|
+
Style/StringLiterals:
|
|
10
|
+
EnforcedStyle: double_quotes
|
|
11
|
+
|
|
12
|
+
Style/StringLiteralsInInterpolation:
|
|
13
|
+
EnforcedStyle: double_quotes
|
|
14
|
+
|
|
15
|
+
Style/Documentation:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
|
+
Style/CommentedKeyword:
|
|
19
|
+
Enabled: false
|
|
20
|
+
|
|
21
|
+
Layout/LineLength:
|
|
22
|
+
Max: 120
|
|
23
|
+
|
|
24
|
+
Metrics/BlockLength:
|
|
25
|
+
Exclude:
|
|
26
|
+
- "spec/**/*"
|
|
27
|
+
- "*.gemspec"
|
|
28
|
+
- "lib/njtransit/tasks.rb"
|
|
29
|
+
|
|
30
|
+
# HTTP client code tends to have longer classes/methods
|
|
31
|
+
Metrics/ClassLength:
|
|
32
|
+
Exclude:
|
|
33
|
+
- "lib/njtransit/client.rb"
|
|
34
|
+
- "lib/njtransit/gtfs/database.rb"
|
|
35
|
+
|
|
36
|
+
Metrics/MethodLength:
|
|
37
|
+
Exclude:
|
|
38
|
+
- "lib/njtransit/client.rb"
|
|
39
|
+
|
|
40
|
+
Metrics/AbcSize:
|
|
41
|
+
Exclude:
|
|
42
|
+
- "lib/njtransit/client.rb"
|
|
43
|
+
|
|
44
|
+
Metrics/CyclomaticComplexity:
|
|
45
|
+
Exclude:
|
|
46
|
+
- "lib/njtransit/client.rb"
|
|
47
|
+
|
|
48
|
+
Metrics/ParameterLists:
|
|
49
|
+
Exclude:
|
|
50
|
+
- "lib/njtransit/client.rb"
|
|
51
|
+
- "lib/njtransit/resources/bus.rb"
|
|
52
|
+
|
|
53
|
+
Naming/VariableNumber:
|
|
54
|
+
CheckMethodNames: false
|
|
55
|
+
|
|
56
|
+
# GTFS database schema is inherently verbose
|
|
57
|
+
Metrics/ModuleLength:
|
|
58
|
+
Exclude:
|
|
59
|
+
- "lib/njtransit/gtfs/database.rb"
|
|
60
|
+
|
|
61
|
+
# RSpec cops — relax rules that fight gem test conventions
|
|
62
|
+
RSpec/SpecFilePathFormat:
|
|
63
|
+
Enabled: false
|
|
64
|
+
|
|
65
|
+
RSpec/MultipleExpectations:
|
|
66
|
+
Max: 4
|
|
67
|
+
|
|
68
|
+
RSpec/ExampleLength:
|
|
69
|
+
Max: 10
|
|
70
|
+
|
|
71
|
+
RSpec/MultipleDescribes:
|
|
72
|
+
Enabled: false
|
|
73
|
+
|
|
74
|
+
RSpec/BeforeAfterAll:
|
|
75
|
+
Enabled: false
|
|
76
|
+
|
|
77
|
+
RSpec/DescribeClass:
|
|
78
|
+
Enabled: false
|
|
79
|
+
|
|
80
|
+
RSpec/VerifiedDoubles:
|
|
81
|
+
Enabled: false
|
|
82
|
+
|
|
83
|
+
RSpec/IdenticalEqualityAssertion:
|
|
84
|
+
Enabled: false
|
|
85
|
+
|
|
86
|
+
RSpec/ScatteredLet:
|
|
87
|
+
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2026-03-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Rail API** — train schedules, station messages, train stop lists, and live vehicle positions via `NJTransit.rail_client`
|
|
12
|
+
- **Bus GTFS-RT** — real-time alerts, trip updates, and vehicle positions (`client.bus_gtfs`)
|
|
13
|
+
- **Bus GTFS-RT G2** — newer version of bus feeds (`client.bus_gtfs_g2`)
|
|
14
|
+
- **Rail GTFS-RT** — real-time rail feeds (`rail_client.rail_gtfs`)
|
|
15
|
+
- **Light rail support** — `mode` parameter on bus API methods (`HBLR`, `NLR`, `RL`, `ALL`)
|
|
16
|
+
- **GTFS static data** — full offline schedules via SQLite, with import/query/rake tasks
|
|
17
|
+
- **Automatic enrichment** — bus API responses enriched with GTFS lat/lon and route names
|
|
18
|
+
- **Token caching** — auth tokens cached across client instances to avoid hitting daily API limits
|
|
19
|
+
- **Descriptive auth errors** — actual API error messages surfaced instead of generic "Authentication failed"
|
|
20
|
+
- **CI pipeline** — RuboCop linting and RSpec on Ruby 3.2/3.3
|
|
21
|
+
- **Automated releases** — publish to RubyGems on merge to main when version changes
|
|
22
|
+
|
|
23
|
+
### Bus API
|
|
24
|
+
|
|
25
|
+
- `routes`, `directions`, `stops`, `stop_name`, `departures`
|
|
26
|
+
- `route_trips`, `trip_stops`, `stops_nearby`, `vehicles_nearby`
|
|
27
|
+
- `locations` with mode filtering
|
|
28
|
+
|
|
29
|
+
### Rail API
|
|
30
|
+
|
|
31
|
+
- `stations`, `station_messages`, `station_schedule`
|
|
32
|
+
- `train_schedule`, `train_schedule_19`, `train_stop_list`
|
|
33
|
+
- `vehicle_data`
|
|
34
|
+
|
|
35
|
+
## [0.1.0] - 2026-01-24
|
|
36
|
+
|
|
37
|
+
- Initial release
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
### Two Clients
|
|
8
|
+
|
|
9
|
+
The gem wraps two separate NJ Transit API hosts with a single `Client` class:
|
|
10
|
+
|
|
11
|
+
- **`NJTransit.client`** → `pcsdata.njtransit.com` — Bus, light rail, bus GTFS-RT
|
|
12
|
+
- **`NJTransit.rail_client`** → `raildata.njtransit.com` — Rail/train, rail GTFS-RT
|
|
13
|
+
|
|
14
|
+
Both use the same `Client` class with different `base_url` and `auth_path`. Authentication is token-based and handled automatically (with transparent re-auth on token expiry).
|
|
15
|
+
|
|
16
|
+
### Resource Classes (`lib/njtransit/resources/`)
|
|
17
|
+
|
|
18
|
+
- `Bus` — real-time bus/light rail API (departures, routes, stops, vehicles)
|
|
19
|
+
- `Rail` — real-time rail API (schedules, station messages, vehicle tracking)
|
|
20
|
+
- `BusGTFS` — bus GTFS-RT feeds (protobuf). Also used for G2 feeds via `api_prefix` param
|
|
21
|
+
- `RailGTFS` — rail GTFS-RT feeds (protobuf)
|
|
22
|
+
|
|
23
|
+
### GTFS Static Layer (`lib/njtransit/gtfs/`)
|
|
24
|
+
|
|
25
|
+
SQLite-backed offline schedule data. Import from GTFS zip, then query via `NJTransit::GTFS.new`:
|
|
26
|
+
- `Database` — Sequel SQLite connection and schema
|
|
27
|
+
- `Importer` — parses GTFS txt files into SQLite
|
|
28
|
+
- `Models` — `Stop`, `Route`
|
|
29
|
+
- `Queries` — `RoutesBetween`, `Schedule`
|
|
30
|
+
|
|
31
|
+
### Key Patterns
|
|
32
|
+
|
|
33
|
+
- **`enrich` flag**: Bus API methods default to `enrich: true`, which joins GTFS static data (lat/lon, route names). Use `enrich: false` if GTFS isn't imported or you don't need it.
|
|
34
|
+
- **`mode` parameter**: Bus methods default to `mode: "BUS"`. Pass `"HBLR"`, `"NLR"`, `"RL"`, or `"ALL"` for light rail.
|
|
35
|
+
- **`stops_nearby` radius**: The radius parameter is in **feet**, not miles.
|
|
36
|
+
- **Raw responses**: GTFS-RT methods (`bus_gtfs`, `rail_gtfs`) return binary protobuf data via `post_form_raw`.
|
|
37
|
+
|
|
38
|
+
## Testing
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
bundle exec rspec # Run all 153 specs
|
|
42
|
+
bundle exec rspec spec/file.rb # Run a specific spec file
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
All API calls are stubbed — no credentials needed for tests.
|
|
46
|
+
|
|
47
|
+
## Git Workflow
|
|
48
|
+
|
|
49
|
+
Every change follows this process: Issue -> Branch -> Implement -> Commit -> PR -> CI -> Merge -> Release -> Cleanup.
|
|
50
|
+
|
|
51
|
+
### 1. Create Issue
|
|
52
|
+
|
|
53
|
+
- Create a GitHub issue describing the work
|
|
54
|
+
- Add the `claude` label to issues created by Claude
|
|
55
|
+
- For human-created issues: add `claude:reviewed` label after reviewing (not both labels on same issue)
|
|
56
|
+
- Include a **Success Criteria** section with testable checkbox items:
|
|
57
|
+
```markdown
|
|
58
|
+
## Success Criteria
|
|
59
|
+
- [ ] Feature X works as described
|
|
60
|
+
- [ ] All existing tests pass
|
|
61
|
+
- [ ] New tests added for feature X
|
|
62
|
+
```
|
|
63
|
+
- Note `*Co-authored by Claude*` if applicable
|
|
64
|
+
|
|
65
|
+
### 2. Create Branch
|
|
66
|
+
|
|
67
|
+
Branch naming convention:
|
|
68
|
+
```
|
|
69
|
+
fix/<issue-number>-<brief-description>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Examples:
|
|
73
|
+
- `fix/15-add-schedule-parsing`
|
|
74
|
+
- `fix/23-fix-departure-times`
|
|
75
|
+
|
|
76
|
+
### 3. Implement
|
|
77
|
+
|
|
78
|
+
- Write code and tests
|
|
79
|
+
- Update issue checkboxes as criteria are met
|
|
80
|
+
- Bump version in `lib/njtransit/version.rb`
|
|
81
|
+
- Add entry to `CHANGELOG.md` under `[Unreleased]`
|
|
82
|
+
|
|
83
|
+
**Every PR must include** a version bump and changelog entry. Dependabot PRs are exempt.
|
|
84
|
+
|
|
85
|
+
Follow [Semantic Versioning](https://semver.org/):
|
|
86
|
+
- **PATCH** (0.0.x): Bug fixes, minor doc updates
|
|
87
|
+
- **MINOR** (0.x.0): New features, new API methods
|
|
88
|
+
- **MAJOR** (x.0.0): Breaking changes to public API
|
|
89
|
+
|
|
90
|
+
### 4. Commit
|
|
91
|
+
|
|
92
|
+
Every commit must include:
|
|
93
|
+
- `Closes #<issue-number>` in the commit message body
|
|
94
|
+
- Co-authorship footer:
|
|
95
|
+
```
|
|
96
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Example:
|
|
100
|
+
```
|
|
101
|
+
Add user authentication with Devise
|
|
102
|
+
|
|
103
|
+
Closes #12
|
|
104
|
+
|
|
105
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 5. Push & Create PR
|
|
109
|
+
|
|
110
|
+
- Push branch to origin
|
|
111
|
+
- Create PR using `gh pr create`
|
|
112
|
+
- Include `*Co-authored by Claude*` in PR body
|
|
113
|
+
- Always use **merge commits** (not squash)
|
|
114
|
+
|
|
115
|
+
### 6. Monitor CI
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
bin/ci-watch <pr-number> # Check once
|
|
119
|
+
bin/ci-watch <pr-number> --poll # Poll every 10s until done
|
|
120
|
+
bin/ci-watch <pr-number> --poll 30 # Poll every 30s
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Exit codes: `0` = all passed, `1` = failed, `2` = still in progress.
|
|
124
|
+
|
|
125
|
+
- **Exit 0**: notify user and await instruction to merge
|
|
126
|
+
- **Exit 1**: investigate the failure, propose a fix — do NOT merge
|
|
127
|
+
- **Exit 2**: check again later
|
|
128
|
+
|
|
129
|
+
Do NOT merge the PR automatically. Wait for explicit user instruction.
|
|
130
|
+
|
|
131
|
+
### 7. Merge PR
|
|
132
|
+
|
|
133
|
+
After CI passes and user gives explicit instruction:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
gh pr merge <pr-number> --merge
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 8. Monitor Release
|
|
140
|
+
|
|
141
|
+
If version was bumped, a release workflow runs automatically on merge to main:
|
|
142
|
+
1. Runs the test suite
|
|
143
|
+
2. Builds the gem
|
|
144
|
+
3. Publishes to RubyGems
|
|
145
|
+
4. Creates a GitHub release with the gem attached
|
|
146
|
+
|
|
147
|
+
Monitor with: `gh run watch` (select the Release workflow). Confirm gem was published to rubygems.org.
|
|
148
|
+
|
|
149
|
+
### 9. Cleanup (only after release is healthy)
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
git checkout main
|
|
153
|
+
git pull origin main
|
|
154
|
+
git branch -d <branch-name>
|
|
155
|
+
git push origin --delete <branch-name>
|
|
156
|
+
git fetch --prune
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Do NOT delete the branch if the release failed — it may be needed for fixes.
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
+
advances of any kind
|
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
* Public or private harassment
|
|
25
|
+
* Publishing others' private information, such as a physical or email
|
|
26
|
+
address, without their explicit permission
|
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
+
professional setting
|
|
29
|
+
|
|
30
|
+
## Enforcement Responsibilities
|
|
31
|
+
|
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
+
|
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
+
|
|
40
|
+
## Enforcement
|
|
41
|
+
|
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jayrav13@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
+
|
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
+
|
|
46
|
+
## Enforcement Guidelines
|
|
47
|
+
|
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
+
|
|
50
|
+
### 1. Correction
|
|
51
|
+
|
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
+
|
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
+
|
|
56
|
+
### 2. Warning
|
|
57
|
+
|
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
+
|
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
+
|
|
62
|
+
### 3. Temporary Ban
|
|
63
|
+
|
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
+
|
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
+
|
|
68
|
+
### 4. Permanent Ban
|
|
69
|
+
|
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
+
|
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
+
|
|
74
|
+
## Attribution
|
|
75
|
+
|
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
+
|
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
+
|
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
|
82
|
+
|
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jay Ravaliya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|