schema_plus_association_inverses 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.consolerc +3 -0
- data/.gitignore +10 -0
- data/.travis.yml +18 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -0
- data/Rakefile +9 -0
- data/gemfiles/Gemfile.base +4 -0
- data/gemfiles/activerecord-4.2/Gemfile.base +3 -0
- data/gemfiles/activerecord-4.2/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-4.2/Gemfile.postgresql +8 -0
- data/gemfiles/activerecord-4.2/Gemfile.sqlite3 +10 -0
- data/lib/schema_plus/association_inverses.rb +8 -0
- data/lib/schema_plus/association_inverses/middleware.rb +1 -0
- data/lib/schema_plus/association_inverses/middleware/association.rb +20 -0
- data/lib/schema_plus/association_inverses/version.rb +6 -0
- data/lib/schema_plus_association_inverses.rb +1 -0
- data/schema_association_inverses.gemspec +33 -0
- data/schema_dev.yml +8 -0
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4534409fced9bb961b30e224eb1eb820d7fbc39c
|
4
|
+
data.tar.gz: c9c6dd35d78aab01b3b71ab316401c97c566fdd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 233d85149243faf8f82bacecbc2c65b297ac816140b713605ed9a76312a586e8780b1588d25c84208e05a023f6844635e2fb82e79da0fb26a5b7248b55aff6f2
|
7
|
+
data.tar.gz: b225e0805790115a6c3a9912ca2a3c598a8010eeaa7fdf81a63f418196a16e18a38f49bc630d94ec4a048feb977d2c28729927b85f4b4c0ad2480a1f9a530227
|
data/.consolerc
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
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.1.5
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
11
|
+
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
12
|
+
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
13
|
+
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
14
|
+
addons:
|
15
|
+
postgresql: '9.3'
|
16
|
+
before_script: bundle exec rake create_databases
|
17
|
+
after_script: bundle exec rake drop_databases
|
18
|
+
script: bundle exec rake travis
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Joel Low
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# SchemaPlus Association Inverses [![Build Status](https://travis-ci.org/lowjoel/schema_plus_association_inverses.svg)](https://travis-ci.org/lowjoel/schema_plus_association_inverses) [![Coverage Status](https://coveralls.io/repos/lowjoel/schema_plus_association_inverses/badge.svg)](https://coveralls.io/r/lowjoel/schema_plus_association_inverses)
|
2
|
+
|
3
|
+
This little gem detects when an ActiveRecord association requires the programmer to explicitly set
|
4
|
+
`inverse_of` in the declaration.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'schema_plus_association_inverses'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install schema_plus_association_inverses
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
When a model requiring manual declaration of the inverse is detected, a little window appears at the
|
25
|
+
bottom of the page. This is inspired by [Bullet](https://github.com/flyerhzm/bullet).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it (https://github.com/lowjoel/schema_plus_association_inverses/fork)
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'middleware/association'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SchemaPlus::AssociationInverses
|
2
|
+
module Middleware
|
3
|
+
|
4
|
+
module Model
|
5
|
+
module Association
|
6
|
+
module Declaration
|
7
|
+
|
8
|
+
def after(env)
|
9
|
+
reflection = env.model.reflect_on_association(env.name)
|
10
|
+
if !reflection.polymorphic? && !reflection.has_inverse?
|
11
|
+
raise ActiveRecord::InverseOfAssociationNotFoundError.new(reflection)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'schema_plus/association_inverses'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'schema_plus/association_inverses/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'schema_plus_association_inverses'
|
8
|
+
spec.version = SchemaPlus::AssociationInverses::VERSION
|
9
|
+
spec.authors = ['Joel Low']
|
10
|
+
spec.email = ['joel@joelsplace.sg']
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
end
|
14
|
+
|
15
|
+
spec.summary = 'Warns when association inverses are not autodetected'
|
16
|
+
spec.description = ''
|
17
|
+
spec.homepage = 'https://github.com/lowjoel/schema_plus_association_inverses'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'schema_plus_core', '~> 0.3.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
29
|
+
spec.add_development_dependency 'rspec-core', '~> 3'
|
30
|
+
spec.add_development_dependency 'schema_dev', '~> 3.3'
|
31
|
+
spec.add_development_dependency 'simplecov'
|
32
|
+
spec.add_development_dependency 'simplecov-gem-profile'
|
33
|
+
end
|
data/schema_dev.yml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_association_inverses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Low
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: schema_plus_core
|
@@ -128,7 +128,26 @@ email:
|
|
128
128
|
executables: []
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
|
-
files:
|
131
|
+
files:
|
132
|
+
- ".consolerc"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".travis.yml"
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- gemfiles/Gemfile.base
|
140
|
+
- gemfiles/activerecord-4.2/Gemfile.base
|
141
|
+
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
142
|
+
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
143
|
+
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
144
|
+
- lib/schema_plus/association_inverses.rb
|
145
|
+
- lib/schema_plus/association_inverses/middleware.rb
|
146
|
+
- lib/schema_plus/association_inverses/middleware/association.rb
|
147
|
+
- lib/schema_plus/association_inverses/version.rb
|
148
|
+
- lib/schema_plus_association_inverses.rb
|
149
|
+
- schema_association_inverses.gemspec
|
150
|
+
- schema_dev.yml
|
132
151
|
homepage: https://github.com/lowjoel/schema_plus_association_inverses
|
133
152
|
licenses:
|
134
153
|
- MIT
|
@@ -149,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
168
|
version: '0'
|
150
169
|
requirements: []
|
151
170
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.4.
|
171
|
+
rubygems_version: 2.4.8
|
153
172
|
signing_key:
|
154
173
|
specification_version: 4
|
155
174
|
summary: Warns when association inverses are not autodetected
|