statesman 9.0.0 → 13.0.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +31 -0
  3. data/.devcontainer/docker-compose.yml +39 -0
  4. data/.github/workflows/tests.yml +130 -0
  5. data/.gitignore +65 -15
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +11 -1
  8. data/.rubocop_todo.yml +23 -38
  9. data/.ruby-version +1 -1
  10. data/CHANGELOG.md +229 -43
  11. data/CONTRIBUTING.md +14 -13
  12. data/Gemfile +18 -3
  13. data/README.md +203 -74
  14. data/docs/COMPATIBILITY.md +3 -3
  15. data/lib/generators/statesman/active_record_transition_generator.rb +1 -1
  16. data/lib/generators/statesman/generator_helpers.rb +2 -2
  17. data/lib/statesman/adapters/active_record.rb +69 -52
  18. data/lib/statesman/adapters/active_record_queries.rb +15 -7
  19. data/lib/statesman/adapters/active_record_transition.rb +5 -1
  20. data/lib/statesman/adapters/memory.rb +1 -1
  21. data/lib/statesman/adapters/type_safe_active_record_queries.rb +21 -0
  22. data/lib/statesman/callback.rb +2 -2
  23. data/lib/statesman/config.rb +3 -10
  24. data/lib/statesman/exceptions.rb +9 -7
  25. data/lib/statesman/guard.rb +1 -1
  26. data/lib/statesman/machine.rb +60 -0
  27. data/lib/statesman/version.rb +1 -1
  28. data/lib/statesman.rb +5 -5
  29. data/lib/tasks/statesman.rake +5 -5
  30. data/spec/generators/statesman/active_record_transition_generator_spec.rb +7 -1
  31. data/spec/generators/statesman/migration_generator_spec.rb +5 -1
  32. data/spec/spec_helper.rb +44 -7
  33. data/spec/statesman/adapters/active_record_queries_spec.rb +8 -10
  34. data/spec/statesman/adapters/active_record_spec.rb +144 -55
  35. data/spec/statesman/adapters/active_record_transition_spec.rb +5 -2
  36. data/spec/statesman/adapters/memory_spec.rb +0 -1
  37. data/spec/statesman/adapters/memory_transition_spec.rb +0 -1
  38. data/spec/statesman/adapters/shared_examples.rb +6 -7
  39. data/spec/statesman/adapters/type_safe_active_record_queries_spec.rb +206 -0
  40. data/spec/statesman/callback_spec.rb +0 -2
  41. data/spec/statesman/config_spec.rb +0 -2
  42. data/spec/statesman/exceptions_spec.rb +8 -4
  43. data/spec/statesman/guard_spec.rb +0 -2
  44. data/spec/statesman/machine_spec.rb +231 -19
  45. data/spec/statesman/utils_spec.rb +0 -2
  46. data/spec/support/active_record.rb +156 -29
  47. data/spec/support/exactly_query_databases.rb +35 -0
  48. data/statesman.gemspec +2 -17
  49. metadata +14 -238
  50. data/.circleci/config.yml +0 -127
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33b89c9b5c5c0a2e31706aedd4861e3c8967d82ec50a1571715d0b2029ed14d2
4
- data.tar.gz: 8b201ea428387579869649c7739b393a4beaf6fb2b27070cd54202d7260fd6b4
3
+ metadata.gz: b15bf5cd57e2049db1ae4a0e93f41b16528c8a73c5741cf6337ec280f6ed1041
4
+ data.tar.gz: 28fba6b8a3304b97fb97a56d145243b5da73f79057fc05449dd3c48a6ea76f72
5
5
  SHA512:
6
- metadata.gz: 0c29e6cf1d191c99d4867f5461ee859241873a00f7ee71730bed266a0e0ee07180acb16ff879f275cf789a33a7c67de73d5eafe04f5981b24ff1bb05ad876cab
7
- data.tar.gz: 108e0c8b7c56cbac445e8c99708bd57b830325be91a40827a87ed51773c81165971cdf76ea446bdf6eb1b2fd19afe7accd6fba0b885824a30998212aa0492d85
6
+ metadata.gz: 5df7c20cbbc737fc8527d959ad8d894cc0e5fece227099287dc1a96d72cbc62000d5d87b854f4a8483b2ee58c726154d9d50ca7568be27fc4126afe5a94818e5
7
+ data.tar.gz: 29c4efb1b93e7057ba343b8c4894978e3d9660a53043755f8d26e6378fa804085cd83e8d81203ab7f81a2cbcdd89bab5126042a113d9bb0ca376cb5967b65ba3
@@ -0,0 +1,31 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "dockerComposeFile": "docker-compose.yml",
6
+ "service": "ruby",
7
+ "workspaceFolder": "/workspace",
8
+ // Environment variables for database connections
9
+ "containerEnv": {
10
+ "POSTGRES_URL": "postgresql://postgres:password@postgres:5432/statesman_dev",
11
+ "MYSQL_URL": "mysql2://root:password@mysql:3306/statesman_dev",
12
+ "PGHOST": "postgres",
13
+ "PGPORT": "5432",
14
+ "PGDATABASE": "statesman_dev",
15
+ "PGUSER": "postgres",
16
+ "PGPASSWORD": "password",
17
+ "MYSQL_HOST": "mysql",
18
+ "MYSQL_PORT": "3306",
19
+ "MYSQL_DATABASE": "statesman_dev",
20
+ "MYSQL_USER": "root",
21
+ "MYSQL_PASSWORD": "password"
22
+ },
23
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
24
+ // "forwardPorts": [],
25
+ // Use 'postCreateCommand' to run commands after the container is created.
26
+ "postCreateCommand": "sudo apt-get update && sudo apt-get install -y postgresql-client default-mysql-client && sudo chown -R vscode:vscode /usr/local/rvm/gems/default && bundle install",
27
+ // Configure tool-specific properties.
28
+ // "customizations": {},
29
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
30
+ // "remoteUser": "root"
31
+ }
@@ -0,0 +1,39 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ ruby:
5
+ image: mcr.microsoft.com/devcontainers/ruby:1-3.4-bullseye
6
+ volumes:
7
+ - ..:/workspace:cached
8
+ - gem-cache:/usr/local/rvm/gems/default
9
+ command: sleep infinity
10
+ depends_on:
11
+ - postgres
12
+ - mysql
13
+
14
+ postgres:
15
+ image: postgres:15
16
+ restart: unless-stopped
17
+ environment:
18
+ POSTGRES_PASSWORD: password
19
+ POSTGRES_DB: statesman_dev
20
+ volumes:
21
+ - postgres-data:/var/lib/postgresql/data
22
+ expose:
23
+ - "5432"
24
+
25
+ mysql:
26
+ image: mysql:8.0
27
+ restart: unless-stopped
28
+ environment:
29
+ MYSQL_ROOT_PASSWORD: password
30
+ MYSQL_DATABASE: statesman_dev
31
+ volumes:
32
+ - mysql-data:/var/lib/mysql
33
+ expose:
34
+ - "3306"
35
+
36
+ volumes:
37
+ postgres-data:
38
+ mysql-data:
39
+ gem-cache:
@@ -0,0 +1,130 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ types: [opened, reopened, synchronize]
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ rubocop:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v5
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ bundler-cache: true
22
+ - run: bundle exec rubocop --extra-details --display-style-guide --parallel --force-exclusion
23
+
24
+ sqlite:
25
+ strategy:
26
+ fail-fast: false
27
+ matrix:
28
+ ruby-version: ["3.2", "3.3", "3.4", "3.5"]
29
+ rails-version:
30
+ - "7.1"
31
+ - "7.2"
32
+ - "8.0"
33
+ - "main"
34
+ runs-on: ubuntu-latest
35
+ env:
36
+ RAILS_VERSION: ${{ matrix.rails-version }}
37
+ steps:
38
+ - uses: actions/checkout@v5
39
+ - name: Set up Ruby
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ bundler-cache: true
43
+ ruby-version: "${{ matrix.ruby-version }}"
44
+ - name: Run specs
45
+ run: |
46
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
47
+
48
+ postgres:
49
+ strategy:
50
+ fail-fast: false
51
+ matrix:
52
+ ruby-version: ["3.2", "3.3", "3.4", "3.5"]
53
+ rails-version:
54
+ - "7.1"
55
+ - "7.2"
56
+ - "8.0"
57
+ - "main"
58
+ postgres-version: ["14", "15", "16", "17"]
59
+ runs-on: ubuntu-latest
60
+ services:
61
+ postgres:
62
+ image: postgres:${{ matrix.postgres-version }}
63
+ env:
64
+ POSTGRES_USER: postgres
65
+ POSTGRES_DB: statesman_test
66
+ POSTGRES_PASSWORD: statesman
67
+ ports:
68
+ - 5432:5432
69
+ options: >-
70
+ --health-cmd pg_isready
71
+ --health-interval 10s
72
+ --health-timeout 5s
73
+ --health-retries 10
74
+ env:
75
+ DATABASE_URL: postgres://postgres:statesman@localhost/statesman_test
76
+ DATABASE_DEPENDENCY_PORT: "5432"
77
+ RAILS_VERSION: ${{ matrix.rails-version }}
78
+ steps:
79
+ - uses: actions/checkout@v5
80
+ - name: Set up Ruby
81
+ uses: ruby/setup-ruby@v1
82
+ with:
83
+ bundler-cache: true
84
+ ruby-version: "${{ matrix.ruby-version }}"
85
+ - name: Run specs
86
+ run: |
87
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
88
+
89
+ mysql:
90
+ strategy:
91
+ fail-fast: false
92
+ matrix:
93
+ ruby-version: ["3.2", "3.3", "3.4", "3.5"]
94
+ rails-version:
95
+ - "7.1"
96
+ - "7.2"
97
+ - "8.0"
98
+ - "main"
99
+ mysql-version: ["8.0", "8.4", "9.4"]
100
+
101
+ runs-on: ubuntu-latest
102
+ services:
103
+ mysql:
104
+ image: mysql:${{ matrix.mysql-version }}
105
+ env:
106
+ MYSQL_ROOT_PASSWORD: password
107
+ MYSQL_USER: foobar
108
+ MYSQL_PASSWORD: password
109
+ MYSQL_DATABASE: statesman_test
110
+ ports:
111
+ - "3306:3306"
112
+ options: >-
113
+ --health-cmd "mysqladmin ping"
114
+ --health-interval 10s
115
+ --health-timeout 5s
116
+ --health-retries 5
117
+ env:
118
+ DATABASE_URL: mysql2://foobar:password@127.0.0.1/statesman_test
119
+ DATABASE_DEPENDENCY_PORT: "3306"
120
+ RAILS_VERSION: ${{ matrix.rails-version }}
121
+ steps:
122
+ - uses: actions/checkout@v5
123
+ - name: Set up Ruby
124
+ uses: ruby/setup-ruby@v1
125
+ with:
126
+ bundler-cache: true
127
+ ruby-version: "${{ matrix.ruby-version }}"
128
+ - name: Run specs
129
+ run: |
130
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
data/.gitignore CHANGED
@@ -1,18 +1,68 @@
1
1
  *.gem
2
2
  *.rbc
3
- .bundle
4
- .config
5
- .rspec
6
- .yardoc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
7
48
  Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
57
+
58
+ # VSCode
59
+ .vscode
60
+
61
+ # Local History for Visual Studio Code
62
+ .history/
63
+
64
+ # Built Visual Studio Code Extensions
65
+ *.vsix
66
+
67
+ # JetBrains
68
+ .idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format progress
data/.rubocop.yml CHANGED
@@ -4,4 +4,14 @@ inherit_gem:
4
4
  gc_ruboconfig: rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 3.0
7
+ TargetRubyVersion: 3.2
8
+ NewCops: enable
9
+
10
+ Metrics/AbcSize:
11
+ Max: 60
12
+
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 10
15
+
16
+ Metrics/PerceivedComplexity:
17
+ Max: 11
data/.rubocop_todo.yml CHANGED
@@ -1,56 +1,47 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-08-09 15:32:40 UTC using RuboCop version 1.18.4.
3
+ # on 2025-08-29 17:37:05 UTC using RuboCop version 1.80.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- # Configuration parameters: Include.
11
- # Include: **/*.gemspec
12
- Gemspec/RequiredRubyVersion:
13
- Exclude:
14
- - 'statesman.gemspec'
15
-
16
- # Offense count: 1
10
+ # Configuration parameters: AllowedParentClasses.
17
11
  Lint/MissingSuper:
18
12
  Exclude:
19
13
  - 'lib/statesman/adapters/active_record_queries.rb'
20
14
 
21
- # Offense count: 5
22
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
23
- Metrics/AbcSize:
24
- Max: 20
15
+ # Offense count: 2
16
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
17
+ # AllowedMethods: call
18
+ # WaywardPredicates: nonzero?
19
+ Naming/PredicateMethod:
20
+ Exclude:
21
+ - 'lib/statesman/callback.rb'
25
22
 
26
23
  # Offense count: 1
27
- # Configuration parameters: IgnoredMethods.
28
- Metrics/CyclomaticComplexity:
29
- Max: 8
30
-
31
- # Offense count: 3
32
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
33
- Metrics/MethodLength:
34
- Max: 14
24
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
25
+ # NamePrefix: is_, has_, have_, does_
26
+ # ForbiddenPrefixes: is_, has_, have_, does_
27
+ # AllowedMethods: is_a?
28
+ # MethodDefinitionMacros: define_method, define_singleton_method
29
+ Naming/PredicatePrefix:
30
+ Exclude:
31
+ - 'spec/**/*'
32
+ - 'lib/statesman/adapters/active_record.rb'
35
33
 
36
- # Offense count: 11
34
+ # Offense count: 15
37
35
  # Configuration parameters: CountAsOne.
38
36
  RSpec/ExampleLength:
39
37
  Max: 14
40
38
 
41
- # Offense count: 7
39
+ # Offense count: 5
42
40
  RSpec/ExpectInHook:
43
41
  Exclude:
44
42
  - 'spec/statesman/adapters/active_record_spec.rb'
45
43
  - 'spec/statesman/machine_spec.rb'
46
44
 
47
- # Offense count: 1
48
- # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
49
- # Include: **/*_spec*rb*, **/spec/**/*
50
- RSpec/FilePath:
51
- Exclude:
52
- - 'spec/statesman/exceptions_spec.rb'
53
-
54
45
  # Offense count: 1
55
46
  # Configuration parameters: AssignmentOnly.
56
47
  RSpec/InstanceVariable:
@@ -80,11 +71,12 @@ RSpec/MessageSpies:
80
71
  Exclude:
81
72
  - 'spec/statesman/callback_spec.rb'
82
73
 
83
- # Offense count: 14
74
+ # Offense count: 20
84
75
  RSpec/MultipleExpectations:
85
76
  Max: 3
86
77
 
87
- # Offense count: 49
78
+ # Offense count: 64
79
+ # Configuration parameters: AllowedGroups.
88
80
  RSpec/NestedGroups:
89
81
  Max: 6
90
82
 
@@ -93,13 +85,6 @@ RSpec/RepeatedExampleGroupBody:
93
85
  Exclude:
94
86
  - 'spec/statesman/exceptions_spec.rb'
95
87
 
96
- # Offense count: 12
97
- RSpec/ScatteredSetup:
98
- Exclude:
99
- - 'spec/statesman/adapters/active_record_spec.rb'
100
- - 'spec/statesman/adapters/shared_examples.rb'
101
- - 'spec/statesman/machine_spec.rb'
102
-
103
88
  # Offense count: 7
104
89
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
105
90
  RSpec/VerifiedDoubles:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.4.5