monq 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '049e17df27a39b7710e1793ad8aa2bbceea1cac5781c952c604f05569e0c5e3a'
4
+ data.tar.gz: 2d1b3d71bfbf2f666116004d75cc96963576d10570926788672a8943774a814a
5
+ SHA512:
6
+ metadata.gz: b40814534a5516dd367c70a706500df2b3ca91a5313eb1544c94ddc05204e247ddc33ff54b8934731f748454dc149b4dacb924894eaf073e90684e49a9c5f86f
7
+ data.tar.gz: 7260f9a2eeb283c07a7bd4e19755897afbc44a4267896b1b58518256749bb0ffe5dd2479296cd20eef38e67b610f3304946fed4ddccb4cf7e96e7467e22721bb
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "monq" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["liuxiang921@gmail.com"](mailto:"liuxiang921@gmail.com").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Liu Xiang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Monq: Mongoid + Pry MongoDB workbench
2
+
3
+ Load user-authored Mongoid models from `~/.monq.d` and query MongoDB from a Pry REPL.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ gem install monq
9
+ ```
10
+
11
+ From this repo:
12
+
13
+ ```bash
14
+ bundle exec exe/monq
15
+ ```
16
+
17
+ ## Config
18
+
19
+ `~/.monq.d/init.yml`:
20
+
21
+ ```yaml
22
+ blog.dev:
23
+ uri: mongodb://USER:PASSWORD@db.example.com:27017/?authSource=admin
24
+ database: blog_dev
25
+ namespace: Blog
26
+ ```
27
+
28
+ `USER` and `PASSWORD` are placeholders. Put real credentials only in your local YAML or in `MONQ_TEST_URI` / `MONQ_TEST_DB` for the optional integration spec. Do not commit them.
29
+
30
+ Start with `monq -e blog.dev`. The environment prefix (`blog`) loads `~/.monq.d/blog.rb` inside the `Blog` namespace.
31
+
32
+ ## Models
33
+
34
+ `~/.monq.d/blog.rb`:
35
+
36
+ ```ruby
37
+ class User
38
+ include Mongoid::Document
39
+ store_in collection: "users"
40
+ field :name, type: String
41
+ field :status, type: String
42
+ embeds_one :meta, class_name: "UserMeta", store_as: "_meta"
43
+
44
+ def posts
45
+ Post.where(author_name: name)
46
+ end
47
+ end
48
+
49
+ class UserMeta
50
+ include Mongoid::Document
51
+ embedded_in :user, class_name: "User"
52
+ field :source, type: String
53
+ end
54
+
55
+ class Post
56
+ include Mongoid::Document
57
+ store_in collection: "posts"
58
+ field :author_name, type: String
59
+ field :title, type: String
60
+ field :published_on, type: String
61
+ end
62
+ ```
63
+
64
+ Write `class User`, not `class Blog::User`. The file is already evaluated inside the namespace, so the class becomes `Blog::User`.
65
+
66
+ String dates such as `published_on` (`YYYY-MM-DD`) sort lexicographically. Associations can be query methods on natural keys, not only ObjectId `belongs_to` / `has_many`. Non-pluralized collection names must be set with `store_in collection:`.
67
+
68
+ ## Commands
69
+
70
+ | Command | What it does |
71
+ |---------|----------------|
72
+ | `info` | Matching environments: database, client, ping, masked URI, SSH |
73
+ | `m` / `l` | Loaded models: collection, class, abbreviation |
74
+ | `show-sql` / `hide-sql` | Toggle Mongo command logging |
75
+ | `reconnect` / `reconnect!` | Rebuild a dead client, or force a rebuild. Refused while a sandbox is open |
76
+ | `redefine` | Reload prefix model files. Refused while a sandbox is open |
77
+ | `sandbox-enter` / `sandbox-quit` | Open or abort a transaction on every environment |
78
+
79
+ ## Display
80
+
81
+ - `record.t` prints one document as a table. `criteria.t` materializes the criteria first.
82
+ - Criteria and collection views without your own `limit` are capped at 500 rows (`showing N rows (capped at 500)`).
83
+ - `.v` returns table data (`[keys, nil, *rows]`). `.vd` sends rows to visidata.
84
+ - `write_csv` and `write_excel` are not capped. `limit` large results yourself.
85
+
86
+ ## SSH
87
+
88
+ A tunnel forwards a single seed and connects with `direct_connection: true`. `replicaSet` (and other topology options) are stripped. `mongodb+srv` together with `ssh` is rejected.
89
+
90
+ ## Sandbox
91
+
92
+ Transactions need a replica set or mongos. Model `save` / `update` / `delete` / `create` are intended to run inside that session. A raw `client[:c].insert_one` is not guaranteed to be inside the transaction. `sandbox-quit` aborts; there is no commit.
93
+
94
+ ## Multiple environments
95
+
96
+ ```bash
97
+ monq -e a,b
98
+ ```
99
+
100
+ A bare top-level constant resolves to the first environment in that list.
101
+
102
+ ## Contributing
103
+
104
+ Bug reports and pull requests are welcome at https://github.com/lululau/monq. Contributors are expected to follow the [code of conduct](https://github.com/lululau/monq/blob/master/CODE_OF_CONDUCT.md).
105
+
106
+ ## License
107
+
108
+ MIT. See [LICENSE.txt](LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec