sequelizer 0.1.4 → 0.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.
- checksums.yaml +4 -4
- data/.beads/.gitignore +54 -0
- data/.beads/.jsonl.lock +0 -0
- data/.beads/.migration-hint-ts +1 -0
- data/.beads/README.md +81 -0
- data/.beads/config.yaml +42 -0
- data/.beads/issues.jsonl +20 -0
- data/.beads/metadata.json +7 -0
- data/.coderabbit.yaml +94 -0
- data/.devcontainer/.p10k.zsh +1713 -0
- data/.devcontainer/.zshrc +29 -0
- data/.devcontainer/Dockerfile +137 -0
- data/.devcontainer/copy-claude-credentials.sh +32 -0
- data/.devcontainer/devcontainer.json +102 -0
- data/.devcontainer/init-firewall.sh +123 -0
- data/.devcontainer/setup-credentials.sh +95 -0
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/dependabot-auto-merge.yml +36 -0
- data/.github/workflows/test.yml +44 -9
- data/.gitignore +6 -1
- data/.overcommit.yml +73 -0
- data/.rubocop.yml +167 -0
- data/AGENTS.md +126 -0
- data/CHANGELOG.md +41 -0
- data/CLAUDE.md +230 -0
- data/Gemfile +6 -2
- data/Gemfile.lock +189 -0
- data/Guardfile +1 -1
- data/Rakefile +28 -3
- data/config/platforms/base.csv +5 -0
- data/config/platforms/rdbms/athena.csv +4 -0
- data/config/platforms/rdbms/postgres.csv +3 -0
- data/config/platforms/rdbms/snowflake.csv +1 -0
- data/config/platforms/rdbms/spark.csv +3 -0
- data/lib/sequel/extensions/cold_col.rb +436 -0
- data/lib/sequel/extensions/db_opts.rb +65 -4
- data/lib/sequel/extensions/funky.rb +136 -0
- data/lib/sequel/extensions/make_readyable.rb +146 -30
- data/lib/sequel/extensions/more_sql.rb +76 -0
- data/lib/sequel/extensions/platform.rb +301 -0
- data/lib/sequel/extensions/settable.rb +64 -0
- data/lib/sequel/extensions/sql_recorder.rb +85 -0
- data/lib/sequel/extensions/unionize.rb +169 -0
- data/lib/sequel/extensions/usable.rb +30 -1
- data/lib/sequelizer/cli.rb +61 -18
- data/lib/sequelizer/connection_maker.rb +54 -72
- data/lib/sequelizer/env_config.rb +6 -6
- data/lib/sequelizer/gemfile_modifier.rb +23 -21
- data/lib/sequelizer/monkey_patches/database_in_after_connect.rb +7 -5
- data/lib/sequelizer/options.rb +102 -19
- data/lib/sequelizer/options_hash.rb +2 -0
- data/lib/sequelizer/version.rb +3 -1
- data/lib/sequelizer/yaml_config.rb +9 -4
- data/lib/sequelizer.rb +65 -9
- data/sequelizer.gemspec +20 -12
- data/test/lib/sequel/extensions/test_cold_col.rb +251 -0
- data/test/lib/sequel/extensions/test_db_opts.rb +10 -8
- data/test/lib/sequel/extensions/test_make_readyable.rb +198 -28
- data/test/lib/sequel/extensions/test_more_sql.rb +132 -0
- data/test/lib/sequel/extensions/test_platform.rb +222 -0
- data/test/lib/sequel/extensions/test_settable.rb +109 -0
- data/test/lib/sequel/extensions/test_sql_recorder.rb +231 -0
- data/test/lib/sequel/extensions/test_unionize.rb +76 -0
- data/test/lib/sequel/extensions/test_usable.rb +5 -2
- data/test/lib/sequelizer/test_connection_maker.rb +21 -17
- data/test/lib/sequelizer/test_env_config.rb +5 -2
- data/test/lib/sequelizer/test_gemfile_modifier.rb +7 -6
- data/test/lib/sequelizer/test_options.rb +42 -9
- data/test/lib/sequelizer/test_yaml_config.rb +13 -12
- data/test/test_helper.rb +37 -8
- metadata +196 -39
- data/lib/sequel/extensions/sqls.rb +0 -31
data/.overcommit.yml
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Overcommit configuration for Sequelizer
|
|
2
|
+
# See https://github.com/sds/overcommit for documentation
|
|
3
|
+
|
|
4
|
+
PreCommit:
|
|
5
|
+
# Run RuboCop to check for style violations and auto-fix when possible
|
|
6
|
+
RuboCop:
|
|
7
|
+
enabled: true
|
|
8
|
+
command: ['bundle', 'exec', 'rubocop']
|
|
9
|
+
flags: ['--autocorrect']
|
|
10
|
+
include:
|
|
11
|
+
- '**/*.rb'
|
|
12
|
+
- '**/*.rake'
|
|
13
|
+
- '**/Rakefile'
|
|
14
|
+
- '**/Gemfile'
|
|
15
|
+
- '**/*.gemspec'
|
|
16
|
+
|
|
17
|
+
# Run tests to ensure nothing is broken
|
|
18
|
+
RakeTarget:
|
|
19
|
+
enabled: true
|
|
20
|
+
targets: ['test']
|
|
21
|
+
description: 'Run test suite'
|
|
22
|
+
|
|
23
|
+
# Check for potential security issues (if bundler-audit is available)
|
|
24
|
+
BundleAudit:
|
|
25
|
+
enabled: false # Disabled by default, enable if you add bundler-audit gem
|
|
26
|
+
|
|
27
|
+
# Check for trailing whitespace
|
|
28
|
+
TrailingWhitespace:
|
|
29
|
+
enabled: true
|
|
30
|
+
exclude:
|
|
31
|
+
- '**/db/structure.sql' # Database dumps may have trailing whitespace
|
|
32
|
+
- '**/*.md' # Markdown may intentionally have trailing spaces
|
|
33
|
+
|
|
34
|
+
# Check for merge conflict markers
|
|
35
|
+
MergeConflicts:
|
|
36
|
+
enabled: true
|
|
37
|
+
|
|
38
|
+
# Check YAML syntax
|
|
39
|
+
YamlSyntax:
|
|
40
|
+
enabled: true
|
|
41
|
+
|
|
42
|
+
# Check JSON syntax
|
|
43
|
+
JsonSyntax:
|
|
44
|
+
enabled: true
|
|
45
|
+
|
|
46
|
+
# Check for hard tabs (prefer spaces)
|
|
47
|
+
HardTabs:
|
|
48
|
+
enabled: true
|
|
49
|
+
exclude:
|
|
50
|
+
- '**/Makefile*'
|
|
51
|
+
- '**/*.mk'
|
|
52
|
+
|
|
53
|
+
CommitMsg:
|
|
54
|
+
# Ensure commit messages are properly formatted
|
|
55
|
+
TextWidth:
|
|
56
|
+
enabled: true
|
|
57
|
+
max_subject_width: 60
|
|
58
|
+
max_body_width: 72
|
|
59
|
+
|
|
60
|
+
PostCheckout:
|
|
61
|
+
# Bundle install when Gemfile changes
|
|
62
|
+
BundleCheck:
|
|
63
|
+
enabled: true
|
|
64
|
+
|
|
65
|
+
PostMerge:
|
|
66
|
+
# Bundle install after merging changes to Gemfile
|
|
67
|
+
BundleCheck:
|
|
68
|
+
enabled: true
|
|
69
|
+
|
|
70
|
+
PostRewrite:
|
|
71
|
+
# Bundle install after rebasing with Gemfile changes
|
|
72
|
+
BundleCheck:
|
|
73
|
+
enabled: true
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-minitest
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 3.2
|
|
6
|
+
NewCops: enable
|
|
7
|
+
Exclude:
|
|
8
|
+
- 'vendor/**/*'
|
|
9
|
+
- 'bin/**/*'
|
|
10
|
+
- 'tmp/**/*'
|
|
11
|
+
|
|
12
|
+
# Style Configuration to match existing project standards
|
|
13
|
+
|
|
14
|
+
# Indentation: 2 spaces (matches existing code)
|
|
15
|
+
Layout/IndentationWidth:
|
|
16
|
+
Width: 2
|
|
17
|
+
|
|
18
|
+
# String quotes: prefer single quotes (matches existing code)
|
|
19
|
+
Style/StringLiterals:
|
|
20
|
+
EnforcedStyle: single_quotes
|
|
21
|
+
|
|
22
|
+
# Allow both single and double quotes in string interpolation contexts
|
|
23
|
+
Style/StringLiteralsInInterpolation:
|
|
24
|
+
EnforcedStyle: double_quotes
|
|
25
|
+
|
|
26
|
+
# Method definitions: allow no parentheses for no arguments (matches existing code)
|
|
27
|
+
Style/DefWithParentheses:
|
|
28
|
+
Enabled: false
|
|
29
|
+
|
|
30
|
+
# Method calls: allow no parentheses for no arguments (matches existing code)
|
|
31
|
+
Style/MethodCallWithoutArgsParentheses:
|
|
32
|
+
Enabled: true
|
|
33
|
+
|
|
34
|
+
# Hash syntax: prefer symbols (matches existing code)
|
|
35
|
+
|
|
36
|
+
# Line length: be reasonable but not too strict for a Ruby gem
|
|
37
|
+
Layout/LineLength:
|
|
38
|
+
Max: 120
|
|
39
|
+
AllowedPatterns: ['\A\s*#']
|
|
40
|
+
Exclude:
|
|
41
|
+
- '*.gemspec'
|
|
42
|
+
- 'test/**/*'
|
|
43
|
+
|
|
44
|
+
# Documentation: don't require class/module documentation for this gem type
|
|
45
|
+
Style/Documentation:
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
# Frozen string literal: don't enforce for compatibility
|
|
49
|
+
Style/FrozenStringLiteralComment:
|
|
50
|
+
Enabled: false
|
|
51
|
+
|
|
52
|
+
# Allow both proc and lambda
|
|
53
|
+
Style/Lambda:
|
|
54
|
+
Enabled: false
|
|
55
|
+
|
|
56
|
+
# Allow multiple assignment
|
|
57
|
+
Style/ParallelAssignment:
|
|
58
|
+
Enabled: false
|
|
59
|
+
|
|
60
|
+
# Allow guard clauses
|
|
61
|
+
Style/GuardClause:
|
|
62
|
+
Enabled: true
|
|
63
|
+
|
|
64
|
+
# Allow both if and unless modifiers
|
|
65
|
+
Style/IfUnlessModifier:
|
|
66
|
+
Enabled: true
|
|
67
|
+
|
|
68
|
+
# Method length: be reasonable for small gem
|
|
69
|
+
Metrics/MethodLength:
|
|
70
|
+
Max: 25
|
|
71
|
+
|
|
72
|
+
# Class length: be reasonable for small gem
|
|
73
|
+
Metrics/ClassLength:
|
|
74
|
+
Max: 200
|
|
75
|
+
|
|
76
|
+
# Module length: be reasonable for small gem
|
|
77
|
+
Metrics/ModuleLength:
|
|
78
|
+
Max: 200
|
|
79
|
+
|
|
80
|
+
# Block length: allow longer blocks for tests and configuration
|
|
81
|
+
Metrics/BlockLength:
|
|
82
|
+
Max: 50
|
|
83
|
+
Exclude:
|
|
84
|
+
- 'test/**/*'
|
|
85
|
+
- '*.gemspec'
|
|
86
|
+
- 'Rakefile'
|
|
87
|
+
|
|
88
|
+
# Allow both foo.empty? and foo.size == 0
|
|
89
|
+
Style/ZeroLengthPredicate:
|
|
90
|
+
Enabled: false
|
|
91
|
+
|
|
92
|
+
# Allow memoized variables with different names (e.g., @_sequelizer_db for @db)
|
|
93
|
+
Naming/MemoizedInstanceVariableName:
|
|
94
|
+
Enabled: false
|
|
95
|
+
|
|
96
|
+
# Allow short parameter names (common in Ruby for simple methods)
|
|
97
|
+
Naming/MethodParameterName:
|
|
98
|
+
MinNameLength: 1
|
|
99
|
+
|
|
100
|
+
# Allow multi-line block chains (common in Ruby data processing)
|
|
101
|
+
Style/MultilineBlockChain:
|
|
102
|
+
Enabled: false
|
|
103
|
+
|
|
104
|
+
# Relax complexity metrics for existing code
|
|
105
|
+
Metrics/AbcSize:
|
|
106
|
+
Max: 35
|
|
107
|
+
Exclude:
|
|
108
|
+
- 'test/**/*'
|
|
109
|
+
|
|
110
|
+
Metrics/CyclomaticComplexity:
|
|
111
|
+
Max: 15
|
|
112
|
+
|
|
113
|
+
Metrics/PerceivedComplexity:
|
|
114
|
+
Max: 12
|
|
115
|
+
|
|
116
|
+
Metrics/BlockNesting:
|
|
117
|
+
Max: 4
|
|
118
|
+
|
|
119
|
+
# Allow set_ prefixed methods (common pattern)
|
|
120
|
+
Naming/AccessorMethodName:
|
|
121
|
+
Enabled: false
|
|
122
|
+
|
|
123
|
+
# Allow both string and symbol keys in same hash for configuration
|
|
124
|
+
Style/HashSyntax:
|
|
125
|
+
EnforcedStyle: ruby19
|
|
126
|
+
EnforcedShorthandSyntax: either
|
|
127
|
+
|
|
128
|
+
# Minitest specific rules
|
|
129
|
+
Minitest/AssertEqual:
|
|
130
|
+
Enabled: true
|
|
131
|
+
|
|
132
|
+
Minitest/RefuteEqual:
|
|
133
|
+
Enabled: true
|
|
134
|
+
|
|
135
|
+
# Layout rules that match existing code
|
|
136
|
+
Layout/EmptyLinesAroundClassBody:
|
|
137
|
+
EnforcedStyle: empty_lines_except_namespace
|
|
138
|
+
|
|
139
|
+
Layout/EmptyLinesAroundModuleBody:
|
|
140
|
+
EnforcedStyle: empty_lines_except_namespace
|
|
141
|
+
|
|
142
|
+
# Allow trailing commas in multiline structures
|
|
143
|
+
Style/TrailingCommaInArguments:
|
|
144
|
+
EnforcedStyleForMultiline: comma
|
|
145
|
+
|
|
146
|
+
Style/TrailingCommaInArrayLiteral:
|
|
147
|
+
EnforcedStyleForMultiline: comma
|
|
148
|
+
|
|
149
|
+
Style/TrailingCommaInHashLiteral:
|
|
150
|
+
EnforcedStyleForMultiline: comma
|
|
151
|
+
|
|
152
|
+
# Disable gemspec-specific rules that don't apply to this project
|
|
153
|
+
Gemspec/DevelopmentDependencies:
|
|
154
|
+
Enabled: false
|
|
155
|
+
|
|
156
|
+
# Disable some style rules for tests to allow more flexibility
|
|
157
|
+
Style/HashLikeCase:
|
|
158
|
+
Exclude:
|
|
159
|
+
- 'test/**/*'
|
|
160
|
+
|
|
161
|
+
Lint/DuplicateBranch:
|
|
162
|
+
Exclude:
|
|
163
|
+
- 'test/**/*'
|
|
164
|
+
|
|
165
|
+
Style/StringConcatenation:
|
|
166
|
+
Exclude:
|
|
167
|
+
- 'test/**/*'
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
This project uses **bd** (beads) for issue tracking. Run `bd onboard` to get started.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bd ready # Find available work
|
|
9
|
+
bd show <id> # View issue details
|
|
10
|
+
bd update <id> --status in_progress # Claim work
|
|
11
|
+
bd close <id> # Complete work
|
|
12
|
+
bd sync # Sync with git
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
<!-- BEGIN BEADS INTEGRATION -->
|
|
16
|
+
## Issue Tracking with bd (beads)
|
|
17
|
+
|
|
18
|
+
**IMPORTANT**: This project uses **bd (beads)** for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.
|
|
19
|
+
|
|
20
|
+
### Why bd?
|
|
21
|
+
|
|
22
|
+
- Dependency-aware: Track blockers and relationships between issues
|
|
23
|
+
- Git-friendly: Auto-syncs to JSONL for version control
|
|
24
|
+
- Agent-optimized: JSON output, ready work detection, discovered-from links
|
|
25
|
+
- Prevents duplicate tracking systems and confusion
|
|
26
|
+
|
|
27
|
+
### Quick Start
|
|
28
|
+
|
|
29
|
+
**Check for ready work:**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bd ready --json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Create new issues:**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
bd create "Issue title" --description="Detailed context" -t bug|feature|task -p 0-4 --json
|
|
39
|
+
bd create "Issue title" --description="What this issue is about" -p 1 --deps discovered-from:bd-123 --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Claim and update:**
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
bd update bd-42 --status in_progress --json
|
|
46
|
+
bd update bd-42 --priority 1 --json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Complete work:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bd close bd-42 --reason "Completed" --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Issue Types
|
|
56
|
+
|
|
57
|
+
- `bug` - Something broken
|
|
58
|
+
- `feature` - New functionality
|
|
59
|
+
- `task` - Work item (tests, docs, refactoring)
|
|
60
|
+
- `epic` - Large feature with subtasks
|
|
61
|
+
- `chore` - Maintenance (dependencies, tooling)
|
|
62
|
+
|
|
63
|
+
### Priorities
|
|
64
|
+
|
|
65
|
+
- `0` - Critical (security, data loss, broken builds)
|
|
66
|
+
- `1` - High (major features, important bugs)
|
|
67
|
+
- `2` - Medium (default, nice-to-have)
|
|
68
|
+
- `3` - Low (polish, optimization)
|
|
69
|
+
- `4` - Backlog (future ideas)
|
|
70
|
+
|
|
71
|
+
### Workflow for AI Agents
|
|
72
|
+
|
|
73
|
+
1. **Check ready work**: `bd ready` shows unblocked issues
|
|
74
|
+
2. **Claim your task**: `bd update <id> --status in_progress`
|
|
75
|
+
3. **Work on it**: Implement, test, document
|
|
76
|
+
4. **Discover new work?** Create linked issue:
|
|
77
|
+
- `bd create "Found bug" --description="Details about what was found" -p 1 --deps discovered-from:<parent-id>`
|
|
78
|
+
5. **Complete**: `bd close <id> --reason "Done"`
|
|
79
|
+
|
|
80
|
+
### Auto-Sync
|
|
81
|
+
|
|
82
|
+
bd automatically syncs with git:
|
|
83
|
+
|
|
84
|
+
- Exports to `.beads/issues.jsonl` after changes (5s debounce)
|
|
85
|
+
- Imports from JSONL when newer (e.g., after `git pull`)
|
|
86
|
+
- No manual export/import needed!
|
|
87
|
+
|
|
88
|
+
### Important Rules
|
|
89
|
+
|
|
90
|
+
- ✅ Use bd for ALL task tracking
|
|
91
|
+
- ✅ Always use `--json` flag for programmatic use
|
|
92
|
+
- ✅ Link discovered work with `discovered-from` dependencies
|
|
93
|
+
- ✅ Check `bd ready` before asking "what should I work on?"
|
|
94
|
+
- ❌ Do NOT create markdown TODO lists
|
|
95
|
+
- ❌ Do NOT use external issue trackers
|
|
96
|
+
- ❌ Do NOT duplicate tracking systems
|
|
97
|
+
|
|
98
|
+
For more details, see README.md and docs/QUICKSTART.md.
|
|
99
|
+
|
|
100
|
+
<!-- END BEADS INTEGRATION -->
|
|
101
|
+
|
|
102
|
+
## Landing the Plane (Session Completion)
|
|
103
|
+
|
|
104
|
+
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
|
|
105
|
+
|
|
106
|
+
**MANDATORY WORKFLOW:**
|
|
107
|
+
|
|
108
|
+
1. **File issues for remaining work** - Create issues for anything that needs follow-up
|
|
109
|
+
2. **Run quality gates** (if code changed) - Tests, linters, builds
|
|
110
|
+
3. **Update issue status** - Close finished work, update in-progress items
|
|
111
|
+
4. **PUSH TO REMOTE** - This is MANDATORY:
|
|
112
|
+
```bash
|
|
113
|
+
git pull --rebase
|
|
114
|
+
bd sync
|
|
115
|
+
git push
|
|
116
|
+
git status # MUST show "up to date with origin"
|
|
117
|
+
```
|
|
118
|
+
5. **Clean up** - Clear stashes, prune remote branches
|
|
119
|
+
6. **Verify** - All changes committed AND pushed
|
|
120
|
+
7. **Hand off** - Provide context for next session
|
|
121
|
+
|
|
122
|
+
**CRITICAL RULES:**
|
|
123
|
+
- Work is NOT complete until `git push` succeeds
|
|
124
|
+
- NEVER stop before pushing - that leaves work stranded locally
|
|
125
|
+
- NEVER say "ready to push when you are" - YOU must push
|
|
126
|
+
- If push fails, resolve and retry until it succeeds
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
5
|
+
## 0.2.0
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- funky Sequel extension for database-specific function abstraction
|
|
9
|
+
- kvcsv as a runtime dependency
|
|
10
|
+
- Platform configuration fixtures in config/platforms/
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Broadened activesupport dependency from ~> 7.0 to >= 7, < 9
|
|
14
|
+
- Broadened hashie dependency from ~> 3.2 to >= 3.2, < 6.0
|
|
15
|
+
- Broadened dotenv dependency from ~> 2.1 to >= 2.1, < 4.0
|
|
16
|
+
- Bumped sequel from 5.93.0 to 5.101.0
|
|
17
|
+
- Added multi-Ruby CI matrix (3.2, 3.3, 3.4, 4.0) with separate lint job
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- Adapter extraction from URL scheme for search_path processing
|
|
21
|
+
|
|
22
|
+
## 0.1.6
|
|
23
|
+
|
|
24
|
+
### Removed
|
|
25
|
+
- JDBC adapter support (jdbc_hive2, jdbc_impala, jdbc_postgres) - not needed for foreseeable future
|
|
26
|
+
- Native Impala adapter support - not needed for foreseeable future
|
|
27
|
+
- Kerberos authentication functionality for enterprise databases
|
|
28
|
+
- CGI dependency used for URL escaping in JDBC connections
|
|
29
|
+
- 16 test methods related to JDBC and Impala adapters
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
- pg gem as development dependency to support PostgreSQL testing
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
- Simplified ConnectionMaker class by removing adapter-specific configuration methods
|
|
36
|
+
- Improved test coverage from 84.95% to 93.54% by removing unused code paths
|
|
37
|
+
- Updated documentation to reflect focus on standard Sequel adapters
|
|
38
|
+
|
|
39
|
+
## 0.1.5
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- Better handling of multiple directories of files for make_ready
|
|
44
|
+
|
|
4
45
|
## [0.1.0] - 2016-11-08
|
|
5
46
|
|
|
6
47
|
### Added
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Sequelizer is a Ruby gem that simplifies database connections using Sequel. It allows users to configure database connections via config/database.yml or .env files, providing an easy-to-use interface for establishing database connections without hardcoding sensitive information.
|
|
8
|
+
|
|
9
|
+
The gem includes:
|
|
10
|
+
|
|
11
|
+
- A main module that provides `db` (cached connection) and `new_db` (fresh connection) methods
|
|
12
|
+
- CLI commands for configuration management and Gemfile updating
|
|
13
|
+
- Support for multiple database adapters including PostgreSQL, Impala, and Hive2
|
|
14
|
+
- Sequel extensions for enhanced functionality
|
|
15
|
+
|
|
16
|
+
## Development Commands
|
|
17
|
+
|
|
18
|
+
### Testing
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Run all tests
|
|
22
|
+
bundle exec rake test
|
|
23
|
+
|
|
24
|
+
# Run tests with coverage report (generates coverage/index.html)
|
|
25
|
+
bundle exec rake coverage
|
|
26
|
+
|
|
27
|
+
# Run specific test file
|
|
28
|
+
bundle exec ruby -I lib test/lib/sequelizer/test_connection_maker.rb
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Linting and Formatting
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Check code style and lint issues
|
|
35
|
+
bundle exec rake lint
|
|
36
|
+
bundle exec rubocop
|
|
37
|
+
|
|
38
|
+
# Auto-fix safe linting issues
|
|
39
|
+
bundle exec rake lint_fix
|
|
40
|
+
bundle exec rubocop --auto-correct
|
|
41
|
+
|
|
42
|
+
# Auto-fix all issues (including unsafe corrections)
|
|
43
|
+
bundle exec rake format
|
|
44
|
+
bundle exec rubocop --auto-correct-all
|
|
45
|
+
|
|
46
|
+
# Run linter on specific files
|
|
47
|
+
bundle exec rubocop lib/sequelizer.rb
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Pre-commit Hooks
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Install pre-commit hooks (done automatically after bundle install)
|
|
54
|
+
bundle exec overcommit --install
|
|
55
|
+
|
|
56
|
+
# Sign configuration (if you modify .overcommit.yml)
|
|
57
|
+
bundle exec overcommit --sign
|
|
58
|
+
|
|
59
|
+
# Run pre-commit hooks manually
|
|
60
|
+
bundle exec overcommit --run
|
|
61
|
+
|
|
62
|
+
# Skip hooks for a specific commit (use sparingly)
|
|
63
|
+
git commit --no-verify -m "commit message"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The pre-commit hooks automatically run:
|
|
67
|
+
|
|
68
|
+
- RuboCop linting with auto-correction
|
|
69
|
+
- Full test suite
|
|
70
|
+
- YAML/JSON syntax validation
|
|
71
|
+
- Trailing whitespace and merge conflict checks
|
|
72
|
+
- Commit message formatting validation
|
|
73
|
+
|
|
74
|
+
### Build and Release
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Build gem
|
|
78
|
+
bundle exec rake build
|
|
79
|
+
|
|
80
|
+
# Release gem
|
|
81
|
+
bundle exec rake release
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### CLI Commands
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Show current configuration
|
|
88
|
+
bundle exec sequelizer config
|
|
89
|
+
|
|
90
|
+
# Update Gemfile with database adapter
|
|
91
|
+
bundle exec sequelizer update_gemfile
|
|
92
|
+
|
|
93
|
+
# Initialize .env file
|
|
94
|
+
bundle exec sequelizer init_env --adapter postgres --host localhost --database mydb
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Architecture
|
|
98
|
+
|
|
99
|
+
### Core Components
|
|
100
|
+
|
|
101
|
+
- **Sequelizer module** (`lib/sequelizer.rb`): Main interface providing `db` and `new_db` methods
|
|
102
|
+
- **ConnectionMaker** (`lib/sequelizer/connection_maker.rb`): Handles database connection logic and adapter-specific configurations
|
|
103
|
+
- **Options** (`lib/sequelizer/options.rb`): Manages configuration from multiple sources with precedence order
|
|
104
|
+
- **CLI** (`lib/sequelizer/cli.rb`): Thor-based command line interface
|
|
105
|
+
|
|
106
|
+
### Configuration Sources (in precedence order)
|
|
107
|
+
|
|
108
|
+
1. Passed options
|
|
109
|
+
2. .env file
|
|
110
|
+
3. Environment variables
|
|
111
|
+
4. config/database.yml
|
|
112
|
+
5. ~/.config/sequelizer/database.yml
|
|
113
|
+
|
|
114
|
+
### Sequel Extensions
|
|
115
|
+
|
|
116
|
+
Located in `lib/sequel/extensions/`:
|
|
117
|
+
|
|
118
|
+
- **db_opts**: Database-specific options handling
|
|
119
|
+
- **make_readyable**: Readiness checking functionality
|
|
120
|
+
- **settable**: Dynamic property setting
|
|
121
|
+
- **sqls**: SQL statement management
|
|
122
|
+
- **usable**: Connection usability features
|
|
123
|
+
|
|
124
|
+
### Database Support
|
|
125
|
+
|
|
126
|
+
The gem supports various database adapters with special handling for:
|
|
127
|
+
|
|
128
|
+
- PostgreSQL (including search_path/schema management)
|
|
129
|
+
- JDBC-based connections (Hive2, Impala, PostgreSQL)
|
|
130
|
+
- Kerberos authentication for enterprise databases
|
|
131
|
+
|
|
132
|
+
### Test Structure
|
|
133
|
+
|
|
134
|
+
- Tests use Minitest framework
|
|
135
|
+
- Located in `test/` directory with subdirectories mirroring `lib/` structure
|
|
136
|
+
- Helper utilities in `test_helper.rb` including constant stubbing for testing
|
|
137
|
+
|
|
138
|
+
## Coding Standards
|
|
139
|
+
|
|
140
|
+
This project follows standard Ruby community conventions enforced by RuboCop, emphasizing readability, consistency, and Ruby idioms.
|
|
141
|
+
|
|
142
|
+
### Style Conventions
|
|
143
|
+
|
|
144
|
+
**Indentation & Formatting:**
|
|
145
|
+
|
|
146
|
+
- 2-space indentation (no tabs)
|
|
147
|
+
- Single-line method definitions when appropriate: `def e(v)`
|
|
148
|
+
- Method parameters without parentheses when no arguments: `def connection`
|
|
149
|
+
- Method parameters with parentheses when there are arguments: `def initialize(options = nil)`
|
|
150
|
+
|
|
151
|
+
**Naming:**
|
|
152
|
+
|
|
153
|
+
- Module/Class names: PascalCase (`Sequelizer`, `ConnectionMaker`)
|
|
154
|
+
- Method names: snake_case (`new_db`, `find_cached`, `after_connect`)
|
|
155
|
+
- Variable names: snake_case (`sequelizer_options`, `db_config`)
|
|
156
|
+
- Instance variables: snake_case with `@` prefix (`@options`, `@_sequelizer_db`)
|
|
157
|
+
- Constants: SCREAMING_SNAKE_CASE (`VERSION`)
|
|
158
|
+
|
|
159
|
+
**Strings:**
|
|
160
|
+
|
|
161
|
+
- Single quotes for simple strings: `'postgres'`, `'mock'`
|
|
162
|
+
- Double quotes for interpolation: `"SET #{key}=#{value}"`
|
|
163
|
+
|
|
164
|
+
### Code Organization
|
|
165
|
+
|
|
166
|
+
**File Structure:**
|
|
167
|
+
|
|
168
|
+
- One main class/module per file
|
|
169
|
+
- Nested modules follow directory structure: `lib/sequelizer/connection_maker.rb`
|
|
170
|
+
- Private methods grouped at bottom with `private` keyword
|
|
171
|
+
|
|
172
|
+
**Dependencies:**
|
|
173
|
+
|
|
174
|
+
- Use `require_relative` for internal dependencies: `require_relative 'sequelizer/version'`
|
|
175
|
+
- Use `require` for external gems: `require 'sequel'`, `require 'thor'`
|
|
176
|
+
- Group requires at top of files
|
|
177
|
+
|
|
178
|
+
### Documentation
|
|
179
|
+
|
|
180
|
+
**Comments:**
|
|
181
|
+
|
|
182
|
+
- Use `#` for single-line comments
|
|
183
|
+
- Extensive method documentation with parameter descriptions
|
|
184
|
+
- Minimal inline comments, used for clarification of complex logic
|
|
185
|
+
|
|
186
|
+
### Ruby Idioms
|
|
187
|
+
|
|
188
|
+
**Patterns Used:**
|
|
189
|
+
|
|
190
|
+
- Memoization: `@_sequelizer_db ||= new_db(options)`
|
|
191
|
+
- Conditional assignment: `||=` for defaults
|
|
192
|
+
- Metaprogramming with `define_method` for dynamic method creation
|
|
193
|
+
- Symbol keys in hashes: `{ adapter: 'postgres' }`
|
|
194
|
+
- Method chaining kept readable
|
|
195
|
+
|
|
196
|
+
**Testing Patterns:**
|
|
197
|
+
|
|
198
|
+
- Test methods prefixed with `test_`: `def test_accepts_options_as_params`
|
|
199
|
+
- Extensive use of stubbing and mocking for isolated testing
|
|
200
|
+
- Custom helper methods for common setup patterns
|
|
201
|
+
|
|
202
|
+
## Ruby Sequel as Lodestone
|
|
203
|
+
|
|
204
|
+
- Refer frequently to GitHub's jeremyevans/sequel repository for:
|
|
205
|
+
- Examples of great documenation
|
|
206
|
+
- Good code organization
|
|
207
|
+
- Great commit messages
|
|
208
|
+
- Wonderful changelog messages
|
|
209
|
+
|
|
210
|
+
## Platform Abstraction Project (In Planning)
|
|
211
|
+
|
|
212
|
+
There is a separate, planned evolution of this gem documented in `oimnibus/projects/in-development/sequelizer/` with 31 ADRs. That project would add a `Platform` object to `Sequel::Database` instances with `supports_*?`/`prefers_*?` methods for abstracting RDBMS-specific behavior across Postgres, Spark, Athena, and Snowflake. **This is NOT yet implemented in this gem** — the current gem is DB-connection-only. The platform abstraction is entirely in planning documents.
|
|
213
|
+
|
|
214
|
+
## Agent Rules
|
|
215
|
+
|
|
216
|
+
1. **NEVER skip, hide, or conditionally disable tests to avoid failures.** If a test fails because a dependency is missing, add the dependency. If a test fails because fixture data is missing, create the fixtures. Wrapping a `require` in `rescue LoadError` and returning early is just as bad as deleting the test. Fix the root cause.
|
|
217
|
+
2. **NEVER exclude files from coverage to dodge SimpleCov thresholds.** If coverage is low because tests aren't running, make the tests run.
|
|
218
|
+
3. **Always test locally across all supported Ruby versions before pushing.** Use `MISE_RUBY_VERSION=X.Y mise exec -- bundle exec rake test` for each version in the CI matrix (3.2, 3.3, 3.4, 4.0).
|
|
219
|
+
4. **Run both `bundle exec rubocop` and `bundle exec rake test` before every push.** No exceptions.
|
|
220
|
+
|
|
221
|
+
## Development Memories
|
|
222
|
+
|
|
223
|
+
- Ensure that bundler is used for all ruby/rake related cli invocations
|
|
224
|
+
- Read-only operations (exploration, testing) can be done in main directory
|
|
225
|
+
- Refer to Ruby Sequel for code style, test frameworks, and general guidance
|
|
226
|
+
- To test CLI, just call bundle exec bin/sequelizer without installing binstubs
|
|
227
|
+
- **IMPORTANT**: Commands like `docker build`, `devcontainer build`, and `bundle install` can take more than 10 minutes to complete and should be run with extended timeout (e.g., 20 minutes / 1200000ms)
|
|
228
|
+
- **Wait for explicit instructions before reading files or creating plans - do not be proactive**
|
|
229
|
+
- When pushing to github or making pull requests, remember you have a PAT in GITHUB_TOKEN you can use for authentication
|
|
230
|
+
- When making a pull request, push to the "github" remote
|
data/Gemfile
CHANGED
|
@@ -3,6 +3,10 @@ source 'https://rubygems.org'
|
|
|
3
3
|
# Specify your gem's dependencies in sequelizer.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
+
group :development do
|
|
7
|
+
gem 'overcommit', '~> 0.68'
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
group :test do
|
|
7
|
-
gem
|
|
8
|
-
end
|
|
11
|
+
gem 'sequel-hexspace', github: 'outcomesinsights/sequel-hexspace', branch: 'master'
|
|
12
|
+
end
|