statesman 7.4.0 → 12.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/tests.yml +112 -0
  4. data/.gitignore +65 -15
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +14 -1
  7. data/.rubocop_todo.yml +37 -28
  8. data/.ruby-version +1 -0
  9. data/CHANGELOG.md +262 -41
  10. data/CONTRIBUTING.md +23 -4
  11. data/Gemfile +4 -6
  12. data/README.md +243 -43
  13. data/docs/COMPATIBILITY.md +2 -2
  14. data/lib/generators/statesman/active_record_transition_generator.rb +1 -1
  15. data/lib/generators/statesman/generator_helpers.rb +12 -4
  16. data/lib/statesman/adapters/active_record.rb +84 -55
  17. data/lib/statesman/adapters/active_record_queries.rb +19 -7
  18. data/lib/statesman/adapters/active_record_transition.rb +5 -1
  19. data/lib/statesman/adapters/memory.rb +5 -1
  20. data/lib/statesman/adapters/type_safe_active_record_queries.rb +21 -0
  21. data/lib/statesman/callback.rb +2 -2
  22. data/lib/statesman/config.rb +3 -10
  23. data/lib/statesman/exceptions.rb +13 -7
  24. data/lib/statesman/guard.rb +1 -1
  25. data/lib/statesman/machine.rb +68 -0
  26. data/lib/statesman/version.rb +1 -1
  27. data/lib/statesman.rb +5 -5
  28. data/lib/tasks/statesman.rake +5 -5
  29. data/spec/generators/statesman/active_record_transition_generator_spec.rb +7 -1
  30. data/spec/generators/statesman/migration_generator_spec.rb +5 -1
  31. data/spec/spec_helper.rb +44 -7
  32. data/spec/statesman/adapters/active_record_queries_spec.rb +34 -12
  33. data/spec/statesman/adapters/active_record_spec.rb +176 -51
  34. data/spec/statesman/adapters/active_record_transition_spec.rb +5 -2
  35. data/spec/statesman/adapters/memory_spec.rb +0 -1
  36. data/spec/statesman/adapters/memory_transition_spec.rb +0 -1
  37. data/spec/statesman/adapters/shared_examples.rb +3 -4
  38. data/spec/statesman/adapters/type_safe_active_record_queries_spec.rb +206 -0
  39. data/spec/statesman/callback_spec.rb +0 -2
  40. data/spec/statesman/config_spec.rb +0 -2
  41. data/spec/statesman/exceptions_spec.rb +17 -4
  42. data/spec/statesman/guard_spec.rb +0 -2
  43. data/spec/statesman/machine_spec.rb +252 -15
  44. data/spec/statesman/utils_spec.rb +0 -2
  45. data/spec/support/active_record.rb +156 -24
  46. data/spec/support/exactly_query_databases.rb +35 -0
  47. data/statesman.gemspec +9 -10
  48. metadata +32 -59
  49. data/.circleci/config.yml +0 -187
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0dbcc9fe3c29e715be585f2ddae96bdea9b80ca104daf00ee3378feab681b8e
4
- data.tar.gz: c5824ece991650b8e6e979a9899dbdabc38b18209a79260f2aa9e9f4fda67da2
3
+ metadata.gz: d49f534086023febd344f7eb73b162903a28e3fd77ee430856d42242aafda37c
4
+ data.tar.gz: aba9670be235de98143f0a2ae0d15b9b7b32c8a9699901049e5cd9d931e29981
5
5
  SHA512:
6
- metadata.gz: 98fe2966e48e912b33f1c6d842aa6090782dd32be726532d8178377ffb0f1a551ee3d83eee291de0723c756eb0b1bda65dae73d695a47f8b6bd38106b127615f
7
- data.tar.gz: 6be77a7114e2c3d59e76cfa71de583213ead8a171c5039941698c1e4b0b28b68500acba91d498fb488d33d0e31b3274fa5e373ce81a55f9f70e8e229132de1cf
6
+ metadata.gz: d68959bd95e90bd0a986de5dd7197d21ac5535a5500d5d528b599fd07d26611125ce7e926f33efb5140f2ecbffa1c78dbb66e6d5f2209eeabe95ee49a4a862f8
7
+ data.tar.gz: 449e98a18f512eaff9a1ea500f9415b016bc8e775f7e1b1a7b9ffc393038112b3689ff4e7d364cbff9be6d23e3c4768d373dda3df7339249b53aa7a9d2e33136
@@ -0,0 +1,7 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: "daily"
@@ -0,0 +1,112 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - "master"
7
+ pull_request:
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ rubocop:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ bundler-cache: true
21
+ - run: bundle exec rubocop --extra-details --display-style-guide --parallel --force-exclusion
22
+
23
+ postgres:
24
+ strategy:
25
+ fail-fast: false
26
+ matrix:
27
+ ruby-version: ["3.0", "3.1", "3.2", "3.3"]
28
+ rails-version:
29
+ - "6.1.7.6"
30
+ - "7.0.8"
31
+ - "7.1.1"
32
+ - "main"
33
+ postgres-version: ["12", "13", "14", "15", "16"]
34
+ exclude:
35
+ - ruby-version: "3.2"
36
+ rails-version: "6.1.7.6"
37
+ - ruby-version: "3.3"
38
+ rails-version: "6.1.7.6"
39
+ runs-on: ubuntu-latest
40
+ services:
41
+ postgres:
42
+ image: postgres:${{ matrix.postgres-version }}
43
+ env:
44
+ POSTGRES_USER: postgres
45
+ POSTGRES_DB: statesman_test
46
+ POSTGRES_PASSWORD: statesman
47
+ ports:
48
+ - 5432:5432
49
+ options: >-
50
+ --health-cmd pg_isready
51
+ --health-interval 10s
52
+ --health-timeout 5s
53
+ --health-retries 10
54
+ env:
55
+ DATABASE_URL: postgres://postgres:statesman@localhost/statesman_test
56
+ DATABASE_DEPENDENCY_PORT: "5432"
57
+ steps:
58
+ - uses: actions/checkout@v3
59
+ - name: Set up Ruby
60
+ uses: ruby/setup-ruby@v1
61
+ with:
62
+ bundler-cache: true
63
+ ruby-version: "${{ matrix.ruby-version }}"
64
+ - name: Run specs
65
+ run: |
66
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
67
+
68
+ mysql:
69
+ strategy:
70
+ fail-fast: false
71
+ matrix:
72
+ ruby-version: ["3.0", "3.1", "3.2", "3.3"]
73
+ rails-version:
74
+ - "6.1.7.6"
75
+ - "7.0.8"
76
+ - "7.1.1"
77
+ - "main"
78
+ mysql-version: ["8.0", "8.2"]
79
+ exclude:
80
+ - ruby-version: "3.2"
81
+ rails-version: "6.1.7.6"
82
+ - ruby-version: "3.3"
83
+ rails-version: "6.1.7.6"
84
+ runs-on: ubuntu-latest
85
+ services:
86
+ mysql:
87
+ image: mysql:${{ matrix.mysql-version }}
88
+ env:
89
+ MYSQL_ROOT_PASSWORD: password
90
+ MYSQL_USER: foobar
91
+ MYSQL_PASSWORD: password
92
+ MYSQL_DATABASE: statesman_test
93
+ ports:
94
+ - "3306:3306"
95
+ options: >-
96
+ --health-cmd "mysqladmin ping"
97
+ --health-interval 10s
98
+ --health-timeout 5s
99
+ --health-retries 5
100
+ env:
101
+ DATABASE_URL: mysql2://foobar:password@127.0.0.1/statesman_test
102
+ DATABASE_DEPENDENCY_PORT: "3306"
103
+ steps:
104
+ - uses: actions/checkout@v3
105
+ - name: Set up Ruby
106
+ uses: ruby/setup-ruby@v1
107
+ with:
108
+ bundler-cache: true
109
+ ruby-version: "${{ matrix.ruby-version }}"
110
+ - name: Run specs
111
+ run: |
112
+ 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 @@
1
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -4,4 +4,17 @@ inherit_gem:
4
4
  gc_ruboconfig: rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.4
7
+ TargetRubyVersion: 3.0
8
+ NewCops: enable
9
+
10
+ Metrics/AbcSize:
11
+ Max: 60
12
+
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 10
15
+
16
+ Metrics/PerceivedComplexity:
17
+ Max: 11
18
+
19
+ Gemspec/DevelopmentDependencies:
20
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,38 +1,42 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-08-17 15:19:58 +0100 using RuboCop version 0.61.1.
3
+ # on 2021-08-09 15:32:40 UTC using RuboCop version 1.18.4.
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
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
9
12
  Gemspec/RequiredRubyVersion:
10
- Enabled: false # We want to allow Ruby 2.2 even though we don't test on it
13
+ Exclude:
14
+ - 'statesman.gemspec'
15
+
16
+ # Offense count: 1
17
+ Lint/MissingSuper:
18
+ Exclude:
19
+ - 'lib/statesman/adapters/active_record_queries.rb'
11
20
 
12
21
  # Offense count: 5
22
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
13
23
  Metrics/AbcSize:
14
- Max: 18
24
+ Max: 20
25
+
26
+ # Offense count: 1
27
+ # Configuration parameters: IgnoredMethods.
28
+ Metrics/CyclomaticComplexity:
29
+ Max: 8
15
30
 
16
- # Offense count: 4
17
- # Configuration parameters: CountComments, ExcludedMethods.
31
+ # Offense count: 3
32
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
18
33
  Metrics/MethodLength:
19
34
  Max: 14
20
35
 
21
- # Offense count: 2
22
- # Cop supports --auto-correct.
23
- # Configuration parameters: SkipBlocks, EnforcedStyle.
24
- # SupportedStyles: described_class, explicit
25
- RSpec/DescribedClass:
26
- Exclude:
27
- - 'spec/statesman/adapters/active_record_queries_spec.rb'
28
-
29
- # Offense count: 7
30
- # Configuration parameters: Max.
36
+ # Offense count: 11
37
+ # Configuration parameters: CountAsOne.
31
38
  RSpec/ExampleLength:
32
- Exclude:
33
- - 'spec/statesman/adapters/active_record_spec.rb'
34
- - 'spec/statesman/adapters/shared_examples.rb'
35
- - 'spec/statesman/machine_spec.rb'
39
+ Max: 14
36
40
 
37
41
  # Offense count: 7
38
42
  RSpec/ExpectInHook:
@@ -40,11 +44,12 @@ RSpec/ExpectInHook:
40
44
  - 'spec/statesman/adapters/active_record_spec.rb'
41
45
  - 'spec/statesman/machine_spec.rb'
42
46
 
43
- # Offense count: 3
44
- RSpec/ImplicitBlockExpectation:
47
+ # Offense count: 1
48
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
49
+ # Include: **/*_spec*rb*, **/spec/**/*
50
+ RSpec/FilePath:
45
51
  Exclude:
46
- - 'spec/statesman/adapters/active_record_spec.rb'
47
- - 'spec/statesman/adapters/shared_examples.rb'
52
+ - 'spec/statesman/exceptions_spec.rb'
48
53
 
49
54
  # Offense count: 1
50
55
  # Configuration parameters: AssignmentOnly.
@@ -75,23 +80,27 @@ RSpec/MessageSpies:
75
80
  Exclude:
76
81
  - 'spec/statesman/callback_spec.rb'
77
82
 
78
- # Offense count: 9
79
- # Configuration parameters: AggregateFailuresByDefault.
83
+ # Offense count: 14
80
84
  RSpec/MultipleExpectations:
81
85
  Max: 3
82
86
 
83
- # Offense count: 50
87
+ # Offense count: 49
84
88
  RSpec/NestedGroups:
85
89
  Max: 6
86
90
 
87
- # Offense count: 16
91
+ # Offense count: 2
92
+ RSpec/RepeatedExampleGroupBody:
93
+ Exclude:
94
+ - 'spec/statesman/exceptions_spec.rb'
95
+
96
+ # Offense count: 12
88
97
  RSpec/ScatteredSetup:
89
98
  Exclude:
90
99
  - 'spec/statesman/adapters/active_record_spec.rb'
91
100
  - 'spec/statesman/adapters/shared_examples.rb'
92
101
  - 'spec/statesman/machine_spec.rb'
93
102
 
94
- # Offense count: 8
103
+ # Offense count: 7
95
104
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
96
105
  RSpec/VerifiedDoubles:
97
106
  Exclude:
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0