odba 1.1.9 → 1.2.1

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/devenv.yml +34 -0
  3. data/.github/workflows/ruby.yml +8 -8
  4. data/.gitignore +15 -0
  5. data/History.md +131 -0
  6. data/README.md +77 -1
  7. data/Rakefile +3 -15
  8. data/devenv.lock +171 -0
  9. data/devenv.nix +66 -0
  10. data/devenv.yaml +16 -0
  11. data/lib/odba/cache.rb +395 -344
  12. data/lib/odba/cache_entry.rb +42 -31
  13. data/lib/odba/connection_pool.rb +99 -72
  14. data/lib/odba/drbwrapper.rb +26 -18
  15. data/lib/odba/id_server.rb +20 -20
  16. data/lib/odba/index.rb +249 -215
  17. data/lib/odba/index_definition.rb +17 -17
  18. data/lib/odba/marshal.rb +15 -14
  19. data/lib/odba/odba.rb +40 -32
  20. data/lib/odba/odba_error.rb +4 -2
  21. data/lib/odba/persistable.rb +460 -414
  22. data/lib/odba/storage.rb +328 -277
  23. data/lib/odba/stub.rb +166 -153
  24. data/lib/odba/version.rb +1 -1
  25. data/lib/odba.rb +9 -9
  26. data/odba.gemspec +8 -3
  27. data/test/example.rb +47 -0
  28. data/test/helper.rb +6 -0
  29. data/test/suite.rb +7 -0
  30. data/test/test_array.rb +38 -33
  31. data/test/test_cache.rb +666 -622
  32. data/test/test_cache_entry.rb +51 -71
  33. data/test/test_connection_pool.rb +70 -25
  34. data/test/test_drbwrapper.rb +31 -20
  35. data/test/test_hash.rb +98 -89
  36. data/test/test_id_server.rb +30 -32
  37. data/test/test_index.rb +191 -158
  38. data/test/test_marshal.rb +15 -25
  39. data/test/test_persistable.rb +378 -369
  40. data/test/test_storage.rb +510 -471
  41. data/test/test_stub.rb +147 -135
  42. metadata +63 -20
  43. data/Guide.txt +0 -36
  44. data/History.txt +0 -91
  45. data/Manifest.txt +0 -38
  46. data/install.rb +0 -1098
  47. data/lib/odba/18_19_loading_compatibility.rb +0 -77
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf433bdf191c8648bff438af766f69c0d67719c16bafc26873224bb3b470dedd
4
- data.tar.gz: fac7e49118a2d3be4235b4cd8f6865f6b1f993cb58b11da176ab379a7d8b50fe
3
+ metadata.gz: ea8626e332e7e9650d0221804e2cc6b6767e0fdedbabb507faaa2ad104b4199e
4
+ data.tar.gz: '06848ad3f7def177deec9c62385e1b63c56fcbf3e6d161f3a73e60a70a0c92a9'
5
5
  SHA512:
6
- metadata.gz: c3658aaeaed768a1533b2d2f26901a3f1504fca1486061e6b066d4d01eeac4b53c21af09592f217a81ef58b0d19ca09e94655ea002db07fee6c26a5577e62b6d
7
- data.tar.gz: e3bd93f6b85575220201abb7350337025fb0a790c9e4af1c7d791a350184b9f4bb25de9b3705bcd6ec2ff5060fe7cbf574bb787aba7fa3b0221f6d9386e9fddc
6
+ metadata.gz: 2d55bb2c6b46d92bd89da28489544b8fc68e8c4fd16a94f3deefef5970376fa2a607c9c9c811506c6f66147f02fcc9981148baf89acd54ae528c51c2b0a7dda6
7
+ data.tar.gz: 2337e2c7910c89653bdb6ddb90150aa38794096f1c5110bd94ae0f4bd54f84006d6ae8cf4bb08bc467e1d0c78d5d28cbfd5e7788611cf75bb83739432d8f3a75
@@ -0,0 +1,34 @@
1
+ name: "devenv test using a real postgres database"
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+
7
+ jobs:
8
+ tests:
9
+ strategy:
10
+ # without this a failure on one OS cancels the other, hiding its result
11
+ fail-fast: false
12
+ matrix:
13
+ # macos-latest dropped: it costs ~8 minutes per run for a library that
14
+ # is deployed on Linux, and its Nix/devenv setup is the fragile part -
15
+ # not odba itself. Re-add it here if that ever becomes worth the wait.
16
+ os: [ubuntu-latest]
17
+ runs-on: ${{ matrix.os }}
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: cachix/install-nix-action@v31
22
+ - uses: cachix/cachix-action@v16
23
+ with:
24
+ name: devenv
25
+ - name: Install devenv.sh
26
+ run: nix profile install nixpkgs#devenv
27
+
28
+ # devenv test builds the shell, runs any pre-commit hooks, brings the
29
+ # postgres service up and then runs enterTest, which waits for the server
30
+ # and runs test/example.rb against it. A separate step re-running
31
+ # example.rb duplicated that work and raced initdb a second time without
32
+ # waiting, which is what kept macOS red.
33
+ - name: Build the devenv shell and run test/example.rb against a real postgres
34
+ run: devenv test
@@ -9,9 +9,11 @@ name: Ruby
9
9
 
10
10
  on:
11
11
  push:
12
- branches: [ master ]
12
+ branches:
13
+ - '*'
13
14
  pull_request:
14
- branches: [ master ]
15
+ branches:
16
+ - '*'
15
17
 
16
18
  jobs:
17
19
  test:
@@ -22,14 +24,12 @@ jobs:
22
24
  fail-fast: false
23
25
  matrix:
24
26
  os: [ ubuntu]
25
- ruby: [2.7, 3.0, 3.1, head]
26
- continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
27
+ ruby: [3.2, 3.3, 3.4]
27
28
  steps:
28
- - uses: actions/checkout@v2
29
+ - uses: actions/checkout@v4
29
30
  - uses: ruby/setup-ruby@v1
30
31
  with:
31
32
  ruby-version: ${{ matrix.ruby }}
32
33
  bundler-cache: true
33
-
34
- - name: Run tests via rake test
35
- run: bundle exec rake test
34
+ - name: Run tests via test/suite.rb
35
+ run: bundle exec ruby test/suite.rb
data/.gitignore CHANGED
@@ -2,3 +2,18 @@
2
2
  vendor/
3
3
  coverage/
4
4
  pkg/
5
+ Gemfile.lock
6
+
7
+ # Devenv
8
+ .devenv*
9
+ devenv.local.nix
10
+
11
+ # direnv
12
+ .direnv
13
+
14
+ # pre-commit
15
+ .pre-commit-config.yaml
16
+
17
+ # built gems - a committed .gem ends up in spec.files (git ls-files) and
18
+ # makes the gemspec invalid: "odba-x.y.z contains itself"
19
+ *.gem
data/History.md ADDED
@@ -0,0 +1,131 @@
1
+ ## 1.2.1 / 21.08.2026
2
+
3
+ No library changes: lib/ is identical to 1.2.0. This release only ships a test
4
+ suite and CI that pass.
5
+
6
+ * Cleared CacheEntry's @@id_table between cache tests. Its ObjectSpace
7
+ finalizer calls ODBA.cache.invalidate, so objects left by earlier tests were
8
+ collected at unpredictable moments and deleted ids the running test had just
9
+ stored - the long standing flakiness in test_clean, test_clean__prefetched
10
+ and test_transaction
11
+ * Fixed test_to_obj for drb >= 2.2, which resolves only ids to_id handed out
12
+ rather than looking them up with ObjectSpace._id2ref
13
+ * Bumped install-nix-action to v31: v26 cannot provision Nix build users on
14
+ current macOS images
15
+ * Stopped starting the processes twice in enterTest and waited for postgres
16
+ before running test/example.rb
17
+ * Declared the git-hooks input that current devenv no longer injects implicitly
18
+ * Dropped a continue-on-error that used matrix.ruby.to_s, which GitHub Actions
19
+ expressions do not support, so it silently never applied
20
+
21
+ ## 1.2.0 / 21.08.2026
22
+
23
+ * Reconnect when the database connection was lost. ydbd-pg reports a lost
24
+ connection as DBI::ProgrammingError, which the ConnectionPool excluded from
25
+ its retry, so a restart of the PostgreSQL server left every pooled connection
26
+ broken until the client process itself was restarted
27
+ * Removed obsolete install.rb. Updated History.txt and moved it to History.md
28
+ * Used standarb for all files
29
+ * Removed obsolete (and not needed) WITH_OIDS to allow running with postgres 12 and later
30
+ * Use SimpleCov. Simplified test/test*.rb to include test/helper.rb and start coverage
31
+ * Updated README.md for devenv
32
+ * Run test/exmple.rb using devenv in .github/workflows/devenv.yml
33
+ * Added test/exmple.rb using a real Postgresql 17. Updated README
34
+ * Merged Guide.txt and into README.md
35
+ * Silence NOTICE if table already exists
36
+ * Removed obsolete Manifest.txt and 18_19_loading_compatibility
37
+ * Added devenv environment for Ruby 3.4 and Postgresql 17
38
+ * limit github CI to rubies 3.2,3.3 and 3.4
39
+ * changelog_uri to gemspec
40
+
41
+ ## 1.1.9 / 28.06.2025
42
+
43
+ * bulk_restore throws OdbaError when stack size > 1000
44
+
45
+ ## 1.1.8 / 10.03.2021
46
+
47
+ * Removed fixed dependency to pg (is optional like mysql2)
48
+
49
+ ## 1.1.7 / 20.01.2021
50
+
51
+ * Reworked some tests
52
+ * Updated to use Ruby 3.0.0
53
+ * Added github actions
54
+ * Updated to use ydbi 0.5.7
55
+
56
+ ## 1.1.6 / 23.01.2016
57
+
58
+ * Updated to use ydbi 0.5.6
59
+
60
+ ## 1.1.5 / 23.01.2016
61
+
62
+ * Remove unused parameter dict for update_fulltext_index
63
+
64
+ ## 1.1.4 / 13.12.2017
65
+
66
+ * Drop text search dictionaries/configuration before recreating
67
+ * Remove dictionary argument in fulltext search and index_definition
68
+
69
+ ## 1.1.3 / 12.12.2016
70
+
71
+ * Avoid errors by always specifying "IF NOT EXISTS" when creating tables and indices
72
+ * Add utility method get_server_version
73
+ * Removed misleading check in generate_dictionary
74
+
75
+ ## 1.1.2 / 10.05.2016
76
+
77
+ * requires now 'ydbi' and 'ydbd-pg'
78
+
79
+ ## 1.1.1 / 10.05.2016
80
+
81
+ * Made tests pass under Ruby 1.9.3, 2.x
82
+ * Updated to use minitest
83
+
84
+ ## 1.1.0 / 15.03.2013
85
+
86
+ * Update dict source file name for multi languages
87
+
88
+ ## 1.0.9 / 15.03.2013
89
+
90
+ * Update dictionary to be suitable for new tsearch2
91
+ - generate_dictionary API is changed.
92
+ - generate_dictionary needs dict source files(dict, affix, stop)
93
+ into /usr/share/postgresql/tsearch_data.
94
+
95
+ ## 1.0.8 / 09.01.2012
96
+
97
+ * Added exclusive control to update @accessed_by Hash variable in CacheEntry class using mutex (Patinfo-Invoice Error)
98
+
99
+ ## 1.0.7 / 27.12.2011
100
+
101
+ * Debugged Hash iteration error during cleaning @fetched and @prefetched objects
102
+
103
+ ## 1.0.6 / 23.12.2011
104
+
105
+ * Fix all the elements of odba_potentials and odba_exclude_vars to be Symbols for Ruby 1.9.3
106
+
107
+ ## 1.0.5 / 20.12.2011
108
+
109
+ * Added attr_accessor :odba_persistent so we can update doctor addresses on ch.oddb.org
110
+
111
+ ## 1.0.4 / 12.12.2011
112
+
113
+ * Fixed file lock process by using @file_lock flag variable to control it in application side
114
+
115
+ ## 1.0.3 / 09.12.2011
116
+
117
+ * Debugged ODBA::Cache#next_id
118
+
119
+ ## 1.0.2 / 09.12.2011
120
+
121
+ * Updated cache.rb persitatble.rb 18_19_loading_compatibility.rb to be compatible for both Ruby 1.8 and 1.9
122
+
123
+ ## 1.0.1 / 08.12.2011
124
+
125
+ * Added file lock exclusive control to create a new odba_id between processes.
126
+
127
+ ## 1.0.0 / 20.12.2010
128
+
129
+ * Add ODBA.cache.index_matches(index_name, substring)
130
+
131
+ * this new method returns all search-terms of a given index (identified by index_name) that start with substring.
data/README.md CHANGED
@@ -1,10 +1,23 @@
1
1
  # odba
2
2
 
3
+ ODBA is an unintrusive Object Cache system. It adresses the crosscutting
4
+ concern of object storage by disconnecting and serializing objects into
5
+ storage. All disconnected connections are replaced by instances of
6
+ ODBA::Stub, thus enabling transparent object-loading.
7
+
8
+
3
9
  * https://github.com/zdavatz/odba
4
10
 
5
11
  To see a graphical overview of the Library please see
6
12
 
7
- * https://raw.githubusercontent.com/ngiger/odba/master/odba.jpeg
13
+ * https://raw.githubusercontent.com/zdavatz/odba/master/odba.jpeg
14
+
15
+ ## ODBA supports
16
+
17
+ * transparent loading of connected objects
18
+ * index-vectors
19
+ * transactions
20
+ * transparently fetches Hash-Elements without loading the entire Hash
8
21
 
9
22
  ## DESCRIPTION:
10
23
 
@@ -15,6 +28,68 @@ To see a graphical overview of the Library please see
15
28
 
16
29
  * There may still be an sql bottleneck. Has to be investigated further.
17
30
  * You will need postgresql installed.
31
+ * The unit test test_clean__prefetched in test/test_cache.rb fails with Ruby 3.3/3.4 sometimes but not always
32
+ * Rework the unit tests to use a test database and less flexmock
33
+ * Rebase the library on the Sequel gem instead of ydbi/ydbd_pg
34
+
35
+ ## Example
36
+
37
+ You may find this code and some tests which is using this (example)[https://github.com/zdavatz/odba/blob/master/test/example.rb]
38
+
39
+ require "odba/connection_pool"
40
+
41
+ class User
42
+ attr_accessor :first_name, :last_name
43
+ include ODBA::Persistable
44
+ def initialize(first_name, last_name)
45
+ @first_name = first_name
46
+ @last_name = last_name
47
+ end
48
+
49
+ def to_s
50
+ "#{@first_name} #{@last_name}"
51
+ end
52
+ end
53
+
54
+ class Example
55
+ def self.db_setup
56
+ # connect default storage manager to a relational database on
57
+ # our localhost using port 5435 with a user odba_test and an empty password
58
+ ODBA.storage.dbi = ODBA::ConnectionPool.new("DBI:Pg:dbname=odba_test;host=127.0.0.1;port=5432", "odba_test", "")
59
+ ODBA.cache.setup
60
+ end
61
+
62
+ def self.show_last_added_user
63
+ res = ODBA.storage.dbi.select_all("Select count(*) from object;").first.first
64
+ odba_id = ODBA.storage.dbi.select_one("select odba_id from object order by odba_id desc limit 1;")
65
+ puts "show_last_added_user: We have #{res} objects. Highest odba_id is #{odba_id}"
66
+ first = ODBA.storage.dbi.select_one("select odba_id, name, prefetchable, extent, content from object order by odba_id desc limit 1;")
67
+ puts " DB-content is #{first}"
68
+ puts " Fetched object for odba_id #{odba_id} is #{ODBA.cache.fetch(odba_id.first)}"
69
+ end
70
+ end
71
+
72
+ Example.db_setup
73
+ composer = User.new("Ludwig", "Van Beethoven")
74
+ composer.odba_store
75
+ Example.show_last_added_user
76
+ painter = User.new("Vincent", "Van Gogh")
77
+ painter.odba_store
78
+ scientist = User.new("Albert", "Einstein")
79
+ scientist.odba_store
80
+ Example.show_last_added_user
81
+
82
+ You will see something like
83
+
84
+ show_last_added_user: We have 2 objects. Highest odba_id is [2]
85
+ DB-content is [2, nil, false, "User", "04086f3a09557365720b3a104066697273745f6e616d6549220b4c7564776967063a0645543a0f406c6173745f6e616d6549221256616e2042656574686f76656e063b07543a15406f6462615f70657273697374656e74543a0d406f6462615f696469073a14406f6462615f6f6273657276657273303a13406f6462615f707265666574636830"]
86
+ Fetched object for odba_id [2] is Ludwig Van Beethoven
87
+ show_last_added_user: We have 4 objects. Highest odba_id is [4]
88
+ DB-content is [4, nil, false, "User", "04086f3a09557365720b3a104066697273745f6e616d6549220b416c62657274063a0645543a0f406c6173745f6e616d6549220d45696e737465696e063b07543a15406f6462615f70657273697374656e74543a0d406f6462615f696469093a14406f6462615f6f6273657276657273303a13406f6462615f707265666574636830"]
89
+ Fetched object for odba_id [4] is Albert Einstein
90
+
91
+
92
+ This example is run on each push to github via the (github action)[https://github.com/zdavatz/odba/blob/master/.github/workflows/devenv.yml]. It is based on (devenv.sh)[https://devenv.sh/], which ensures reproducability.
18
93
 
19
94
  ## INSTALL:
20
95
 
@@ -25,6 +100,7 @@ To see a graphical overview of the Library please see
25
100
  * Masamoi Hatakeyama
26
101
  * Zeno R.R. Davatz
27
102
  * Hannes Wyss (up to Version 1.0)
103
+ * Niklaus Giger (Porting to Ruby 2.x and 3.x, cleanup)
28
104
 
29
105
  ## LICENSE:
30
106
 
data/Rakefile CHANGED
@@ -1,25 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
  lib = File.expand_path('../lib', __FILE__)
4
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
4
  require 'odba/version'
6
5
  require "bundler/gem_tasks"
7
6
  require 'rake/testtask'
8
7
 
9
- # dependencies are now declared in odba.gemspec
10
-
11
- desc 'Offer a gem task like hoe'
12
- task :gem => :build do
13
- Rake::Task[:build].invoke
14
- end
15
-
16
- desc "Run tests"
17
- task :default => :test
18
-
19
- Rake::TestTask.new(:test) do |t|
20
- t.libs << "test"
21
- t.libs << "lib"
22
- t.test_files = FileList["test/**/test_*.rb"]
8
+ task default: "test"
9
+ Rake::TestTask.new(:test) do |task|
10
+ require_relative 'test/suite'
23
11
  end
24
12
 
25
13
 
data/devenv.lock ADDED
@@ -0,0 +1,171 @@
1
+ {
2
+ "nodes": {
3
+ "devenv": {
4
+ "locked": {
5
+ "dir": "src/modules",
6
+ "lastModified": 1736426010,
7
+ "owner": "cachix",
8
+ "repo": "devenv",
9
+ "rev": "1c384bc4be3ee571511fbbc6fdc94fe47d60f6cf",
10
+ "type": "github"
11
+ },
12
+ "original": {
13
+ "dir": "src/modules",
14
+ "owner": "cachix",
15
+ "repo": "devenv",
16
+ "type": "github"
17
+ }
18
+ },
19
+ "flake-compat": {
20
+ "flake": false,
21
+ "locked": {
22
+ "lastModified": 1733328505,
23
+ "owner": "edolstra",
24
+ "repo": "flake-compat",
25
+ "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
26
+ "type": "github"
27
+ },
28
+ "original": {
29
+ "owner": "edolstra",
30
+ "repo": "flake-compat",
31
+ "type": "github"
32
+ }
33
+ },
34
+ "flake-compat_2": {
35
+ "flake": false,
36
+ "locked": {
37
+ "lastModified": 1733328505,
38
+ "owner": "edolstra",
39
+ "repo": "flake-compat",
40
+ "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
41
+ "type": "github"
42
+ },
43
+ "original": {
44
+ "owner": "edolstra",
45
+ "repo": "flake-compat",
46
+ "type": "github"
47
+ }
48
+ },
49
+ "flake-utils": {
50
+ "inputs": {
51
+ "systems": "systems"
52
+ },
53
+ "locked": {
54
+ "lastModified": 1731533236,
55
+ "owner": "numtide",
56
+ "repo": "flake-utils",
57
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
58
+ "type": "github"
59
+ },
60
+ "original": {
61
+ "owner": "numtide",
62
+ "repo": "flake-utils",
63
+ "type": "github"
64
+ }
65
+ },
66
+ "git-hooks": {
67
+ "inputs": {
68
+ "flake-compat": "flake-compat",
69
+ "gitignore": "gitignore",
70
+ "nixpkgs": [
71
+ "nixpkgs"
72
+ ]
73
+ },
74
+ "locked": {
75
+ "lastModified": 1742649964,
76
+ "owner": "cachix",
77
+ "repo": "git-hooks.nix",
78
+ "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
79
+ "type": "github"
80
+ },
81
+ "original": {
82
+ "owner": "cachix",
83
+ "repo": "git-hooks.nix",
84
+ "type": "github"
85
+ }
86
+ },
87
+ "gitignore": {
88
+ "inputs": {
89
+ "nixpkgs": [
90
+ "git-hooks",
91
+ "nixpkgs"
92
+ ]
93
+ },
94
+ "locked": {
95
+ "lastModified": 1709087332,
96
+ "owner": "hercules-ci",
97
+ "repo": "gitignore.nix",
98
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
99
+ "type": "github"
100
+ },
101
+ "original": {
102
+ "owner": "hercules-ci",
103
+ "repo": "gitignore.nix",
104
+ "type": "github"
105
+ }
106
+ },
107
+ "nixpkgs": {
108
+ "locked": {
109
+ "lastModified": 1736200483,
110
+ "owner": "NixOS",
111
+ "repo": "nixpkgs",
112
+ "rev": "3f0a8ac25fb674611b98089ca3a5dd6480175751",
113
+ "type": "github"
114
+ },
115
+ "original": {
116
+ "owner": "NixOS",
117
+ "ref": "nixos-24.11",
118
+ "repo": "nixpkgs",
119
+ "type": "github"
120
+ }
121
+ },
122
+ "nixpkgs-ruby": {
123
+ "inputs": {
124
+ "flake-compat": "flake-compat_2",
125
+ "flake-utils": "flake-utils",
126
+ "nixpkgs": [
127
+ "nixpkgs"
128
+ ]
129
+ },
130
+ "locked": {
131
+ "lastModified": 1735192621,
132
+ "owner": "bobvanderlinden",
133
+ "repo": "nixpkgs-ruby",
134
+ "rev": "602c528c8228f231f912c6d117703a1700464202",
135
+ "type": "github"
136
+ },
137
+ "original": {
138
+ "owner": "bobvanderlinden",
139
+ "repo": "nixpkgs-ruby",
140
+ "type": "github"
141
+ }
142
+ },
143
+ "root": {
144
+ "inputs": {
145
+ "devenv": "devenv",
146
+ "git-hooks": "git-hooks",
147
+ "nixpkgs": "nixpkgs",
148
+ "nixpkgs-ruby": "nixpkgs-ruby",
149
+ "pre-commit-hooks": [
150
+ "git-hooks"
151
+ ]
152
+ }
153
+ },
154
+ "systems": {
155
+ "locked": {
156
+ "lastModified": 1681028828,
157
+ "owner": "nix-systems",
158
+ "repo": "default",
159
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
160
+ "type": "github"
161
+ },
162
+ "original": {
163
+ "owner": "nix-systems",
164
+ "repo": "default",
165
+ "type": "github"
166
+ }
167
+ }
168
+ },
169
+ "root": "root",
170
+ "version": 7
171
+ }
data/devenv.nix ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ inputs,
3
+ pkgs,
4
+ config,
5
+ lib,
6
+ ...
7
+ }:
8
+ {
9
+
10
+ # https://devenv.sh/basics/
11
+ env.GREET = "devenv";
12
+
13
+ # https://devenv.sh/packages/
14
+ packages = [
15
+ pkgs.git
16
+ pkgs.libyaml
17
+ pkgs.nixfmt-rfc-style
18
+ ];
19
+
20
+ enterShell = ''
21
+ echo This is the devenv shell for odba_test
22
+ git --version
23
+ ruby --version
24
+ psql --version
25
+ bundle install
26
+ '';
27
+ services.postgres = {
28
+ enable = true;
29
+ package = pkgs.postgresql_17;
30
+ listen_addresses = "0.0.0.0";
31
+ port = 5432;
32
+
33
+ initialDatabases = [
34
+ { name = "odba_test"; }
35
+ ];
36
+
37
+ initdbArgs = [
38
+ "--locale=C"
39
+ "--encoding=UTF8"
40
+ ];
41
+
42
+ initialScript = ''
43
+ create role odba_test superuser login password null;
44
+ '';
45
+ };
46
+ languages.ruby.enable = true;
47
+ languages.ruby.version = "3.4";
48
+ # See full reference at https://devenv.sh/reference/options/
49
+ enterTest = ''
50
+ # No `devenv up` here: `devenv test` already starts the processes before
51
+ # running enterTest, so starting them again aborts the whole run with
52
+ # "Processes already running with PID ...".
53
+ #
54
+ # Those processes come up in parallel with this script. On slower runners
55
+ # initdb is still creating template0 when we arrive and the first connect
56
+ # is refused, so wait for postgres to accept connections. The bare
57
+ # pg_isready afterwards turns "never came up" into a clear error rather
58
+ # than a confusing PG::ConnectionBad from the test.
59
+ for _ in $(seq 1 60); do
60
+ if pg_isready --host 127.0.0.1 --port 5432 > /dev/null 2>&1; then break; fi
61
+ sleep 1
62
+ done
63
+ pg_isready --host 127.0.0.1 --port 5432
64
+ bundle exec ruby test/example.rb
65
+ '';
66
+ }
data/devenv.yaml ADDED
@@ -0,0 +1,16 @@
1
+ inputs:
2
+ nixpkgs:
3
+ url: github:NixOS/nixpkgs/nixos-24.11
4
+ # Declared explicitly because devenv no longer injects it implicitly: its
5
+ # git-hooks module throws "git-hooks or pre-commit-hooks input required".
6
+ # This mirrors what devenv.lock already records, so the lock stays valid.
7
+ git-hooks:
8
+ url: github:cachix/git-hooks.nix
9
+ inputs:
10
+ nixpkgs:
11
+ follows: nixpkgs
12
+ nixpkgs-ruby:
13
+ url: github:bobvanderlinden/nixpkgs-ruby
14
+ inputs:
15
+ nixpkgs:
16
+ follows: nixpkgs