litestream 0.13.0-aarch64-linux → 0.14.0-aarch64-linux
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 +4 -4
- data/README.md +26 -5
- data/app/controllers/litestream/restorations_controller.rb +1 -1
- data/lib/litestream/commands.rb +50 -25
- data/lib/litestream/generators/litestream/templates/initializer.rb +28 -16
- data/lib/litestream/version.rb +1 -1
- data/lib/litestream.rb +1 -2
- data/lib/tasks/litestream_tasks.rake +24 -46
- metadata +5 -33
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a413a275b86e89941f79ba3c6a94fd2e20302879d9b9c6a3ffe51802473dda63
         | 
| 4 | 
            +
              data.tar.gz: f5829ceddf3d396e17cfc3a0cb5cec451790d9a524736d3a53aa58036ae6be89
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a54bcf8477f6e568d97158af0f70908fa116e8a59cfa6832fb568874dad6e58d17ae02bb1cce2fb8e941be406942edb13d939c2d225023505cb6be6272363bf2
         | 
| 7 | 
            +
              data.tar.gz: 4cbf14b3acb539cbb30f3c310bb207c9fbdc1b03435d811c5ef9e00799e2dfecbfced6c0cefc309c45b4e3b63a80a05a4b61e8162b9875763c2d3fa72b5ab405
         | 
    
        data/README.md
    CHANGED
    
    | @@ -80,24 +80,27 @@ LITESTREAM_INSTALL_DIR=.bin | |
| 80 80 |  | 
| 81 81 | 
             
            You configure the Litestream executable through the [`config/litestream.yml` file](https://litestream.io/reference/config/), which is a standard Litestream configuration file as if Litestream was running in a traditional installation.
         | 
| 82 82 |  | 
| 83 | 
            -
            The gem streamlines the configuration process by providing a default configuration file for you. This configuration file will backup all SQLite databases defined in your `config/database.yml` file to one replication bucket. In order to ensure that no secrets are stored in plain-text in your repository, this configuration file leverages Litestream's support for environment variables.  | 
| 83 | 
            +
            The gem streamlines the configuration process by providing a default configuration file for you. This configuration file will backup all SQLite databases defined in your `config/database.yml` file to one replication bucket. In order to ensure that no secrets are stored in plain-text in your repository, this configuration file leverages Litestream's support for environment variables. Inspect which environment variables are available by running the `bin/rails litestream:env` command.
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            The default configuration file looks like this if you only have one SQLite database:
         | 
| 84 86 |  | 
| 85 87 | 
             
            ```yaml
         | 
| 86 88 | 
             
            dbs:
         | 
| 87 89 | 
             
              - path: storage/production.sqlite3
         | 
| 88 90 | 
             
                replicas:
         | 
| 89 91 | 
             
                  - type: s3
         | 
| 90 | 
            -
                    bucket: $LITESTREAM_REPLICA_BUCKET
         | 
| 91 92 | 
             
                    path: storage/production.sqlite3
         | 
| 93 | 
            +
                    bucket: $LITESTREAM_REPLICA_BUCKET
         | 
| 92 94 | 
             
                    access-key-id: $LITESTREAM_ACCESS_KEY_ID
         | 
| 93 95 | 
             
                    secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY
         | 
| 94 96 | 
             
            ```
         | 
| 95 97 |  | 
| 96 98 | 
             
            This is the default for Amazon S3. The full range of possible replica types (e.g. other S3-compatible object storage servers) are covered in Litestream's [replica guides](https://litestream.io/guides/#replica-guides).
         | 
| 97 99 |  | 
| 98 | 
            -
            The gem also provides a default initializer file at `config/initializers/litestream.rb` that allows you to configure  | 
| 100 | 
            +
            The gem also provides a default initializer file at `config/initializers/litestream.rb` that allows you to configure various variables referenced in the configuration file in Ruby. By providing a Ruby interface to these environment variables, you can use your preferred method of storing secrets. For example, the default generated file uses Rails' encrypted credentials to store your secrets.
         | 
| 99 101 |  | 
| 100 102 | 
             
            ```ruby
         | 
| 103 | 
            +
            # config/initializers/litestream.rb
         | 
| 101 104 | 
             
            Rails.application.configure do
         | 
| 102 105 | 
             
              litestream_credentials = Rails.application.credentials.litestream
         | 
| 103 106 |  | 
| @@ -107,7 +110,21 @@ Rails.application.configure do | |
| 107 110 | 
             
            end
         | 
| 108 111 | 
             
            ```
         | 
| 109 112 |  | 
| 110 | 
            -
             | 
| 113 | 
            +
            Outside of configuring Litestream's replication, you may also configure various other aspects of `litestream-ruby` itself. 
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            ```ruby
         | 
| 116 | 
            +
            # config/initializers/litestream.rb
         | 
| 117 | 
            +
            Rails.application.configure do
         | 
| 118 | 
            +
              # ...
         | 
| 119 | 
            +
             | 
| 120 | 
            +
              # Base controller used for Litestream dashboard
         | 
| 121 | 
            +
              config.litestream.base_controller_class = "MyApplicationController"
         | 
| 122 | 
            +
              # Set the location of the Litestream config
         | 
| 123 | 
            +
              config.litestream.config_path = "config/litestream.yml"
         | 
| 124 | 
            +
            end
         | 
| 125 | 
            +
            ```
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            However, if you need manual control over the Litestream configuration, you can edit the `config/litestream.yml` file. The full range of possible configurations are covered in Litestream's [configuration reference](https://litestream.io/reference/config/).  
         | 
| 111 128 |  | 
| 112 129 | 
             
            ### Replication
         | 
| 113 130 |  | 
| @@ -232,6 +249,7 @@ You can verify the integrity of your backed-up databases using the gem's provide | |
| 232 249 |  | 
| 233 250 | 
             
            ```ruby
         | 
| 234 251 | 
             
            Litestream.verify! "storage/production.sqlite3"
         | 
| 252 | 
            +
            Litestream.verify!(replication_sleep: 10) "storage/production.sqlite3"
         | 
| 235 253 | 
             
            ```
         | 
| 236 254 |  | 
| 237 255 | 
             
            In order to verify that the backup for that database is both restorable and fresh, the method will add a new row to that database under the `_litestream_verification` table, which it will create if needed. It will then wait `replication_sleep` seconds (defaults to 10) to give the Litestream utility time to replicate that change to whatever storage providers you have configured. After that, it will download the latest backup from that storage provider and ensure that this verification row is present in the backup. If the verification row is _not_ present, the method will raise a `Litestream::VerificationFailure` exception. This check ensures that the restored database file:
         | 
| @@ -242,6 +260,9 @@ In order to verify that the backup for that database is both restorable and fres | |
| 242 260 |  | 
| 243 261 | 
             
            After restoring the backup, the `Litestream.verify!` method will delete the restored database file. If you need the restored database file, use the `litestream:restore` rake task or `Litestream::Commands.restore` method instead.
         | 
| 244 262 |  | 
| 263 | 
            +
            > [!NOTE]
         | 
| 264 | 
            +
            > If you configure Litestream's [`sync-interval`](https://litestream.io/reference/config/#replica-settings) to be longer than the default `replication_sleep` value of 10 seconds, you will need to adjust `replication_sleep` to a value larger than `sync-interval`; otherwise, `Litestream.verify!` may appear to fail where it actually simply didn't wait long enough for replication. 
         | 
| 265 | 
            +
             | 
| 245 266 | 
             
            ### Dashboard
         | 
| 246 267 |  | 
| 247 268 | 
             
            The gem provides a web dashboard for monitoring the status of your Litestream replication. To mount the dashboard in your Rails application, add the following to your `config/routes.rb` file:
         | 
| @@ -506,7 +527,7 @@ time=YYYY-MM-DDTHH:MM:SS level=INFO msg="replicating to" name=s3 type=s3 sync-in | |
| 506 527 |  | 
| 507 528 | 
             
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 508 529 |  | 
| 509 | 
            -
            To install this gem onto your local machine, run `bundle exec rake install`.
         | 
| 530 | 
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To download the Litestream binaries run `bundle exec rake download`.
         | 
| 510 531 |  | 
| 511 532 | 
             
            For maintainers, to release a new version, run `bin/release $VERSION`, which will create a git tag for the version, push git commits and tags, and push all of the platform-specific `.gem` files to [rubygems.org](https://rubygems.org).
         | 
| 512 533 |  | 
| @@ -9,7 +9,7 @@ module Litestream | |
| 9 9 | 
             
                  now = Time.now.utc.strftime("%Y%m%d%H%M%S")
         | 
| 10 10 | 
             
                  backup = File.join(dir, "#{base}-#{now}#{ext}")
         | 
| 11 11 |  | 
| 12 | 
            -
                  Litestream::Commands.restore(database,  | 
| 12 | 
            +
                  Litestream::Commands.restore(database, **{"-o" => backup})
         | 
| 13 13 |  | 
| 14 14 | 
             
                  redirect_to root_path, notice: "Restored to <code>#{backup}</code>."
         | 
| 15 15 | 
             
                end
         | 
    
        data/lib/litestream/commands.rb
    CHANGED
    
    | @@ -1,5 +1,4 @@ | |
| 1 1 | 
             
            require_relative "upstream"
         | 
| 2 | 
            -
            require "logfmt"
         | 
| 3 2 |  | 
| 4 3 | 
             
            module Litestream
         | 
| 5 4 | 
             
              module Commands
         | 
| @@ -21,6 +20,24 @@ module Litestream | |
| 21 20 | 
             
                # raised when a litestream command fails
         | 
| 22 21 | 
             
                CommandFailedException = Class.new(StandardError)
         | 
| 23 22 |  | 
| 23 | 
            +
                module Output
         | 
| 24 | 
            +
                  class << self
         | 
| 25 | 
            +
                    def format(data)
         | 
| 26 | 
            +
                      return "" if data.nil? || data.empty?
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                      headers = data.first.keys.map(&:to_s)
         | 
| 29 | 
            +
                      widths = headers.map.with_index { |h, i|
         | 
| 30 | 
            +
                        [h.length, data.map { |r| r[data.first.keys[i]].to_s.length }.max].max
         | 
| 31 | 
            +
                      }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                      format_str = widths.map { |w| "%-#{w}s" }.join("  ")
         | 
| 34 | 
            +
                      ([headers] + data.map(&:values)).map { |row|
         | 
| 35 | 
            +
                        sprintf(format_str, *row.map(&:to_s))
         | 
| 36 | 
            +
                      }.join("\n")
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 24 41 | 
             
                class << self
         | 
| 25 42 | 
             
                  def platform
         | 
| 26 43 | 
             
                    [:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
         | 
| @@ -77,44 +94,49 @@ module Litestream | |
| 77 94 | 
             
                    exe_file
         | 
| 78 95 | 
             
                  end
         | 
| 79 96 |  | 
| 97 | 
            +
                  # Replicate can be run either as a fork or in the same process, depending on the context.
         | 
| 98 | 
            +
                  # Puma will start replication as a forked process, while running replication from a rake
         | 
| 99 | 
            +
                  # tasks won't.
         | 
| 80 100 | 
             
                  def replicate(async: false, **argv)
         | 
| 81 | 
            -
                     | 
| 101 | 
            +
                    cmd = prepare("replicate", argv)
         | 
| 102 | 
            +
                    run_replicate(cmd, async: async)
         | 
| 103 | 
            +
                  rescue
         | 
| 104 | 
            +
                    raise CommandFailedException, "Failed to execute `#{cmd.join(" ")}`"
         | 
| 82 105 | 
             
                  end
         | 
| 83 106 |  | 
| 84 | 
            -
                  def restore(database,  | 
| 107 | 
            +
                  def restore(database, **argv)
         | 
| 85 108 | 
             
                    raise DatabaseRequiredException, "database argument is required for restore command, e.g. litestream:restore -- --database=path/to/database.sqlite" if database.nil?
         | 
| 86 | 
            -
                    argv.stringify_keys!
         | 
| 87 109 |  | 
| 88 | 
            -
                    execute("restore", argv, database,  | 
| 110 | 
            +
                    execute("restore", argv, database, tabled_output: false)
         | 
| 89 111 | 
             
                  end
         | 
| 90 112 |  | 
| 91 | 
            -
                  def databases( | 
| 92 | 
            -
                    execute("databases", argv | 
| 113 | 
            +
                  def databases(**argv)
         | 
| 114 | 
            +
                    execute("databases", argv)
         | 
| 93 115 | 
             
                  end
         | 
| 94 116 |  | 
| 95 | 
            -
                  def generations(database,  | 
| 117 | 
            +
                  def generations(database, **argv)
         | 
| 96 118 | 
             
                    raise DatabaseRequiredException, "database argument is required for generations command, e.g. litestream:generations -- --database=path/to/database.sqlite" if database.nil?
         | 
| 97 119 |  | 
| 98 | 
            -
                    execute("generations", argv, database | 
| 120 | 
            +
                    execute("generations", argv, database)
         | 
| 99 121 | 
             
                  end
         | 
| 100 122 |  | 
| 101 | 
            -
                  def snapshots(database,  | 
| 123 | 
            +
                  def snapshots(database, **argv)
         | 
| 102 124 | 
             
                    raise DatabaseRequiredException, "database argument is required for snapshots command, e.g. litestream:snapshots -- --database=path/to/database.sqlite" if database.nil?
         | 
| 103 125 |  | 
| 104 | 
            -
                    execute("snapshots", argv, database | 
| 126 | 
            +
                    execute("snapshots", argv, database)
         | 
| 105 127 | 
             
                  end
         | 
| 106 128 |  | 
| 107 | 
            -
                  def wal(database,  | 
| 129 | 
            +
                  def wal(database, **argv)
         | 
| 108 130 | 
             
                    raise DatabaseRequiredException, "database argument is required for wal command, e.g. litestream:wal -- --database=path/to/database.sqlite" if database.nil?
         | 
| 109 131 |  | 
| 110 | 
            -
                    execute("wal", argv, database | 
| 132 | 
            +
                    execute("wal", argv, database)
         | 
| 111 133 | 
             
                  end
         | 
| 112 134 |  | 
| 113 135 | 
             
                  private
         | 
| 114 136 |  | 
| 115 | 
            -
                  def execute(command, argv = {}, database = nil,  | 
| 137 | 
            +
                  def execute(command, argv = {}, database = nil, tabled_output: true)
         | 
| 116 138 | 
             
                    cmd = prepare(command, argv, database)
         | 
| 117 | 
            -
                    results = run(cmd,  | 
| 139 | 
            +
                    results = run(cmd, tabled_output: tabled_output)
         | 
| 118 140 |  | 
| 119 141 | 
             
                    if Array === results && results.one? && results[0]["level"] == "ERROR"
         | 
| 120 142 | 
             
                      raise CommandFailedException, "Failed to execute `#{cmd.join(" ")}`; Reason: #{results[0]["error"]}"
         | 
| @@ -139,21 +161,24 @@ module Litestream | |
| 139 161 | 
             
                    cmd
         | 
| 140 162 | 
             
                  end
         | 
| 141 163 |  | 
| 142 | 
            -
                  def run(cmd,  | 
| 164 | 
            +
                  def run(cmd, tabled_output:)
         | 
| 165 | 
            +
                    stdout = `#{cmd.join(" ")}`.chomp
         | 
| 166 | 
            +
                    return stdout unless tabled_output
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                    keys, *rows = stdout.split("\n").map { _1.split(/\s+/) }
         | 
| 169 | 
            +
                    rows.map { keys.zip(_1).to_h }
         | 
| 170 | 
            +
                  end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                  def run_replicate(cmd, async:)
         | 
| 143 173 | 
             
                    if async
         | 
| 144 | 
            -
                      # To release the resources of the Ruby process, just fork and exit.
         | 
| 145 | 
            -
                      # The forked process executes litestream and replaces itself.
         | 
| 146 174 | 
             
                      exec(*cmd) if fork.nil?
         | 
| 147 175 | 
             
                    else
         | 
| 148 | 
            -
                       | 
| 149 | 
            -
                       | 
| 176 | 
            +
                      # When running in-process, we capture output continuously and write to stdout.
         | 
| 177 | 
            +
                      IO.popen(cmd, err: [:child, :out]) do |io|
         | 
| 178 | 
            +
                        io.each_line { |line| puts line }
         | 
| 179 | 
            +
                      end
         | 
| 150 180 | 
             
                    end
         | 
| 151 181 | 
             
                  end
         | 
| 152 | 
            -
             | 
| 153 | 
            -
                  def text_table_to_hashes(string)
         | 
| 154 | 
            -
                    keys, *rows = string.split("\n").map { _1.split(/\s+/) }
         | 
| 155 | 
            -
                    rows.map { keys.zip(_1).to_h }
         | 
| 156 | 
            -
                  end
         | 
| 157 182 | 
             
                end
         | 
| 158 183 | 
             
              end
         | 
| 159 184 | 
             
            end
         | 
| @@ -5,29 +5,41 @@ | |
| 5 5 | 
             
            # or some other mechanism where the values are only available at runtime.
         | 
| 6 6 |  | 
| 7 7 | 
             
            Rails.application.configure do
         | 
| 8 | 
            -
              #  | 
| 8 | 
            +
              # Configure Litestream through environment variables. Use Rails encrypted credentials for secrets.
         | 
| 9 9 | 
             
              # litestream_credentials = Rails.application.credentials.litestream
         | 
| 10 10 |  | 
| 11 | 
            -
              # Replica-specific bucket location.
         | 
| 12 | 
            -
              # This will be your bucket's URL without the `https://` prefix.
         | 
| 11 | 
            +
              # Replica-specific bucket location. This will be your bucket's URL without the `https://` prefix.
         | 
| 13 12 | 
             
              # For example, if you used DigitalOcean Spaces, your bucket URL could look like:
         | 
| 13 | 
            +
              #
         | 
| 14 14 | 
             
              #   https://myapp.fra1.digitaloceanspaces.com
         | 
| 15 | 
            +
              #
         | 
| 15 16 | 
             
              # And so you should set your `replica_bucket` to:
         | 
| 17 | 
            +
              #
         | 
| 16 18 | 
             
              #   myapp.fra1.digitaloceanspaces.com
         | 
| 17 | 
            -
              # | 
| 18 | 
            -
              # Scaleway Object Storage, Google Cloud Storage, Linode Object Storage, and
         | 
| 19 | 
            -
              # any SFTP server.
         | 
| 20 | 
            -
              # In this example, we are using Rails encrypted credentials to store the URL to
         | 
| 21 | 
            -
              # our storage provider bucket.
         | 
| 19 | 
            +
              #
         | 
| 22 20 | 
             
              # config.litestream.replica_bucket = litestream_credentials&.replica_bucket
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              # Replica-specific authentication key.
         | 
| 25 | 
            -
              # Litestream needs authentication credentials to access your storage provider bucket.
         | 
| 26 | 
            -
              # In this example, we are using Rails encrypted credentials to store the access key ID.
         | 
| 21 | 
            +
              #
         | 
| 22 | 
            +
              # Replica-specific authentication key. Litestream needs authentication credentials to access your storage provider bucket.
         | 
| 27 23 | 
             
              # config.litestream.replica_key_id = litestream_credentials&.replica_key_id
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              # Replica-specific secret key.
         | 
| 30 | 
            -
              # Litestream needs authentication credentials to access your storage provider bucket.
         | 
| 31 | 
            -
              # In this example, we are using Rails encrypted credentials to store the secret access key.
         | 
| 24 | 
            +
              #
         | 
| 25 | 
            +
              # Replica-specific secret key. Litestream needs authentication credentials to access your storage provider bucket.
         | 
| 32 26 | 
             
              # config.litestream.replica_access_key = litestream_credentials&.replica_access_key
         | 
| 27 | 
            +
              #
         | 
| 28 | 
            +
              # Replica-specific region. Set the bucket’s region. Only used for AWS S3 & Backblaze B2.
         | 
| 29 | 
            +
              # config.litestream.replica_region = "us-east-1"
         | 
| 30 | 
            +
              #
         | 
| 31 | 
            +
              # Replica-specific endpoint. Set the endpoint URL of the S3-compatible service. Only required for non-AWS services.
         | 
| 32 | 
            +
              # config.litestream.replica_endpoint = "endpoint.your-objectstorage.com"
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              # Configure the default Litestream config path
         | 
| 35 | 
            +
              # config.config_path = Rails.root.join("config", "litestream.yml")
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              # Configure the Litestream dashboard
         | 
| 38 | 
            +
              #
         | 
| 39 | 
            +
              # Set the default base controller class
         | 
| 40 | 
            +
              # config.litestream.base_controller_class = "MyApplicationController"
         | 
| 41 | 
            +
              #
         | 
| 42 | 
            +
              # Set authentication credentials for Litestream dashboard
         | 
| 43 | 
            +
              # config.litestream.username = litestream_credentials&.username
         | 
| 44 | 
            +
              # config.litestream.password = litestream_credentials&.password
         | 
| 33 45 | 
             
            end
         | 
    
        data/lib/litestream/version.rb
    CHANGED
    
    
    
        data/lib/litestream.rb
    CHANGED
    
    | @@ -33,8 +33,7 @@ module Litestream | |
| 33 33 | 
             
                end
         | 
| 34 34 | 
             
              end
         | 
| 35 35 |  | 
| 36 | 
            -
              mattr_writer :username, :password, :queue, :replica_bucket, :replica_region, :replica_endpoint, :replica_key_id, :replica_access_key, :systemctl_command,
         | 
| 37 | 
            -
                :config_path
         | 
| 36 | 
            +
              mattr_writer :username, :password, :queue, :replica_bucket, :replica_region, :replica_endpoint, :replica_key_id, :replica_access_key, :systemctl_command, :config_path
         | 
| 38 37 | 
             
              mattr_accessor :base_controller_class, default: "::ApplicationController"
         | 
| 39 38 |  | 
| 40 39 | 
             
              class << self
         | 
| @@ -12,83 +12,61 @@ namespace :litestream do | |
| 12 12 |  | 
| 13 13 | 
             
              desc 'Monitor and continuously replicate SQLite databases defined in your config file, for example `rake litestream:replicate -- -exec "foreman start"`'
         | 
| 14 14 | 
             
              task replicate: :environment do
         | 
| 15 | 
            -
                options =  | 
| 16 | 
            -
                if (separator_index = ARGV.index("--"))
         | 
| 17 | 
            -
                  ARGV.slice(separator_index + 1, ARGV.length)
         | 
| 18 | 
            -
                    .map { |pair| pair.split("=") }
         | 
| 19 | 
            -
                    .each { |opt| options[opt[0]] = opt[1] || nil }
         | 
| 20 | 
            -
                end
         | 
| 21 | 
            -
                options.symbolize_keys!
         | 
| 15 | 
            +
                options = parse_argv_options
         | 
| 22 16 |  | 
| 23 | 
            -
                Litestream::Commands.replicate( | 
| 17 | 
            +
                Litestream::Commands.replicate(**options)
         | 
| 24 18 | 
             
              end
         | 
| 25 19 |  | 
| 26 20 | 
             
              desc "Restore a SQLite database from a Litestream replica, for example `rake litestream:restore -- -database=storage/production.sqlite3`"
         | 
| 27 21 | 
             
              task restore: :environment do
         | 
| 28 | 
            -
                options =  | 
| 29 | 
            -
                 | 
| 30 | 
            -
                  ARGV.slice(separator_index + 1, ARGV.length)
         | 
| 31 | 
            -
                    .map { |pair| pair.split("=") }
         | 
| 32 | 
            -
                    .each { |opt| options[opt[0]] = opt[1] || nil }
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
                database = options.delete("--database") || options.delete("-database")
         | 
| 35 | 
            -
                options.symbolize_keys!
         | 
| 22 | 
            +
                options = parse_argv_options
         | 
| 23 | 
            +
                database = options.delete(:"--database") || options.delete(:"-database")
         | 
| 36 24 |  | 
| 37 | 
            -
                Litestream::Commands.restore(database,  | 
| 25 | 
            +
                puts Litestream::Commands.restore(database, **options)
         | 
| 38 26 | 
             
              end
         | 
| 39 27 |  | 
| 40 28 | 
             
              desc "List all databases and associated replicas in the config file, for example `rake litestream:databases -- -no-expand-env`"
         | 
| 41 29 | 
             
              task databases: :environment do
         | 
| 42 | 
            -
                options =  | 
| 43 | 
            -
                if (separator_index = ARGV.index("--"))
         | 
| 44 | 
            -
                  ARGV.slice(separator_index + 1, ARGV.length)
         | 
| 45 | 
            -
                    .map { |pair| pair.split("=") }
         | 
| 46 | 
            -
                    .each { |opt| options[opt[0]] = opt[1] || nil }
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
                options.symbolize_keys!
         | 
| 30 | 
            +
                options = parse_argv_options
         | 
| 49 31 |  | 
| 50 | 
            -
                Litestream::Commands.databases( | 
| 32 | 
            +
                puts Litestream::Commands::Output.format(Litestream::Commands.databases(**options))
         | 
| 51 33 | 
             
              end
         | 
| 52 34 |  | 
| 53 35 | 
             
              desc "List all generations for a database or replica, for example `rake litestream:generations -- -database=storage/production.sqlite3`"
         | 
| 54 36 | 
             
              task generations: :environment do
         | 
| 55 | 
            -
                options =  | 
| 56 | 
            -
                 | 
| 57 | 
            -
                  ARGV.slice(separator_index + 1, ARGV.length)
         | 
| 58 | 
            -
                    .map { |pair| pair.split("=") }
         | 
| 59 | 
            -
                    .each { |opt| options[opt[0]] = opt[1] || nil }
         | 
| 60 | 
            -
                end
         | 
| 61 | 
            -
                database = options.delete("--database") || options.delete("-database")
         | 
| 62 | 
            -
                options.symbolize_keys!
         | 
| 37 | 
            +
                options = parse_argv_options
         | 
| 38 | 
            +
                database = options.delete(:"--database") || options.delete(:"-database")
         | 
| 63 39 |  | 
| 64 | 
            -
                Litestream::Commands.generations(database,  | 
| 40 | 
            +
                puts Litestream::Commands::Output.format(Litestream::Commands.generations(database, **options))
         | 
| 65 41 | 
             
              end
         | 
| 66 42 |  | 
| 67 43 | 
             
              desc "List all snapshots for a database or replica, for example `rake litestream:snapshots -- -database=storage/production.sqlite3`"
         | 
| 68 44 | 
             
              task snapshots: :environment do
         | 
| 69 | 
            -
                options =  | 
| 70 | 
            -
                 | 
| 71 | 
            -
                  ARGV.slice(separator_index + 1, ARGV.length)
         | 
| 72 | 
            -
                    .map { |pair| pair.split("=") }
         | 
| 73 | 
            -
                    .each { |opt| options[opt[0]] = opt[1] || nil }
         | 
| 74 | 
            -
                end
         | 
| 75 | 
            -
                database = options.delete("--database") || options.delete("-database")
         | 
| 76 | 
            -
                options.symbolize_keys!
         | 
| 45 | 
            +
                options = parse_argv_options
         | 
| 46 | 
            +
                database = options.delete(:"--database") || options.delete(:"-database")
         | 
| 77 47 |  | 
| 78 | 
            -
                Litestream::Commands.snapshots(database,  | 
| 48 | 
            +
                puts Litestream::Commands::Output.format(Litestream::Commands.snapshots(database, **options))
         | 
| 79 49 | 
             
              end
         | 
| 80 50 |  | 
| 81 51 | 
             
              desc "List all wal files for a database or replica, for example `rake litestream:wal -- -database=storage/production.sqlite3`"
         | 
| 82 52 | 
             
              task wal: :environment do
         | 
| 53 | 
            +
                options = parse_argv_options
         | 
| 54 | 
            +
                database = options.delete(:"--database") || options.delete(:"-database")
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                puts Litestream::Commands::Output.format(
         | 
| 57 | 
            +
                  Litestream::Commands.wal(database, **options)
         | 
| 58 | 
            +
                )
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              private
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              def parse_argv_options
         | 
| 83 64 | 
             
                options = {}
         | 
| 84 65 | 
             
                if (separator_index = ARGV.index("--"))
         | 
| 85 66 | 
             
                  ARGV.slice(separator_index + 1, ARGV.length)
         | 
| 86 67 | 
             
                    .map { |pair| pair.split("=") }
         | 
| 87 68 | 
             
                    .each { |opt| options[opt[0]] = opt[1] || nil }
         | 
| 88 69 | 
             
                end
         | 
| 89 | 
            -
                database = options.delete("--database") || options.delete("-database")
         | 
| 90 70 | 
             
                options.symbolize_keys!
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                Litestream::Commands.wal(database, async: true, **options)
         | 
| 93 71 | 
             
              end
         | 
| 94 72 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,28 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: litestream
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.14.0
         | 
| 5 5 | 
             
            platform: aarch64-linux
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Stephen Margheim
         | 
| 8 8 | 
             
            bindir: exe
         | 
| 9 9 | 
             
            cert_chain: []
         | 
| 10 | 
            -
            date: 2025-06- | 
| 10 | 
            +
            date: 2025-06-13 00:00:00.000000000 Z
         | 
| 11 11 | 
             
            dependencies:
         | 
| 12 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 13 | 
            -
              name: logfmt
         | 
| 14 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 15 | 
            -
                requirements:
         | 
| 16 | 
            -
                - - ">="
         | 
| 17 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 18 | 
            -
                    version: 0.0.10
         | 
| 19 | 
            -
              type: :runtime
         | 
| 20 | 
            -
              prerelease: false
         | 
| 21 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 22 | 
            -
                requirements:
         | 
| 23 | 
            -
                - - ">="
         | 
| 24 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 25 | 
            -
                    version: 0.0.10
         | 
| 26 12 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 27 13 | 
             
              name: sqlite3
         | 
| 28 14 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -66,7 +52,7 @@ dependencies: | |
| 66 52 | 
             
                  - !ruby/object:Gem::Version
         | 
| 67 53 | 
             
                    version: '7.0'
         | 
| 68 54 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 69 | 
            -
              name:  | 
| 55 | 
            +
              name: activejob
         | 
| 70 56 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 71 57 | 
             
                requirements:
         | 
| 72 58 | 
             
                - - ">="
         | 
| @@ -80,7 +66,7 @@ dependencies: | |
| 80 66 | 
             
                  - !ruby/object:Gem::Version
         | 
| 81 67 | 
             
                    version: '7.0'
         | 
| 82 68 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 83 | 
            -
              name:  | 
| 69 | 
            +
              name: activesupport
         | 
| 84 70 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 85 71 | 
             
                requirements:
         | 
| 86 72 | 
             
                - - ">="
         | 
| @@ -107,20 +93,6 @@ dependencies: | |
| 107 93 | 
             
                - - ">="
         | 
| 108 94 | 
             
                  - !ruby/object:Gem::Version
         | 
| 109 95 | 
             
                    version: '7.0'
         | 
| 110 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            -
              name: rubyzip
         | 
| 112 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 113 | 
            -
                requirements:
         | 
| 114 | 
            -
                - - ">="
         | 
| 115 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 116 | 
            -
                    version: '0'
         | 
| 117 | 
            -
              type: :development
         | 
| 118 | 
            -
              prerelease: false
         | 
| 119 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 120 | 
            -
                requirements:
         | 
| 121 | 
            -
                - - ">="
         | 
| 122 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 123 | 
            -
                    version: '0'
         | 
| 124 96 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 125 97 | 
             
              name: rails
         | 
| 126 98 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -136,7 +108,7 @@ dependencies: | |
| 136 108 | 
             
                  - !ruby/object:Gem::Version
         | 
| 137 109 | 
             
                    version: '0'
         | 
| 138 110 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 139 | 
            -
              name:  | 
| 111 | 
            +
              name: rubyzip
         | 
| 140 112 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 141 113 | 
             
                requirements:
         | 
| 142 114 | 
             
                - - ">="
         |