taql 0.2.6 → 0.3.7

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: 51560820483201d09e0deeeb279062896454dd4e74796461e6513800ef39a1a5
4
- data.tar.gz: a6bb0f39c93942d1fd4be527ecb9c59fffced9a5aa8ab490a4a340009d418388
3
+ metadata.gz: 66db91199e02a0312a18f93208174c5ef48002e60415d0b36680c6eaa3a02d61
4
+ data.tar.gz: 31358e92a67034c323975e931ab54102d6ee3cb40f5bb191fa06f5e7687f8414
5
5
  SHA512:
6
- metadata.gz: f9fa6aa118887bf1302c65b12623e4becdb30aa3a1c0a7d4239f768591b8bc937a1d8ad0604f8c2b0b856bd9452fc45aae7bd970320228288a56c7b81a9e5f9b
7
- data.tar.gz: 87aff05a7d6b00528811490d27699ce15c3ad4770a582a716e0c9904958f4bbd376228a6e507c40aae48edc05f2c25c106cb548633ae924785a321244218c04c
6
+ metadata.gz: 7c68d0a8f118fac312d48864fa64e56dc5d56b0ffc26dfb7b56196a8bc18387517c5d1f9fb69c8835bf84514962b49a7756b01a3e7f55f777e673a61b342953c
7
+ data.tar.gz: 43f2896a0c7d00455ff599425e5b22d08e0f837950fa8af44e239dfdf37a05db7e83776726ff21417642252617aabfeb852fdaf4e752af8b98c135155991565c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.7] - 2025-09-01
4
+
5
+ - Add Railtie
6
+
7
+ ## [0.2.7] - 2025-06-27
8
+
9
+ - Provide default options
10
+
3
11
  ## [0.2.6] - 2025-05-17
4
12
 
5
13
  - Fix version
data/README.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # Taql
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/taql`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Taql is a lightweight Ruby gem that provides a convenient interface for executing SQL queries with beautifully formatted results. Whether you need a command-line SQL client for quick database exploration or a programmatic way to run queries within your Ruby application, Taql has you covered.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
9
+ ```sh
10
+ $ bundle add taql
11
+ ```
14
12
 
15
13
  If bundler is not being used to manage dependencies, install the gem by executing:
16
14
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```sh
16
+ $ gem install taql
17
+ ```
18
18
 
19
19
  ## Usage
20
20
 
@@ -76,14 +76,18 @@ The return value is a native PG::Result object, which supports mapping or extrac
76
76
  | 20240815131806 |
77
77
  | 20240815131747 |
78
78
  +----------------+
79
- => \#<PG::Result:0x000000012ebf6a38 status=PGRES_TUPLES_OK ntuples=3 nfields=1 cmd_tuples=3>
79
+ => #<PG::Result:0x000000012ebf6a38 status=PGRES_TUPLES_OK ntuples=3 nfields=1 cmd_tuples=3>
80
80
  ```
81
81
 
82
82
  ## Development
83
83
 
84
84
  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.
85
85
 
86
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
86
+ To install this gem onto your local machine, run `bundle exec rake install`.
87
+
88
+ ## Releasing
89
+
90
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
87
91
 
88
92
  ## Contributing
89
93
 
@@ -0,0 +1,13 @@
1
+ require "rails/railtie"
2
+
3
+ module Taql
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :taql
6
+
7
+ initializer "taql.initialize" do
8
+ ActiveSupport.on_load(:active_record) do
9
+ Taql.instance_variable_set(:@default_connection, -> { ActiveRecord::Base.connection_pool.connection })
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/taql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Taql
2
- VERSION = "0.2.6"
2
+ VERSION = "0.3.7"
3
3
  end
data/lib/taql.rb CHANGED
@@ -1,15 +1,22 @@
1
1
  require_relative "taql/cli"
2
2
  require_relative "taql/table"
3
3
  require_relative "taql/version"
4
+ require_relative "taql/railtie" if defined?(Rails)
4
5
 
5
6
  module Taql
6
- class Error < StandardError; end
7
-
8
- def self.execute(query, options, connection: ActiveRecord::Base.connection)
9
- connection.execute(query).tap do |result|
10
- if (results = result.entries).any?
11
- $stdout.puts Table.new(results, markdown: options[:markdown])
7
+ class << self
8
+ def execute(query, options = {}, connection: nil)
9
+ (connection || default_connection).execute(query).tap do |result|
10
+ if (results = result.entries).any?
11
+ $stdout.puts Table.new(results, markdown: options[:markdown])
12
+ end
12
13
  end
13
14
  end
15
+
16
+ private
17
+
18
+ def default_connection
19
+ @default_connection&.call || raise("Taql not properly initialized with Rails")
20
+ end
14
21
  end
15
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Rzezak
@@ -27,6 +27,7 @@ files:
27
27
  - exe/taql
28
28
  - lib/taql.rb
29
29
  - lib/taql/cli.rb
30
+ - lib/taql/railtie.rb
30
31
  - lib/taql/table.rb
31
32
  - lib/taql/version.rb
32
33
  - taql.gemspec
@@ -51,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
52
  - !ruby/object:Gem::Version
52
53
  version: '0'
53
54
  requirements: []
54
- rubygems_version: 3.6.7
55
+ rubygems_version: 3.7.1
55
56
  specification_version: 4
56
57
  summary: Tableize Rails SQL queries
57
58
  test_files: []