deckard 0.4.1 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d5a064c82d88bfb7e1303ab4fcd7ab08936f78c78c9b27256a95fcb79e22520
4
- data.tar.gz: 71320bd238bb13cae37b84fb3d6f2fadef423dd997b93e483514e8c163208be2
3
+ metadata.gz: 0061b5bce8bdbfb3f3787dc5049ed35504081529c2bd8aa796526467fdffea35
4
+ data.tar.gz: 714d6d18d26ab344bcadc8f4a284a403b3169260f96b100897ece7b04f9a02f4
5
5
  SHA512:
6
- metadata.gz: 165d0c5ad4bc499f3fcf8d7c54ae27cde30451c1ee4a9d55ad9f86884a163ff9104c44bcf58d64213489e75cde619f78b1145b07a894a9837711746c0e18280b
7
- data.tar.gz: 4820249beabe3bb2c8bf61657cb34396b2a727a950d6b0850638105ad7a8dbbc4cc9f444d92affae1c9dc7efaeea11ecdf5a0820195723413fce8f21bc8901b2
6
+ metadata.gz: 33a6db2baa60c146f463c00151034bf4c4de3a970033d9e27d921b42b55fef2b1e1f25c52b91a17643edfe6643e153d6623c86e931960ab04a1c05f8de5f311b
7
+ data.tar.gz: 3aa42e22d2618ff664b9fc83ea3e0a7babda68ac57be546b6b638bbfdca9fb453f03b359726c3498ecea9be7782ccca18ffad4915cba4fe12b268d3a25472745
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ change the stream format and the Ruby API.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] - 2026-11-19
11
+
12
+ ### Changed
13
+
14
+ - Dump, load, and plan commands now boot automatically from a Rails app root
15
+ when `config/environment.rb` is present. See [application boot](docs/spec.md#62-requiring-the-application-environment).
16
+
10
17
  ## [0.4.1] - 2026-11-17
11
18
 
12
19
  ### Changed
data/README.md CHANGED
@@ -12,7 +12,7 @@ for ActiveRecord 8 and PostgreSQL.
12
12
 
13
13
  ## Quick start
14
14
 
15
- Add the gem to both applications:
15
+ Add the gem to both applications and run `bundle install` in each:
16
16
 
17
17
  ```ruby
18
18
  gem "deckard"
@@ -41,12 +41,13 @@ class Order < ActiveRecord::Base
41
41
  end
42
42
  ```
43
43
 
44
- From your development machine, dump on the remote side and load locally in
45
- one pipe. SSH is the transport; nothing lands on disk:
44
+ From your local Rails app root, dump on the remote side and load locally in
45
+ one pipe. Deckard loads `config/environment.rb` from each app's working
46
+ directory when present.
46
47
 
47
48
  ```bash
48
- ssh prod.example.org "deckard -r /app/config/environment -d 'Order.find(1234)'" \
49
- | deckard -r ./config/environment -l
49
+ ssh prod.example.org 'cd /app && bundle exec deckard --dump "Order.find(1234)"' \
50
+ | bundle exec deckard --load
50
51
  ```
51
52
 
52
53
  Standard error on each end reports what moved:
@@ -66,10 +67,13 @@ rather than duplicated. Everything else is a new row with a new id.
66
67
  To keep a dump around, write it to a file and load it later:
67
68
 
68
69
  ```bash
69
- deckard -r ./config/environment -d "Order.find(1234)" > order.dump
70
- deckard -r ./config/environment -l < order.dump
70
+ bundle exec deckard --dump 'Order.find(1234)' > order.dump
71
+ bundle exec deckard --load < order.dump
71
72
  ```
72
73
 
74
+ Use `-r FILE` when you need to override automatic boot. See
75
+ [application boot](docs/spec.md#62-requiring-the-application-environment).
76
+
73
77
  ## What a dump carries
74
78
 
75
79
  Dumping a record includes the rows it depends on (`belongs_to`), the record
@@ -131,8 +135,8 @@ before any record is dumped. Loading consults no plan at all.
131
135
  To see a plan before pointing it at production, print it:
132
136
 
133
137
  ```bash
134
- deckard -r ./config/environment --plan Order
135
- deckard -r ./config/environment --plan Order --format json
138
+ bundle exec deckard --plan Order
139
+ bundle exec deckard --plan Order --format json
136
140
  ```
137
141
 
138
142
  ```text
@@ -149,12 +153,9 @@ Customer
149
153
 
150
154
  ## Dumping
151
155
 
152
- `-d` evaluates a Ruby expression and streams the result to standard output.
153
- Diagnostics go to standard error; standard output carries only the stream.
154
- Application boot code that prints to stdout (a logger pointed at `STDOUT`, a
155
- stray `puts` in an initializer) cannot corrupt it: before requiring the
156
- application, deckard keeps the original stdout for itself and points file
157
- descriptor 1 at stderr.
156
+ `--dump` evaluates a Ruby expression and streams the result to standard
157
+ output. Deckard sends diagnostics and app boot output to standard error.
158
+ See [application output during a dump](docs/spec.md#66-application-output-during-a-dump).
158
159
 
159
160
  For more involved selection, pass a Ruby file instead of an expression. The
160
161
  script runs in a context exposing `dump(object)`:
@@ -167,19 +168,19 @@ dump repo.issues
167
168
  ```
168
169
 
169
170
  ```bash
170
- deckard -r ./config/environment -d config/deckard/dump-repo.rb tilt > repos.dump
171
+ bundle exec deckard --dump config/deckard/dump-repo.rb tilt > repos.dump
171
172
  ```
172
173
 
173
- Extra command-line arguments reach the script through `ARGV`, and `-d -`
174
- reads the script from standard input. An expression given to `-d` runs in
174
+ Extra command-line arguments reach the script through `ARGV`, and `--dump -`
175
+ reads the script from standard input. An expression given to `--dump` runs in
175
176
  the same context, so it may call `dump` directly. While stderr is a
176
177
  terminal, a live object counter shows progress on both ends of the pipe.
177
178
 
178
179
  ## Loading
179
180
 
180
- `-l` reads a stream from standard input and loads it inside one transaction,
181
- bypassing validations and callbacks: it copies data, it does not run your
182
- application. If the source dies mid-stream, nothing is committed.
181
+ `--load` reads a stream from standard input and loads it in one transaction.
182
+ The load bypasses model validations and callbacks. If the source dies
183
+ mid-stream, nothing is committed.
183
184
 
184
185
  Deckard syncs a primary key that is not auto-populated like any other
185
186
  field. Give that model a match key if the same dump will be loaded twice.
@@ -209,13 +210,8 @@ between two docker compose containers. `bundle exec rake test-all` runs both
209
210
  host-side checks and the full-stack test. See `docs/spec.md` for the v1.0
210
211
  specification and `docs/traversal.md` for how a dump walks the graph.
211
212
 
212
- Crow CI runs `bundle exec rake` on pull requests, default-branch pushes, and
213
- manual runs using Ruby and an isolated PostgreSQL service. The workflow in
214
- [`.crow/ruby.yaml`](.crow/ruby.yaml) defines the runtime versions and covers
215
- specs, Standard lint, and the style ratchet. [`.crow/e2e.yaml`](.crow/e2e.yaml)
216
- runs the end-to-end stream test. The performance suite remains a separate
217
- local task.
213
+ See the [CI and validation guide](CLAUDE.md#ci-and-validation) for workflow
214
+ coverage and commands.
218
215
 
219
- See the [shared release guide](https://github.com/rsanheim/.github#readme) for
220
- setup and operation, and the [Deckard quick reference](docs/releasing.md) for
221
- the files to update in a release PR.
216
+ See [Releasing Deckard](docs/releasing.md) for release setup and the files to
217
+ update in a release PR.
data/lib/deckard/cli.rb CHANGED
@@ -5,10 +5,10 @@ require_relative "plan_report"
5
5
  require_relative "status"
6
6
 
7
7
  module Deckard
8
- # The deckard executable: -r requires the application environment, -d
9
- # dumps a Ruby expression or dump script to stdout, -l loads a stream
10
- # from stdin, --plan prints a root model's plan. Required from
11
- # exe/deckard, not from the library itself.
8
+ # The deckard executable: boots the application in the working directory
9
+ # (or the file given to -r), -d dumps a Ruby expression or dump script to
10
+ # stdout, -l loads a stream from stdin, --plan prints a root model's plan.
11
+ # Required from exe/deckard, not from the library itself.
12
12
  class CLI
13
13
  # Evaluation context for dump scripts and -d expressions: exposes only
14
14
  # dump(object). Scripts see any extra command-line arguments in ARGV.
@@ -31,7 +31,9 @@ module Deckard
31
31
  def run(argv)
32
32
  options = parse(argv)
33
33
  reserve_stdout if options[:dump]
34
- require File.expand_path(options[:require]) if options[:require]
34
+ environment = options[:require]
35
+ environment ||= "config/environment.rb" if File.file?("config/environment.rb")
36
+ require File.expand_path(environment) if environment
35
37
 
36
38
  if options[:dump]
37
39
  dump(options[:dump])
@@ -69,15 +71,17 @@ module Deckard
69
71
  banner <<~BANNER
70
72
  deckard: stream ActiveRecord objects between Rails environments
71
73
 
72
- dump: deckard -r ./config/environment -d "User.find(1)" > user.dump
73
- load: deckard -r ./config/environment -l < user.dump
74
- pipe: ssh example.org "deckard -r /app/config/environment -d 'User.find(1)'" | deckard -r ./config/environment -l
75
- plan: deckard -r ./config/environment --plan User
74
+ dump: deckard --dump "User.find(1)" > user.dump
75
+ load: deckard --load < user.dump
76
+ plan: deckard --plan User
77
+
78
+ Dump, load, and plan commands load config/environment.rb from the
79
+ current directory when present.
76
80
 
77
81
  Options:
78
82
  BANNER
79
- opt :require, "Ruby file to require first (usually config/environment)", type: :string
80
- opt :dump, "Dump the result of a Ruby expression, or run a dump script (a file, or - for stdin)", type: :string
83
+ opt :require, "Ruby file to load in place of config/environment.rb", type: :string
84
+ opt :dump, "Dump the result of a Ruby expression or run a dump script. Use - to read the script from standard input.", type: :string
81
85
  opt :load, "Load a deckard stream from standard input"
82
86
  opt :plan, "Print the plan for dumps rooted at MODEL", type: :string
83
87
  opt :format, "Plan output: #{PlanReport::FORMATS.join(" or ")}", default: "text"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deckard
4
- VERSION = "0.4.1"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deckard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Sanheim