New Upstream Snapshot - ruby-activerecord-explain-analyze

Ready changes

Summary

Merged new upstream version: 0.1.0+git20190817.1.cb9392a (was: 0.1.0).

Resulting package

Built on 2022-12-19T03:00 (took 6m8s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots ruby-activerecord-explain-analyze

Lintian Result

Diff

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 611bf95..1d9bdfc 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -4,10 +4,35 @@ version: 2
 jobs:
   build:
     docker:
-       - image: circleci/ruby:2.4.2
+       - image: circleci/ruby:2.6.3
+         environment:
+           RAILS_ENV: test
+           RACK_ENV: test
+       - image: circleci/postgres:11.5
+         environment:
+           POSTGRES_USER: postgres
+
     working_directory: ~/repo
     steps:
       - checkout
+      - run:
+          name: Install `psql` command
+          command: sudo apt-get update && sudo apt-get install postgresql-client
       - run: bundle install --jobs=4 --retry=3 --path vendor/bundle
       - run: bundle exec bundle-audit update && bundle exec bundle-audit check
-      - run: bundle exec rspec
+      - run:
+          name: Wait for db
+          command: dockerize -wait tcp://localhost:5432 -timeout 1m
+      - run:
+          name: Run tests
+          command: |
+            mkdir /tmp/test-results
+            bundle exec rspec \
+              --format progress \
+              --format RspecJunitFormatter \
+              --out /tmp/test-results/rspec.xml
+      - store_test_results:
+          path: /tmp/test-results
+      - store_artifacts:
+          path: /tmp/test-results
+          destination: test-results
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index c6934b3..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,15 +0,0 @@
-/.bundle/
-/.yardoc
-/Gemfile.lock
-/_yardoc/
-/coverage/
-/doc/
-/pkg/
-/spec/reports/
-/tmp/
-
-# rspec failure tracking
-.rspec_status
-
-.ruby-version
-*.gem
diff --git a/README.md b/README.md
index 256cba4..ab9b608 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,26 @@
-# activerecord-explain-analyze [![CircleCI](https://circleci.com/gh/6/activerecord-explain-analyze.svg?style=svg)](https://circleci.com/gh/6/activerecord-explain-analyze)
+# activerecord-explain-analyze [![CircleCI](https://circleci.com/gh/6/activerecord-explain-analyze.svg?style=svg)](https://circleci.com/gh/6/activerecord-explain-analyze) [![Gem Version](https://badge.fury.io/rb/activerecord-explain-analyze.svg)](https://rubygems.org/gems/activerecord-explain-analyze)
 
-Extends ActiveRecord#explain with support for EXPLAIN ANALYZE and output formats of JSON, XML, and YAML.
+Extends [`ActiveRecord#explain`](http://guides.rubyonrails.org/active_record_querying.html#running-explain) with support for EXPLAIN ANALYZE and output formats of JSON, XML, and YAML.
 
-It currently supports ActiveRecord 4 and 5, and PostgreSQL only.
+It currently supports ActiveRecord 4 through 6, and PostgreSQL only.
 
-### Examples:
+#### What's EXPLAIN ANALYZE?
+
+From the [PostgreSQL docs](https://www.postgresql.org/docs/9.6/static/using-explain.html):
+
+> PostgreSQL devises a _query plan_ for each query it receives. Choosing the right plan to match the query structure and the properties of the data is absolutely critical for good performance, so the system includes a complex _planner_ that tries to choose good plans. You can use the **EXPLAIN** command to see what query plan the planner creates for any query.
+
+> With **EXPLAIN ANALYZE**, EXPLAIN actually executes the query, and then displays the true row counts and true run time accumulated within each plan node.
+
+## Installation
+
+Add this line to your application's Gemfile and run `bundle` to install:
+
+```ruby
+gem 'activerecord-explain-analyze'
+```
+
+## Example usage
 
 ```ruby
 Wallet.where(base_currency: "USD").explain(analyze: true)
@@ -26,6 +42,12 @@ Planning time: 0.041 ms
 Execution time: 0.026 ms
 ```
 
+This can be copy-pasted into [explain.depesz.com](https://explain.depesz.com/):
+
+<img width="673" alt="explain.depesz.com example" src="https://user-images.githubusercontent.com/509837/36261515-7d350db0-125c-11e8-9c4b-618feb016971.png">
+
+You can output in `:json`, `:yaml`, and `:xml` formats as well. Below demonstrates JSON:
+
 ```ruby
 Wallet.where(base_currency: "USD").explain(analyze: true, format: :json)
 ```
@@ -51,19 +73,11 @@ Results in:
       ...
 ```
 
-You can then paste this JSON output into [PEV](http://tatiyants.com/pev/) or similar tools to get a visualization of the EXPLAIN query output:
+You can then paste this JSON output into [PEV](http://tatiyants.com/pev/) or similar tools to get a visualization of the query plan:
 
 <img width="673" alt="screen shot 2017-10-27 at 4 24 38 pm" src="https://user-images.githubusercontent.com/158675/32123765-6b4938ae-bb33-11e7-80b6-7d9ceac013e2.png">
 
 
-## Installation
-
-Add this line to your application's Gemfile and run `bundle` to install:
-
-```ruby
-gem 'activerecord-explain-analyze'
-```
-
 ## Development
 
 After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
diff --git a/activerecord-explain-analyze.gemspec b/activerecord-explain-analyze.gemspec
index 103f17b..95d838d 100644
--- a/activerecord-explain-analyze.gemspec
+++ b/activerecord-explain-analyze.gemspec
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
   spec.version       = ActiveRecordExplainAnalyze::VERSION
   spec.authors       = ["Peter Graham"]
   spec.email         = ["peterghm@gmail.com"]
-  spec.licenses      = ["MIT"] 
+  spec.licenses      = ["MIT"]
 
   spec.summary       = %q{ActiveRecord#explain with support for EXPLAIN ANALYZE and a variety of output formats}
   spec.description   = %q{Extends ActiveRecord#explain with support for EXPLAIN ANALYZE and output formats of JSON, XML, and YAML.}
@@ -30,5 +30,7 @@ Gem::Specification.new do |spec|
   spec.add_development_dependency "pry"
   spec.add_development_dependency "rspec-collection_matchers"
   spec.add_development_dependency "rspec-its"
+  spec.add_development_dependency "rspec_junit_formatter"
   spec.add_development_dependency "bundler-audit"
+  spec.add_development_dependency "database_cleaner"
 end
diff --git a/debian/changelog b/debian/changelog
index 74e0c6e..c9c9c82 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-activerecord-explain-analyze (0.1.0+git20190817.1.cb9392a-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 19 Dec 2022 02:56:26 -0000
+
 ruby-activerecord-explain-analyze (0.1.0-2) unstable; urgency=medium
 
   * Team upload
diff --git a/spec/activerecord-explain-analyze_spec.rb b/spec/activerecord-explain-analyze_spec.rb
new file mode 100644
index 0000000..f5bc87c
--- /dev/null
+++ b/spec/activerecord-explain-analyze_spec.rb
@@ -0,0 +1,37 @@
+describe ActiveRecordExplainAnalyze do
+  it "has a version number" do
+    expect(described_class::VERSION).not_to be nil
+  end
+
+  describe "#explain" do
+    before do
+      Car.create!(model: "tesla")
+      Car.create!(model: "bmw")
+    end
+
+    context "without any args" do
+      it "returns normal explain output" do
+        output = Car.where(model: "bmw").explain
+        expect(output).to start_with(%{EXPLAIN for: SELECT "cars"})
+        expect(output).not_to include("actual time")
+      end
+    end
+
+    context "with analyze: true" do
+      it "returns EXPLAIN ANALYZE output" do
+        output = Car.where(model: "bmw").explain(analyze: true)
+        expect(output).to start_with(%{EXPLAIN for: SELECT "cars"})
+        expect(output).to include("actual time")
+      end
+    end
+
+    context "with analyze: true, format: :json" do
+      it "returns EXPLAIN ANALYZE output in JSON format" do
+        output = Car.where(model: "bmw").explain(analyze: true, format: :json)
+        json = JSON.parse(output.lines[1..-1].join)
+        expect(json).to be_a(Array)
+        expect(json.first["Plan"]).to include("Node Type" => "Seq Scan")
+      end
+    end
+  end
+end
diff --git a/spec/database.yml b/spec/database.yml
new file mode 100644
index 0000000..39877df
--- /dev/null
+++ b/spec/database.yml
@@ -0,0 +1,7 @@
+postgres:
+  adapter:  postgresql
+  host:     localhost
+  database: activerecord-explain-analyze_test
+  username: postgres
+  schema_search_path: public
+  min_messages: warning
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..cfaa55b
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,66 @@
+require "bundler/setup"
+require "activerecord-explain-analyze"
+require 'rspec'
+require 'rspec/collection_matchers'
+require 'rspec/its'
+require 'database_cleaner'
+
+class Car < ActiveRecord::Base
+end
+
+def db_config
+  @db_config ||= begin
+    filepath = File.join('spec', 'database.yml')
+    YAML.load_file(filepath)['postgres']
+  end
+end
+
+def establish_connection(config)
+  ActiveRecord::Base.establish_connection(config)
+  ActiveRecord::Base.connection
+end
+
+def create_database
+  %x{psql -h localhost -p 5432 -c 'create database "#{db_config['database']}";' -U postgres;}
+  connection = establish_connection(db_config)
+  connection.create_database(db_config['database']) rescue nil
+end
+
+def create_table
+  connection = establish_connection(db_config)
+  connection.create_table(:cars, :force => true) do |t|
+    t.column :model, :string
+  end
+end
+
+RSpec.configure do |config|
+  config.filter_run :focus
+  config.expose_dsl_globally = true
+  config.run_all_when_everything_filtered = true
+
+  # Enable flags like --only-failures and --next-failure
+  config.example_status_persistence_file_path = ".rspec_status"
+
+  config.expect_with :rspec do |c|
+    c.syntax = :expect
+  end
+
+  config.before(:suite) do
+    create_database
+    create_table
+
+    DatabaseCleaner.strategy = :transaction
+    DatabaseCleaner.clean_with(:truncation)
+    begin
+      DatabaseCleaner.start
+    ensure
+      DatabaseCleaner.clean
+    end
+  end
+
+  config.around(:each) do |example|
+    DatabaseCleaner.cleaning do
+      example.run
+    end
+  end
+end

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details