console_kit 1.1.0 → 1.2.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.
data/README.md DELETED
@@ -1,163 +0,0 @@
1
- # ConsoleKit
2
-
3
- ![Gem Version](https://img.shields.io/gem/v/console_kit.svg)
4
- ![Gem Downloads](https://img.shields.io/gem/dt/console_kit.svg)
5
- ![Build Status](https://github.com/Soumyadeep-ai/console_kit/actions/workflows/release.yml/badge.svg)
6
- ![License](https://img.shields.io/github/license/Soumyadeep-ai/console_kit)
7
- ![Ruby](https://img.shields.io/badge/ruby-%3E=3.1.0-red)
8
-
9
- A simple and flexible multi-tenant console setup toolkit for Rails applications.
10
-
11
- ConsoleKit helps you manage tenant-specific database connections (SQL, MongoDB, Redis, Elasticsearch) and context configuration via an easy CLI interface and Rails integration.
12
-
13
- ## Installation
14
-
15
- Install the gem and add to the application's Gemfile by executing:
16
-
17
- ```ruby
18
- bundle add console_kit
19
- ```
20
-
21
- Additionally you can also add this line to your application's Gemfile:
22
-
23
- ```ruby
24
- gem 'console_kit'
25
- ```
26
-
27
- And then execute:
28
-
29
- ```ruby
30
- bundle install
31
- ```
32
-
33
- If bundler is not being used to manage dependencies, install the gem by executing:
34
-
35
- ```ruby
36
- gem install console_kit
37
- ```
38
-
39
- ## Usage
40
-
41
- After installing, generate the initializer and configuration files by running:
42
-
43
- ```ruby
44
- rails generate console_kit:install
45
- ```
46
-
47
- Then, edit config/initializers/console_kit.rb to define your tenants and context class. Example format:
48
-
49
- ```ruby
50
- ConsoleKit.configure do |config|
51
- config.tenants = {
52
- tenant_one: {
53
- constants: {
54
- shard: :tenant_one_db,
55
- mongo_db: :tenant_one_mongo,
56
- partner_code: 'partnerA',
57
- redis_db: 1,
58
- elasticsearch_prefix: 'tenant_one',
59
- environment: 'production'
60
- }
61
- },
62
- tenant_two: {
63
- constants: {
64
- shard: :tenant_two_db,
65
- mongo_db: :tenant_two_mongo,
66
- partner_code: 'partnerB',
67
- redis_db: 2,
68
- elasticsearch_prefix: 'tenant_two',
69
- environment: 'staging'
70
- }
71
- }
72
- }
73
-
74
- config.context_class = CurrentContext
75
-
76
- # Optional: Toggle pretty CLI output
77
- config.pretty_output = true
78
- end
79
- ```
80
-
81
- ## Supported Connections
82
-
83
- ConsoleKit automatically detects and manages connections for:
84
-
85
- | Connection | Gem Required | Config Key | Behavior |
86
- |-----------------|-----------------|--------------------------|------------------------------------------------|
87
- | SQL (ActiveRecord) | `activerecord` | `shard` | Calls `establish_connection` on your base class |
88
- | MongoDB | `mongoid` | `mongo_db` | Calls `Mongoid.override_database` |
89
- | Redis | `redis` | `redis_db` | Calls `Redis.current.select(db)` |
90
- | Elasticsearch | `elasticsearch` | `elasticsearch_prefix` | Sets `Elasticsearch::Model.index_name_prefix=` |
91
-
92
- Handlers are only activated when their corresponding gem is loaded.
93
-
94
- ## Console Usage
95
-
96
- When launching the Rails console, ConsoleKit will prompt you to select a tenant (if multiple tenants are configured). On selection, a tenant banner is displayed showing the tenant name, environment safety warnings, and active connections.
97
-
98
- ### Selection Options:
99
- - **Number or Name:** Select a tenant by its index or name (case-insensitive).
100
- - **0 (Skip):** Load the console without any tenant configuration.
101
- - **exit / quit:** Immediately terminate the console session.
102
-
103
- ### Console Helpers
104
-
105
- The following helper methods are available in your Rails console:
106
-
107
- ```ruby
108
- # Switch to a different tenant
109
- switch_tenant
110
-
111
- # Print details about the current tenant
112
- tenant_info
113
-
114
- # List all available tenants
115
- tenants
116
- ```
117
-
118
- ### Custom Prompt
119
-
120
- ConsoleKit automatically sets your IRB/Pry prompt to show the active tenant:
121
-
122
- ```
123
- [tenant_one] main:001>
124
- ```
125
-
126
- ### Other Methods
127
-
128
- ```ruby
129
- # Get current tenant
130
- ConsoleKit.current_tenant
131
- # => :tenant_one
132
-
133
- # Reset and re-select tenant
134
- ConsoleKit.reset_current_tenant
135
-
136
- # Toggle pretty output
137
- ConsoleKit.enable_pretty_output
138
- ConsoleKit.disable_pretty_output
139
- ```
140
-
141
- ### Environment Warnings
142
-
143
- When a tenant has an `environment` key in its constants:
144
- - **production**: A red warning is displayed at setup time.
145
- - **staging**: A yellow warning is displayed at setup time.
146
-
147
- ## Development
148
-
149
- 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.
150
-
151
- 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).
152
-
153
- ## Contributing
154
-
155
- Bug reports and pull requests are welcome on GitHub at [Console Kit](https://github.com/Soumyadeep-ai/console_kit). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Soumyadeep-ai/console_kit/blob/main/CODE_OF_CONDUCT.md).
156
-
157
- ## License
158
-
159
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
160
-
161
- ## Code of Conduct
162
-
163
- Everyone interacting in the ConsoleKit project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Soumyadeep-ai/console_kit/blob/main/CODE_OF_CONDUCT.md).
data/SECURITY.md DELETED
@@ -1,31 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- We do **not maintain multiple supported versions**. Only the latest released version is eligible for security updates.
6
-
7
- Once a new version is released, the previous version is branched and locked, and will no longer receive updates — including security patches.
8
-
9
- | Version | Supported |
10
- | ------- | ------------------ |
11
- | 1.1.0 | :white_check_mark: |
12
- | 1.0.0 | :x: |
13
- | 0.1.5 | :x: |
14
- | 0.1.4 | :x: |
15
- | 0.1.3 | :x: |
16
- | 0.1.2 | :x: |
17
- | 0.1.1 | :x: |
18
- | 0.1.0 | :x: |
19
-
20
- ## Reporting a Vulnerability
21
-
22
- If you discover a security vulnerability, please use the GitHub [Security Advisories](https://github.com/Soumyadeep-ai/console_kit/security/advisories/new) feature to report it privately.
23
-
24
- We follow this process:
25
- - All reported vulnerabilities are reviewed promptly.
26
- - A new version with security fixes will be released.
27
- - Once validated, we will publish an advisory and issue a patched release if necessary.
28
-
29
- Please avoid disclosing vulnerabilities publicly until we’ve had a chance to review and respond.
30
-
31
- For more details, visit [GitHub Docs: Reporting a Vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
data/sig/console_kit.rbs DELETED
@@ -1,4 +0,0 @@
1
- module ConsoleKit
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end