sequelizer 0.2.0 → 0.3.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/LICENSE +21 -0
  4. data/README.md +28 -14
  5. data/lib/sequel/extensions/cold_col.rb +39 -15
  6. data/lib/sequel/extensions/funky.rb +1 -1
  7. data/lib/sequel/extensions/make_readyable.rb +18 -8
  8. data/lib/sequel/extensions/platform.rb +8 -9
  9. data/lib/sequel/extensions/smart_select_remove.rb +101 -0
  10. data/lib/sequelizer/options.rb +10 -5
  11. data/lib/sequelizer/version.rb +1 -1
  12. metadata +7 -52
  13. data/.beads/.gitignore +0 -54
  14. data/.beads/.jsonl.lock +0 -0
  15. data/.beads/.migration-hint-ts +0 -1
  16. data/.beads/README.md +0 -81
  17. data/.beads/config.yaml +0 -42
  18. data/.beads/issues.jsonl +0 -20
  19. data/.beads/metadata.json +0 -7
  20. data/.coderabbit.yaml +0 -94
  21. data/.devcontainer/.p10k.zsh +0 -1713
  22. data/.devcontainer/.zshrc +0 -29
  23. data/.devcontainer/Dockerfile +0 -137
  24. data/.devcontainer/copy-claude-credentials.sh +0 -32
  25. data/.devcontainer/devcontainer.json +0 -102
  26. data/.devcontainer/init-firewall.sh +0 -123
  27. data/.devcontainer/setup-credentials.sh +0 -95
  28. data/.github/dependabot.yml +0 -18
  29. data/.github/workflows/dependabot-auto-merge.yml +0 -36
  30. data/.github/workflows/test.yml +0 -49
  31. data/.gitignore +0 -40
  32. data/.overcommit.yml +0 -73
  33. data/.rubocop.yml +0 -167
  34. data/AGENTS.md +0 -126
  35. data/CLAUDE.md +0 -230
  36. data/Gemfile +0 -12
  37. data/Gemfile.lock +0 -189
  38. data/Guardfile +0 -28
  39. data/LICENSE.txt +0 -22
  40. data/Rakefile +0 -35
  41. data/examples/database.with_one_set_of_options.yml +0 -15
  42. data/examples/database.yml +0 -30
  43. data/examples/dot_env.txt +0 -10
  44. data/sequelizer.gemspec +0 -38
  45. data/test/lib/sequel/extensions/test_cold_col.rb +0 -251
  46. data/test/lib/sequel/extensions/test_db_opts.rb +0 -42
  47. data/test/lib/sequel/extensions/test_make_readyable.rb +0 -258
  48. data/test/lib/sequel/extensions/test_more_sql.rb +0 -132
  49. data/test/lib/sequel/extensions/test_platform.rb +0 -222
  50. data/test/lib/sequel/extensions/test_settable.rb +0 -109
  51. data/test/lib/sequel/extensions/test_sql_recorder.rb +0 -231
  52. data/test/lib/sequel/extensions/test_unionize.rb +0 -76
  53. data/test/lib/sequel/extensions/test_usable.rb +0 -15
  54. data/test/lib/sequelizer/test_connection_maker.rb +0 -123
  55. data/test/lib/sequelizer/test_env_config.rb +0 -37
  56. data/test/lib/sequelizer/test_gemfile_modifier.rb +0 -88
  57. data/test/lib/sequelizer/test_options.rb +0 -111
  58. data/test/lib/sequelizer/test_yaml_config.rb +0 -83
  59. data/test/test_helper.rb +0 -45
@@ -1,111 +0,0 @@
1
- require_relative '../../test_helper'
2
- require 'sequelizer/options'
3
-
4
- class TestOptions < Minitest::Test
5
-
6
- def test_changes_postgresql_adapter_to_postgres
7
- options = Sequelizer::Options.new(Sequelizer::OptionsHash.new(adapter: 'postgresql'))
8
-
9
- assert_equal('postgres', options.adapter)
10
- assert_equal('postgres', options.to_hash[:adapter])
11
- assert_equal('postgres', options.to_hash['adapter'])
12
- end
13
-
14
- def test_finds_search_path_as_search_path
15
- options = Sequelizer::Options.new(Sequelizer::OptionsHash.new(adapter: 'postgres', search_path: 'path'))
16
-
17
- assert_equal('path', options.search_path)
18
- end
19
-
20
- def test_finds_schema_as_search_path
21
- options = Sequelizer::Options.new(Sequelizer::OptionsHash.new(adapter: 'postgres', schema: 'path'))
22
-
23
- assert_equal('path', options.search_path)
24
- end
25
-
26
- def test_finds_schema_search_path_as_search_path
27
- options = Sequelizer::Options.new(Sequelizer::OptionsHash.new(adapter: 'postgres', schema_search_path: 'path'))
28
-
29
- assert_equal('path', options.search_path)
30
- end
31
-
32
- def test_prefers_search_path_over_schema_search_path
33
- options = Sequelizer::Options.new(Sequelizer::OptionsHash.new(adapter: 'postgres', search_path: 'path',
34
- schema_search_path: 'path2'))
35
-
36
- assert_equal('path', options.search_path)
37
- end
38
-
39
- def test_returns_timeout_as_an_integer_even_if_given_string
40
- options = Sequelizer::Options.new({ timeout: '30' })
41
-
42
- assert_equal(30, options.to_hash[:timeout])
43
- end
44
-
45
- def test_returns_a_hash_even_if_given_nil
46
- Sequelizer::YamlConfig.stub :user_config_path, Pathname.new('/completely/made/up/path/that/does/not/exist') do
47
- options = Sequelizer::Options.new
48
-
49
- assert_equal(1, options.to_hash.length)
50
- assert_instance_of(Proc, options.to_hash[:after_connect])
51
- end
52
- end
53
-
54
- def test_handles_symbolized_search_path
55
- options = Sequelizer::Options.new(search_path: 'passed', adapter: 'postgres')
56
-
57
- assert_equal 'passed', options.search_path
58
- end
59
-
60
- def test_handles_existing_after_connect
61
- db = Sequel.mock(host: :postgres)
62
- conny = Minitest::Mock.new
63
- conny.expect :db, db
64
- conny.expect :db, db
65
- conny.expect :db, db
66
-
67
- procky = proc { |conn| conn.db[:table].to_a }
68
-
69
- options = Sequelizer::Options.new(after_connect: procky)
70
- options.to_hash[:after_connect].call(conny, :default, db)
71
-
72
- assert_equal(['SELECT * FROM "table"'], db.sqls)
73
- end
74
-
75
- def test_url_based_connection_processes_search_path
76
- options = Sequelizer::Options.new(
77
- Sequelizer::OptionsHash.new(url: 'postgres://localhost/mydb', search_path: 'my_schema'),
78
- )
79
-
80
- assert_equal('my_schema', options.search_path)
81
- assert_instance_of(Proc, options.to_hash[:after_connect])
82
- end
83
-
84
- def test_url_based_connection_processes_schema_as_search_path
85
- options = Sequelizer::Options.new(
86
- Sequelizer::OptionsHash.new(url: 'postgresql://localhost/mydb', schema: 'my_schema'),
87
- )
88
-
89
- assert_equal('my_schema', options.search_path)
90
- end
91
-
92
- def test_url_based_connection_skips_search_path_processing_for_non_postgres
93
- options = Sequelizer::Options.new(
94
- Sequelizer::OptionsHash.new(url: 'mysql2://localhost/mydb', search_path: 'my_schema'),
95
- )
96
-
97
- # search_path key remains but is NOT processed (no schema creation callback)
98
- assert_equal('my_schema', options.search_path)
99
- # adapter should not be normalized to 'postgres'
100
- assert_nil(options.adapter)
101
- end
102
-
103
- def test_handles_extensions_passed_in
104
- options = Sequelizer::Options.new(extension_example_one: 1, extension_example_two: 1, not_an_extension_example: 1)
105
-
106
- assert_equal 1, options.to_hash[:not_an_extension_example]
107
- assert_includes options.extensions, :example_one, 'Failed to find example_one in extensions'
108
- assert_includes options.extensions, :example_two, 'Failed to find example_two in extensions'
109
- end
110
-
111
- end
@@ -1,83 +0,0 @@
1
- require_relative '../../test_helper'
2
- require 'sequelizer/yaml_config'
3
-
4
- class TestYamlConfig < Minitest::Test
5
-
6
- def setup
7
- @yaml_config = Sequelizer::YamlConfig.new
8
- end
9
-
10
- def with_empty_env(&)
11
- env_mock = Minitest::Mock.new
12
- env_mock.expect :[], nil, ['SEQUELIZER_ENV']
13
- env_mock.expect :[], nil, ['RAILS_ENV']
14
- env_mock.expect :[], nil, ['RACK_ENV']
15
-
16
- stub_const(Sequelizer::YamlConfig, :ENV, env_mock, &)
17
-
18
- env_mock.verify
19
- end
20
-
21
- def test_loads_from_yaml_file_if_present
22
- mock = Minitest::Mock.new
23
- file_mock = Minitest::Mock.new
24
-
25
- stub_const(Sequelizer::YamlConfig, :File, mock) do
26
- mock.expect :read, 'adapter: <%= "sqlite" %>', [file_mock]
27
- file_mock.expect :exist?, true
28
-
29
- @yaml_config.stub :config_file_path, file_mock do
30
- assert_equal({ 'adapter' => 'sqlite' }, @yaml_config.options)
31
- end
32
-
33
- file_mock.verify
34
- mock.verify
35
- end
36
- end
37
-
38
- def test_loads_by_environment_if_present
39
- file_mock = Minitest::Mock.new
40
- file_mock.expect :exist?, true
41
- @yaml_config.stub :config_file_path, file_mock do
42
- @yaml_config.stub :config, { 'development' => { 'adapter' => 'sqlite' } } do
43
- with_empty_env do
44
- assert_equal({ 'adapter' => 'sqlite' }, @yaml_config.options)
45
- end
46
- end
47
- end
48
- file_mock.verify
49
- end
50
-
51
- def test_options_default_to_empty_hash
52
- assert_empty(@yaml_config.options)
53
- end
54
-
55
- def test_path_defaults_to_local_config
56
- assert_equal(@yaml_config.config_file_path, Pathname.pwd.join('config', 'sequelizer.yml'))
57
- end
58
-
59
- def test_path_can_be_fed_pathanem_from_initialize
60
- assert_equal(Sequelizer::YamlConfig.new(Pathname.new('~').join('.config')).config_file_path,
61
- Pathname.new('~').expand_path.join('.config'))
62
- end
63
-
64
- def test_path_can_be_fed_string_from_initialize
65
- assert_equal(Sequelizer::YamlConfig.new('~/.config').config_file_path, Pathname.new('~/.config').expand_path)
66
- end
67
-
68
- def test_local_is_current_directory
69
- assert_equal(Sequelizer::YamlConfig.local_config.config_file_path, Pathname.pwd.join('config', 'sequelizer.yml'))
70
- end
71
-
72
- def test_home_uses_home_directory
73
- assert_equal(Sequelizer::YamlConfig.user_config.config_file_path,
74
- Pathname.new(Dir.home).join('.config', 'sequelizer', 'database.yml'))
75
- end
76
-
77
- def test_environment_checks_environment_variables
78
- with_empty_env do
79
- assert_equal 'development', @yaml_config.environment
80
- end
81
- end
82
-
83
- end
data/test/test_helper.rb DELETED
@@ -1,45 +0,0 @@
1
- # Disable Rails plugins for Minitest to avoid version conflicts
2
- ENV['MT_NO_PLUGINS'] = '1'
3
-
4
- # SimpleCov must be loaded before application code
5
- require 'simplecov'
6
-
7
- SimpleCov.start do
8
- add_filter '/test/'
9
- add_filter '/vendor/'
10
-
11
- add_group 'Core', 'lib/sequelizer'
12
- add_group 'Sequel Extensions', 'lib/sequel'
13
-
14
- # Temporarily lower minimum coverage to see what we're working with
15
- minimum_coverage 70
16
- minimum_coverage_by_file 40
17
-
18
- # Generate both HTML and JSON for easier analysis
19
- formatter SimpleCov::Formatter::MultiFormatter.new([
20
- SimpleCov::Formatter::HTMLFormatter,
21
- SimpleCov::Formatter::SimpleFormatter,
22
- ])
23
- end
24
-
25
- require 'minitest/autorun'
26
- require 'minitest/mock'
27
- require 'sequel'
28
-
29
- module Minitest
30
- class Test
31
-
32
- def stub_const(klass, const, replace)
33
- klass.send(:const_set, const, replace)
34
- return unless block_given?
35
-
36
- yield
37
- remove_stubbed_const(klass, const)
38
- end
39
-
40
- def remove_stubbed_const(klass, const)
41
- klass.send(:remove_const, const)
42
- end
43
-
44
- end
45
- end