schema_associations 1.2.7 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/prs.yml +134 -0
  3. data/.gitignore +1 -0
  4. data/.simplecov +20 -0
  5. data/Gemfile +3 -0
  6. data/README.md +37 -18
  7. data/Rakefile +2 -13
  8. data/gemfiles/Gemfile.base +1 -1
  9. data/gemfiles/activerecord-5.2/Gemfile.base +2 -1
  10. data/gemfiles/activerecord-5.2/Gemfile.mysql2 +2 -2
  11. data/gemfiles/activerecord-5.2/Gemfile.postgresql +2 -2
  12. data/gemfiles/activerecord-5.2/Gemfile.sqlite3 +3 -3
  13. data/gemfiles/activerecord-6.0/Gemfile.base +4 -0
  14. data/gemfiles/activerecord-6.0/Gemfile.mysql2 +10 -0
  15. data/gemfiles/activerecord-6.0/Gemfile.postgresql +10 -0
  16. data/gemfiles/{activerecord-4.2 → activerecord-6.0}/Gemfile.sqlite3 +3 -3
  17. data/lib/schema_associations/active_record/associations.rb +9 -9
  18. data/lib/schema_associations/version.rb +1 -1
  19. data/schema_associations.gemspec +21 -22
  20. data/schema_dev.yml +4 -7
  21. data/spec/association_spec.rb +8 -18
  22. data/spec/spec_helper.rb +1 -2
  23. metadata +46 -48
  24. data/.travis.yml +0 -31
  25. data/gemfiles/activerecord-4.2/Gemfile.base +0 -3
  26. data/gemfiles/activerecord-4.2/Gemfile.mysql2 +0 -10
  27. data/gemfiles/activerecord-4.2/Gemfile.postgresql +0 -10
  28. data/gemfiles/activerecord-5.0/Gemfile.base +0 -3
  29. data/gemfiles/activerecord-5.0/Gemfile.mysql2 +0 -10
  30. data/gemfiles/activerecord-5.0/Gemfile.postgresql +0 -10
  31. data/gemfiles/activerecord-5.0/Gemfile.sqlite3 +0 -10
  32. data/gemfiles/activerecord-5.1/Gemfile.base +0 -3
  33. data/gemfiles/activerecord-5.1/Gemfile.mysql2 +0 -10
  34. data/gemfiles/activerecord-5.1/Gemfile.postgresql +0 -10
  35. data/gemfiles/activerecord-5.1/Gemfile.sqlite3 +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44cb70a92c74e94032088d96228cf1622875c341c4e4f5b9d7563786dde6cf0d
4
- data.tar.gz: 2a8fa7848d6fc166fc648ed761e075a508b14ed9b31b4dd64364bb76ae221205
3
+ metadata.gz: 9ce1a98047254a00934a2a5ea83cae65bb088154a9c9125e0924e53c07ab6b77
4
+ data.tar.gz: 9305ad24ed3345de55d42a7a566b1f15cfa01d4e285c694ffd3750aa7feebce6
5
5
  SHA512:
6
- metadata.gz: 78104847107eef1060cbb84245730fe60e2c900f1416b969cfb9d3e2359db705d53a150f9e3435422cee7d67c7ae4cca4cfedf8fbdbe73f642c12a2da794a68a
7
- data.tar.gz: cbe12ce462e1faeb6db6f45fd0fc902a61348e65093ade4ca453943b855928a16cc5b67324fc3b8dc358e697ef4af3da5b69eb37d7a15f5d4fc586dd901da3cf
6
+ metadata.gz: 6e1e8b03ccce6cb04497ee2faec4816718a5b7b56803abcb04225e27d823d600d8a4af5e858433ba05551fb775395f36e9a187ba7f310740e0f9a06c5a7a9497
7
+ data.tar.gz: 75e7e05eb6989c2d680e1425d7a05f684a1d8033b63590c3f7ab9f1154a8b33c1c00500748aee123442e2f97fda16efc60d2819530bf3cd182eccf63591466bd
@@ -0,0 +1,134 @@
1
+ # This file was auto-generated by the schema_dev tool, based on the data in
2
+ # ./schema_dev.yml
3
+ # Please do not edit this file; any changes will be overwritten next time
4
+ # schema_dev gets run.
5
+ ---
6
+ name: CI PR Builds
7
+ 'on':
8
+ push:
9
+ branches:
10
+ - master
11
+ pull_request:
12
+ concurrency:
13
+ group: ci-${{ github.ref }}
14
+ cancel-in-progress: true
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby:
22
+ - '2.5'
23
+ - '2.7'
24
+ - '3.0'
25
+ activerecord:
26
+ - '5.2'
27
+ - '6.0'
28
+ db:
29
+ - mysql2
30
+ - sqlite3
31
+ - skip
32
+ dbversion:
33
+ - skip
34
+ exclude:
35
+ - ruby: '3.0'
36
+ activerecord: '5.2'
37
+ - db: skip
38
+ dbversion: skip
39
+ include:
40
+ - ruby: '2.5'
41
+ activerecord: '5.2'
42
+ db: postgresql
43
+ dbversion: '9.6'
44
+ - ruby: '2.5'
45
+ activerecord: '6.0'
46
+ db: postgresql
47
+ dbversion: '9.6'
48
+ - ruby: '2.7'
49
+ activerecord: '5.2'
50
+ db: postgresql
51
+ dbversion: '9.6'
52
+ - ruby: '2.7'
53
+ activerecord: '6.0'
54
+ db: postgresql
55
+ dbversion: '9.6'
56
+ - ruby: '3.0'
57
+ activerecord: '6.0'
58
+ db: postgresql
59
+ dbversion: '9.6'
60
+ env:
61
+ BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
62
+ MYSQL_DB_HOST: 127.0.0.1
63
+ MYSQL_DB_USER: root
64
+ MYSQL_DB_PASS: database
65
+ POSTGRESQL_DB_HOST: 127.0.0.1
66
+ POSTGRESQL_DB_USER: schema_plus_test
67
+ POSTGRESQL_DB_PASS: database
68
+ steps:
69
+ - uses: actions/checkout@v2
70
+ - name: Set up Ruby
71
+ uses: ruby/setup-ruby@v1
72
+ with:
73
+ ruby-version: "${{ matrix.ruby }}"
74
+ bundler-cache: true
75
+ - name: Run bundle update
76
+ run: bundle update
77
+ - name: Start Mysql
78
+ if: matrix.db == 'mysql2'
79
+ run: |
80
+ docker run --rm --detach \
81
+ -e MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASS \
82
+ -p 3306:3306 \
83
+ --health-cmd "mysqladmin ping --host=127.0.0.1 --password=$MYSQL_DB_PASS --silent" \
84
+ --health-interval 5s \
85
+ --health-timeout 5s \
86
+ --health-retries 5 \
87
+ --name database mysql:5.6
88
+ - name: Start Postgresql
89
+ if: matrix.db == 'postgresql'
90
+ run: |
91
+ docker run --rm --detach \
92
+ -e POSTGRES_USER=$POSTGRESQL_DB_USER \
93
+ -e POSTGRES_PASSWORD=$POSTGRESQL_DB_PASS \
94
+ -p 5432:5432 \
95
+ --health-cmd "pg_isready -q" \
96
+ --health-interval 5s \
97
+ --health-timeout 5s \
98
+ --health-retries 5 \
99
+ --name database postgres:${{ matrix.dbversion }}
100
+ - name: Wait for database to start
101
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
102
+ run: |
103
+ COUNT=0
104
+ ATTEMPTS=20
105
+ until [[ $COUNT -eq $ATTEMPTS ]]; do
106
+ [ "$(docker inspect -f {{.State.Health.Status}} database)" == "healthy" ] && break
107
+ echo $(( COUNT++ )) > /dev/null
108
+ sleep 2
109
+ done
110
+ - name: Create testing database
111
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
112
+ run: bundle exec rake create_ci_database
113
+ - name: Run tests
114
+ run: bundle exec rake spec
115
+ - name: Shutdown database
116
+ if: always() && (matrix.db == 'postgresql' || matrix.db == 'mysql2')
117
+ run: docker stop database
118
+ - name: Coveralls Parallel
119
+ if: "${{ !env.ACT }}"
120
+ uses: coverallsapp/github-action@master
121
+ with:
122
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
123
+ flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}-${{ matrix.db }}-${{ matrix.dbversion }}
124
+ parallel: true
125
+ finish:
126
+ needs: test
127
+ runs-on: ubuntu-latest
128
+ steps:
129
+ - name: Coveralls Finished
130
+ if: "${{ !env.ACT }}"
131
+ uses: coverallsapp/github-action@master
132
+ with:
133
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
134
+ parallel-finished: true
data/.gitignore CHANGED
@@ -25,3 +25,4 @@ tmp/
25
25
  Gemfile.lock
26
26
  gemfiles/*.lock
27
27
  gemfiles/**/*.lock
28
+ /.idea
data/.simplecov ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.configure do
4
+ enable_coverage :branch
5
+ add_filter '/spec/'
6
+
7
+ add_group 'Binaries', '/bin/'
8
+ add_group 'Libraries', '/lib/'
9
+
10
+ if ENV['CI']
11
+ require 'simplecov-lcov'
12
+
13
+ SimpleCov::Formatter::LcovFormatter.config do |c|
14
+ c.report_with_single_file = true
15
+ c.single_report_path = 'coverage/lcov.info'
16
+ end
17
+
18
+ formatter SimpleCov::Formatter::LcovFormatter
19
+ end
20
+ end
data/Gemfile CHANGED
@@ -1,2 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
  gemspec
3
+
4
+ gemfile_local = File.expand_path '../Gemfile.local', __FILE__
5
+ eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
data/README.md CHANGED
@@ -5,8 +5,8 @@ definitions simpler and more DRY, by automatically defining associations based
5
5
  on the database schema.
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/schema_associations.svg)](http://badge.fury.io/rb/schema_associations)
8
- [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_associations.svg)](http://travis-ci.org/SchemaPlus/schema_associations)
9
- [![Coverage Status](https://img.shields.io/coveralls/SchemaPlus/schema_associations.svg)](https://coveralls.io/r/SchemaPlus/schema_associations?branch=master)
8
+ [![Build Status](https://github.com/SchemaPlus/schema_associations/actions/workflows/pr.yml/badge.svg)](http://github.com/SchemaPlus/schema_associations/actions)
9
+ [![Coverage Status](https://coveralls.io/github/SchemaPlus/schema_associations/badge.svg)](https://coveralls.io/github/SchemaPlus/schema_associations)
10
10
 
11
11
 
12
12
  ## Overview
@@ -418,15 +418,17 @@ SchemaAssociations is tested on all combinations of:
418
418
 
419
419
  <!-- SCHEMA_DEV: MATRIX - begin -->
420
420
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
421
- * ruby **2.3.1** with activerecord **4.2**, using **mysql2**, **postgresql** or **sqlite3**
422
- * ruby **2.3.1** with activerecord **5.0**, using **mysql2**, **postgresql** or **sqlite3**
423
- * ruby **2.3.1** with activerecord **5.1**, using **mysql2**, **postgresql** or **sqlite3**
424
- * ruby **2.3.1** with activerecord **5.2**, using **mysql2**, **postgresql** or **sqlite3**
421
+ * ruby **2.5** with activerecord **5.2**, using **mysql2**, **postgresql:9.6** or **sqlite3**
422
+ * ruby **2.5** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
423
+ * ruby **2.7** with activerecord **5.2**, using **mysql2**, **postgresql:9.6** or **sqlite3**
424
+ * ruby **2.7** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
425
+ * ruby **3.0** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
425
426
 
426
427
  <!-- SCHEMA_DEV: MATRIX - end -->
427
428
 
428
429
  Notes:
429
430
 
431
+ * As for version 1.3.0, rails < 5.2 and ruby < 2.5 are no longer supported
430
432
  * As of version 1.2.3, rails < 4.1 and ruby < 2.1 are no longer supported
431
433
  * As of version 1.2.0, ruby 1.9.2 is no longer supported.
432
434
  * As of version 1.0.0, ruby 1.8.7 and rails < 3.2 are no longer supported.
@@ -441,20 +443,12 @@ or in a Gemfile
441
443
 
442
444
  gem "schema_associations"
443
445
 
444
- ## Testing
445
-
446
- SchemaAssociations is tested against the matrix of combinations. To run the full combo of
447
- tests, after you've forked & cloned:
448
-
449
- $ cd schema_associations
450
- $ schema_dev bundle install
451
- $ schema_dev rspec
446
+ ## Release notes:
452
447
 
453
- For more info, see [schema_dev](https://github.com/SchemaPlus/schema_dev)
448
+ ### 1.3.0
454
449
 
455
- Code coverage results will be in coverage/index.html -- it should be at 100% coverage.
456
-
457
- ## Release notes:
450
+ * drop AR < 5.2, add AR 6.0
451
+ * drop Ruby < 2.5, add Ruby 3.0
458
452
 
459
453
  ### 1.2.7
460
454
 
@@ -520,3 +514,28 @@ Code coverage results will be in coverage/index.html -- it should be at 100% cov
520
514
  ## License
521
515
 
522
516
  This gem is released under the MIT license.
517
+
518
+ ## Development & Testing
519
+
520
+ Are you interested in contributing to SchemaPlus::Views? Thanks! Please follow the standard protocol: fork, feature branch, develop, push, and issue pull request.
521
+
522
+ Some things to know about to help you develop and test:
523
+
524
+ <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - begin -->
525
+ <!-- These lines are auto-inserted from a schema_dev template -->
526
+ * **schema_dev**: SchemaAssociations uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
527
+ facilitate running rspec tests on the matrix of ruby, activerecord, and database
528
+ versions that the gem supports, both locally and on
529
+ [github actions](https://github.com/SchemaPlus/schema_associations/actions)
530
+
531
+ To to run rspec locally on the full matrix, do:
532
+
533
+ $ schema_dev bundle install
534
+ $ schema_dev rspec
535
+
536
+ You can also run on just one configuration at a time; For info, see `schema_dev --help` or the [schema_dev](https://github.com/SchemaPlus/schema_dev) README.
537
+
538
+ The matrix of configurations is specified in `schema_dev.yml` in
539
+ the project root.
540
+
541
+ <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
data/Rakefile CHANGED
@@ -1,20 +1,9 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
4
  require 'schema_dev/tasks'
8
5
 
9
-
10
6
  task :default => :spec
11
7
 
12
- require 'rdoc/task'
13
- Rake::RDocTask.new do |rdoc|
14
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
15
-
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = "schema_associations #{version}"
18
- rdoc.rdoc_files.include('README*')
19
- rdoc.rdoc_files.include('lib/**/*.rb')
20
- end
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:spec)
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gemspec :path => File.expand_path('..', __FILE__)
2
+ gemspec path: File.expand_path('..', __FILE__)
3
3
 
4
4
  File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
@@ -1,3 +1,4 @@
1
- eval File.read File.expand_path('../../Gemfile.base', __FILE__)
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
2
3
 
3
4
  gem "activerecord", ">= 5.2.0.beta0", "< 5.3"
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "mysql2"
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "pg"
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
10
+ end
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.0", "< 6.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
10
+ end
@@ -5,7 +5,7 @@ module SchemaAssociations
5
5
 
6
6
  module Relation
7
7
 
8
- def initialize(klass, *args)
8
+ def initialize(klass, *args, **kwargs)
9
9
  klass.send :_load_schema_associations_associations unless klass.nil?
10
10
  super
11
11
  end
@@ -71,12 +71,12 @@ module SchemaAssociations
71
71
  end
72
72
 
73
73
  %i[has_many has_one].each do |m|
74
- define_method(m) do |name, *args|
74
+ define_method(m) do |name, *args, **options|
75
75
  if @schema_associations_associations_loaded
76
- super name, *args
76
+ super name, *args, **options
77
77
  else
78
78
  @schema_associations_deferred_associations ||= []
79
- @schema_associations_deferred_associations.push({macro: m, name: name, args: args})
79
+ @schema_associations_deferred_associations.push({macro: m, name: name, args: args, options: options})
80
80
  end
81
81
  end
82
82
  end
@@ -109,7 +109,7 @@ module SchemaAssociations
109
109
 
110
110
  (@schema_associations_deferred_associations || []).each do |a|
111
111
  argstr = a[:args].inspect[1...-1] + ' # deferred association'
112
- _create_association(a[:macro], a[:name], argstr, *a[:args])
112
+ _create_association(a[:macro], a[:name], argstr, *a[:args], **a[:options])
113
113
  end
114
114
  if instance_variable_defined? :@schema_associations_deferred_associations
115
115
  remove_instance_variable :@schema_associations_deferred_associations
@@ -170,17 +170,17 @@ module SchemaAssociations
170
170
  end
171
171
  argstr += opts.inspect[1...-1]
172
172
  if (_filter_association(macro, name) && !_method_exists?(name))
173
- _create_association(macro, name, argstr, scope_block, opts.dup)
173
+ _create_association(macro, name, argstr, scope_block, **opts.dup)
174
174
  end
175
175
  end
176
176
 
177
- def _create_association(macro, name, argstr, *args)
177
+ def _create_association(macro, name, argstr, *args, **options)
178
178
  logger.debug "[schema_associations] #{self.name || self.from_table.classify}.#{macro} #{name.inspect}, #{argstr}"
179
- send macro, name, *args
179
+ send macro, name, *args, **options
180
180
  case
181
181
  when respond_to?(:subclasses) then subclasses
182
182
  end.each do |subclass|
183
- subclass.send :_create_association, macro, name, argstr, *args
183
+ subclass.send :_create_association, macro, name, argstr, *args, **options
184
184
  end
185
185
  end
186
186
 
@@ -1,3 +1,3 @@
1
1
  module SchemaAssociations
2
- VERSION = "1.2.7"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -2,30 +2,29 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "schema_associations/version"
4
4
 
5
- Gem::Specification.new do |s|
6
- s.name = "schema_associations"
7
- s.version = SchemaAssociations::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Ronen Barzel", "Michał Łomnicki"]
10
- s.email = ["ronen@barzel.org", "michal.lomnicki@gmail.com"]
11
- s.homepage = "https://github.com/SchemaPlus/schema_associations"
12
- s.summary = "ActiveRecord extension that automatically (DRY) creates associations based on the schema"
13
- s.description = "SchemaAssociations extends ActiveRecord to automatically create associations by inspecting the database schema. This is more more DRY than the standard behavior, for which in addition to specifying the foreign key in the migration, you must also specify complementary associations in two model files (e.g. a :belongs_to and a :has_many)."
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "schema_associations"
7
+ gem.version = SchemaAssociations::VERSION
8
+ gem.platform = Gem::Platform::RUBY
9
+ gem.authors = ["Ronen Barzel", "Michał Łomnicki"]
10
+ gem.email = ["ronen@barzel.org", "michal.lomnicki@gmail.com"]
11
+ gem.homepage = "https://github.com/SchemaPlus/schema_associations"
12
+ gem.summary = "ActiveRecord extension that automatically (DRY) creates associations based on the schema"
13
+ gem.description = "SchemaAssociations extends ActiveRecord to automatically create associations by inspecting the database schema. This is more more DRY than the standard behavior, for which in addition to specifying the foreign key in the migration, you must also specify complementary associations in two model files (e.g. a :belongs_to and a :has_many)."
14
14
 
15
- s.rubyforge_project = "schema_associations"
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ gem.require_paths = ["lib"]
16
19
 
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
20
+ gem.required_ruby_version = '>= 2.5'
21
21
 
22
- s.add_dependency("schema_plus_foreign_keys", "~> 0.1")
22
+ gem.add_dependency 'activerecord', '>= 5.2', '< 6.1'
23
+ gem.add_dependency 'schema_plus_foreign_keys', '~> 1.0.0'
24
+ gem.add_dependency 'valuable'
23
25
 
24
- s.add_development_dependency("schema_dev", "~> 3.6")
25
- s.add_development_dependency("rake")
26
- s.add_development_dependency("rdoc")
27
- s.add_development_dependency("rspec")
28
- s.add_development_dependency("simplecov")
29
- s.add_development_dependency("simplecov-gem-profile")
26
+ gem.add_development_dependency 'bundler'
27
+ gem.add_development_dependency 'rake', '~> 13.0'
28
+ gem.add_development_dependency 'rspec', '~> 3.0'
29
+ gem.add_development_dependency 'schema_dev', '~> 4.1'
30
30
  end
31
-
data/schema_dev.yml CHANGED
@@ -1,14 +1,11 @@
1
1
  ruby:
2
- - 2.3.1
2
+ - 2.5
3
+ - 2.7
4
+ - 3.0
3
5
  activerecord:
4
- - 4.2
5
- - 5.0
6
- - 5.1
7
6
  - 5.2
7
+ - 6.0
8
8
  db:
9
9
  - mysql2
10
10
  - postgresql
11
11
  - sqlite3
12
- notify:
13
- - toby@ovod-everett.org
14
- - ronen@barzel.org
@@ -7,8 +7,6 @@ describe ActiveRecord::Base do
7
7
  remove_all_models
8
8
  end
9
9
 
10
- let(:pk_type) { Gem::Requirement.new('< 5.1').satisfied_by?(::ActiveRecord.version) ? :integer : :bigint }
11
-
12
10
  context "in basic case" do
13
11
  before(:each) do
14
12
  create_tables(
@@ -359,11 +357,7 @@ describe ActiveRecord::Base do
359
357
  expect(reflection.options[:class_name]).to eq("Comment")
360
358
  expect(reflection.options[:foreign_key]).to eq("post_id")
361
359
  expect(reflection.options[:inverse_of]).to eq(:post)
362
- if ::ActiveRecord::VERSION::MAJOR.to_i < 4
363
- expect(reflection.options[:order]).to be_nil
364
- else
365
- expect(reflection.scope).to be_nil
366
- end
360
+ expect(reflection.scope).to be_nil
367
361
  end
368
362
  end
369
363
 
@@ -383,14 +377,10 @@ describe ActiveRecord::Base do
383
377
  expect(reflection.options[:class_name]).to eq("Comment")
384
378
  expect(reflection.options[:foreign_key]).to eq("post_id")
385
379
  expect(reflection.options[:inverse_of]).to eq(:post)
386
- if ::ActiveRecord::VERSION::MAJOR.to_i < 4
387
- expect(reflection.options[:order].to_s).to eq("position")
388
- else
389
- expect(reflection.scope).not_to be_nil
390
- scope_tester = Object.new
391
- expect(scope_tester).to receive(:order).with(:position)
392
- scope_tester.instance_exec(&reflection.scope)
393
- end
380
+ expect(reflection.scope).not_to be_nil
381
+ scope_tester = Object.new
382
+ expect(scope_tester).to receive(:order).with(:position)
383
+ scope_tester.instance_exec(&reflection.scope)
394
384
  end
395
385
  end
396
386
 
@@ -729,10 +719,10 @@ describe ActiveRecord::Base do
729
719
  ActiveRecord::Migration.drop_table table, force: :cascade
730
720
  end
731
721
  table_defs.each_slice(3) do |table_name, opts, columns_with_options|
732
- ActiveRecord::Migration.create_table table_name, opts do |t|
722
+ ActiveRecord::Migration.create_table table_name, **opts do |t|
733
723
  columns_with_options.each_pair do |column, options|
734
- coltype = options.delete(:coltype) || pk_type
735
- t.send coltype, column, options
724
+ coltype = options.delete(:coltype) || :bigint
725
+ t.send coltype, column, **options
736
726
  end
737
727
  end
738
728
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'simplecov'
2
- require 'simplecov-gem-profile'
3
- SimpleCov.start "gem"
2
+ SimpleCov.start
4
3
 
5
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
metadata CHANGED
@@ -1,52 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_associations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronen Barzel
8
8
  - Michał Łomnicki
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-19 00:00:00.000000000 Z
12
+ date: 2022-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: schema_plus_foreign_keys
15
+ name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0.1'
20
+ version: '5.2'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '6.1'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '5.2'
31
+ - - "<"
26
32
  - !ruby/object:Gem::Version
27
- version: '0.1'
33
+ version: '6.1'
28
34
  - !ruby/object:Gem::Dependency
29
- name: schema_dev
35
+ name: schema_plus_foreign_keys
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - "~>"
33
39
  - !ruby/object:Gem::Version
34
- version: '3.6'
35
- type: :development
40
+ version: 1.0.0
41
+ type: :runtime
36
42
  prerelease: false
37
43
  version_requirements: !ruby/object:Gem::Requirement
38
44
  requirements:
39
45
  - - "~>"
40
46
  - !ruby/object:Gem::Version
41
- version: '3.6'
47
+ version: 1.0.0
42
48
  - !ruby/object:Gem::Dependency
43
- name: rake
49
+ name: valuable
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
52
  - - ">="
47
53
  - !ruby/object:Gem::Version
48
54
  version: '0'
49
- type: :development
55
+ type: :runtime
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
52
58
  requirements:
@@ -54,7 +60,7 @@ dependencies:
54
60
  - !ruby/object:Gem::Version
55
61
  version: '0'
56
62
  - !ruby/object:Gem::Dependency
57
- name: rdoc
63
+ name: bundler
58
64
  requirement: !ruby/object:Gem::Requirement
59
65
  requirements:
60
66
  - - ">="
@@ -68,47 +74,47 @@ dependencies:
68
74
  - !ruby/object:Gem::Version
69
75
  version: '0'
70
76
  - !ruby/object:Gem::Dependency
71
- name: rspec
77
+ name: rake
72
78
  requirement: !ruby/object:Gem::Requirement
73
79
  requirements:
74
- - - ">="
80
+ - - "~>"
75
81
  - !ruby/object:Gem::Version
76
- version: '0'
82
+ version: '13.0'
77
83
  type: :development
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
80
86
  requirements:
81
- - - ">="
87
+ - - "~>"
82
88
  - !ruby/object:Gem::Version
83
- version: '0'
89
+ version: '13.0'
84
90
  - !ruby/object:Gem::Dependency
85
- name: simplecov
91
+ name: rspec
86
92
  requirement: !ruby/object:Gem::Requirement
87
93
  requirements:
88
- - - ">="
94
+ - - "~>"
89
95
  - !ruby/object:Gem::Version
90
- version: '0'
96
+ version: '3.0'
91
97
  type: :development
92
98
  prerelease: false
93
99
  version_requirements: !ruby/object:Gem::Requirement
94
100
  requirements:
95
- - - ">="
101
+ - - "~>"
96
102
  - !ruby/object:Gem::Version
97
- version: '0'
103
+ version: '3.0'
98
104
  - !ruby/object:Gem::Dependency
99
- name: simplecov-gem-profile
105
+ name: schema_dev
100
106
  requirement: !ruby/object:Gem::Requirement
101
107
  requirements:
102
- - - ">="
108
+ - - "~>"
103
109
  - !ruby/object:Gem::Version
104
- version: '0'
110
+ version: '4.1'
105
111
  type: :development
106
112
  prerelease: false
107
113
  version_requirements: !ruby/object:Gem::Requirement
108
114
  requirements:
109
- - - ">="
115
+ - - "~>"
110
116
  - !ruby/object:Gem::Version
111
- version: '0'
117
+ version: '4.1'
112
118
  description: SchemaAssociations extends ActiveRecord to automatically create associations
113
119
  by inspecting the database schema. This is more more DRY than the standard behavior,
114
120
  for which in addition to specifying the foreign key in the migration, you must also
@@ -121,29 +127,22 @@ executables: []
121
127
  extensions: []
122
128
  extra_rdoc_files: []
123
129
  files:
130
+ - ".github/workflows/prs.yml"
124
131
  - ".gitignore"
125
- - ".travis.yml"
132
+ - ".simplecov"
126
133
  - Gemfile
127
134
  - MIT-LICENSE
128
135
  - README.md
129
136
  - Rakefile
130
137
  - gemfiles/Gemfile.base
131
- - gemfiles/activerecord-4.2/Gemfile.base
132
- - gemfiles/activerecord-4.2/Gemfile.mysql2
133
- - gemfiles/activerecord-4.2/Gemfile.postgresql
134
- - gemfiles/activerecord-4.2/Gemfile.sqlite3
135
- - gemfiles/activerecord-5.0/Gemfile.base
136
- - gemfiles/activerecord-5.0/Gemfile.mysql2
137
- - gemfiles/activerecord-5.0/Gemfile.postgresql
138
- - gemfiles/activerecord-5.0/Gemfile.sqlite3
139
- - gemfiles/activerecord-5.1/Gemfile.base
140
- - gemfiles/activerecord-5.1/Gemfile.mysql2
141
- - gemfiles/activerecord-5.1/Gemfile.postgresql
142
- - gemfiles/activerecord-5.1/Gemfile.sqlite3
143
138
  - gemfiles/activerecord-5.2/Gemfile.base
144
139
  - gemfiles/activerecord-5.2/Gemfile.mysql2
145
140
  - gemfiles/activerecord-5.2/Gemfile.postgresql
146
141
  - gemfiles/activerecord-5.2/Gemfile.sqlite3
142
+ - gemfiles/activerecord-6.0/Gemfile.base
143
+ - gemfiles/activerecord-6.0/Gemfile.mysql2
144
+ - gemfiles/activerecord-6.0/Gemfile.postgresql
145
+ - gemfiles/activerecord-6.0/Gemfile.sqlite3
147
146
  - init.rb
148
147
  - lib/schema_associations.rb
149
148
  - lib/schema_associations/active_record/associations.rb
@@ -156,7 +155,7 @@ files:
156
155
  homepage: https://github.com/SchemaPlus/schema_associations
157
156
  licenses: []
158
157
  metadata: {}
159
- post_install_message:
158
+ post_install_message:
160
159
  rdoc_options: []
161
160
  require_paths:
162
161
  - lib
@@ -164,16 +163,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
163
  requirements:
165
164
  - - ">="
166
165
  - !ruby/object:Gem::Version
167
- version: '0'
166
+ version: '2.5'
168
167
  required_rubygems_version: !ruby/object:Gem::Requirement
169
168
  requirements:
170
169
  - - ">="
171
170
  - !ruby/object:Gem::Version
172
171
  version: '0'
173
172
  requirements: []
174
- rubyforge_project: schema_associations
175
- rubygems_version: 2.7.8
176
- signing_key:
173
+ rubygems_version: 3.0.8
174
+ signing_key:
177
175
  specification_version: 4
178
176
  summary: ActiveRecord extension that automatically (DRY) creates associations based
179
177
  on the schema
data/.travis.yml DELETED
@@ -1,31 +0,0 @@
1
- # This file was auto-generated by the schema_dev tool, based on the data in
2
- # ./schema_dev.yml
3
- # Please do not edit this file; any changes will be overwritten next time
4
- # schema_dev gets run.
5
- ---
6
- sudo: false
7
- rvm:
8
- - 2.3.1
9
- gemfile:
10
- - gemfiles/activerecord-4.2/Gemfile.mysql2
11
- - gemfiles/activerecord-4.2/Gemfile.postgresql
12
- - gemfiles/activerecord-4.2/Gemfile.sqlite3
13
- - gemfiles/activerecord-5.0/Gemfile.mysql2
14
- - gemfiles/activerecord-5.0/Gemfile.postgresql
15
- - gemfiles/activerecord-5.0/Gemfile.sqlite3
16
- - gemfiles/activerecord-5.1/Gemfile.mysql2
17
- - gemfiles/activerecord-5.1/Gemfile.postgresql
18
- - gemfiles/activerecord-5.1/Gemfile.sqlite3
19
- - gemfiles/activerecord-5.2/Gemfile.mysql2
20
- - gemfiles/activerecord-5.2/Gemfile.postgresql
21
- - gemfiles/activerecord-5.2/Gemfile.sqlite3
22
- env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
23
- addons:
24
- postgresql: '9.4'
25
- before_script: bundle exec rake create_databases
26
- after_script: bundle exec rake drop_databases
27
- script: bundle exec rake travis
28
- notifications:
29
- email:
30
- - toby@ovod-everett.org
31
- - ronen@barzel.org
@@ -1,3 +0,0 @@
1
- eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
-
3
- gem "activerecord", "~> 4.2.6"
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "mysql2", '>= 0.3.18', '< 0.5'
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcmysql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "pg", "< 1"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcpostgresql-adapter'
10
- end
@@ -1,3 +0,0 @@
1
- eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
-
3
- gem "activerecord", "~> 5.0.1"
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "mysql2"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcmysql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "pg", "< 1"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcpostgresql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "sqlite3"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
@@ -1,3 +0,0 @@
1
- eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
-
3
- gem "activerecord", "~> 5.1.0"
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "mysql2"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcmysql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "pg", "< 1"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcpostgresql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "sqlite3"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end