is_a_validator 1.0.0 → 2.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 (61) hide show
  1. checksums.yaml +5 -5
  2. data/README.org +40 -0
  3. data/Rakefile +7 -15
  4. data/lib/is_a_validator.rb +9 -4
  5. data/lib/is_a_validator/version.rb +3 -1
  6. metadata +74 -127
  7. data/README.rdoc +0 -15
  8. data/test/dummy/README.rdoc +0 -28
  9. data/test/dummy/Rakefile +0 -6
  10. data/test/dummy/app/assets/javascripts/application.js +0 -13
  11. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  12. data/test/dummy/app/controllers/application_controller.rb +0 -5
  13. data/test/dummy/app/helpers/application_helper.rb +0 -2
  14. data/test/dummy/app/models/account_implementer.rb +0 -3
  15. data/test/dummy/app/models/account_owner.rb +0 -4
  16. data/test/dummy/app/models/concerns/account.rb +0 -3
  17. data/test/dummy/app/models/not_an_account.rb +0 -2
  18. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  19. data/test/dummy/bin/bundle +0 -3
  20. data/test/dummy/bin/rails +0 -4
  21. data/test/dummy/bin/rake +0 -4
  22. data/test/dummy/bin/setup +0 -29
  23. data/test/dummy/config.ru +0 -4
  24. data/test/dummy/config/application.rb +0 -26
  25. data/test/dummy/config/boot.rb +0 -5
  26. data/test/dummy/config/database.yml +0 -25
  27. data/test/dummy/config/environment.rb +0 -5
  28. data/test/dummy/config/environments/development.rb +0 -41
  29. data/test/dummy/config/environments/production.rb +0 -79
  30. data/test/dummy/config/environments/test.rb +0 -42
  31. data/test/dummy/config/initializers/assets.rb +0 -11
  32. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  33. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  34. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  35. data/test/dummy/config/initializers/inflections.rb +0 -16
  36. data/test/dummy/config/initializers/mime_types.rb +0 -4
  37. data/test/dummy/config/initializers/session_store.rb +0 -3
  38. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  39. data/test/dummy/config/locales/en.yml +0 -23
  40. data/test/dummy/config/routes.rb +0 -56
  41. data/test/dummy/config/secrets.yml +0 -22
  42. data/test/dummy/db/development.sqlite3 +0 -0
  43. data/test/dummy/db/migrate/20150519012115_create_account_implementers.rb +0 -8
  44. data/test/dummy/db/migrate/20150519012211_create_not_an_accounts.rb +0 -8
  45. data/test/dummy/db/migrate/20150519012248_create_account_owners.rb +0 -9
  46. data/test/dummy/db/schema.rb +0 -33
  47. data/test/dummy/db/test.sqlite3 +0 -0
  48. data/test/dummy/log/development.log +0 -26
  49. data/test/dummy/log/test.log +0 -179
  50. data/test/dummy/public/404.html +0 -67
  51. data/test/dummy/public/422.html +0 -67
  52. data/test/dummy/public/500.html +0 -66
  53. data/test/dummy/public/favicon.ico +0 -0
  54. data/test/dummy/test/fixtures/account_implementers.yml +0 -11
  55. data/test/dummy/test/fixtures/account_owners.yml +0 -7
  56. data/test/dummy/test/fixtures/not_an_accounts.yml +0 -11
  57. data/test/dummy/test/models/account_implementer_test.rb +0 -7
  58. data/test/dummy/test/models/account_owner_test.rb +0 -7
  59. data/test/dummy/test/models/not_an_account_test.rb +0 -7
  60. data/test/is_a_validator_test.rb +0 -19
  61. data/test/test_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2d94aaf8565ad7caf1bea44980178f58eccc06bd
4
- data.tar.gz: 56ca414ddcdb175f0f589123269b03b53d74746f
2
+ SHA256:
3
+ metadata.gz: 8adf8977486337e902cadd7e71aacecbf9450cb609b9f2214c26047ca83f3aa7
4
+ data.tar.gz: 1f966631f3a81b284999b7d1ff03d8096b4283340d4774726f857016e875cb1c
5
5
  SHA512:
6
- metadata.gz: 61cb43df36ee170bba2bc5c63d3de3830ea6b75a24d1b0df50d185b3d2fd906a89a78d7a93db75c848de0be30c64a89a6a620350ff50fe21c2a2aa45f429b91e
7
- data.tar.gz: 4027666c3f0bc4c2f7f5b0420c8dd403e4d27d517a0cf3c1b4e7ee5a9f50c2eb11522c2582939e8dc11df112f0bb295ee34959fe944271e109fce61ba8538913
6
+ metadata.gz: 89d55f0586b10a2d08e411762404d20875663524280594eb7b2804be6a3d59cd7387cda7f5a8434c086fa8a2251f74816e12b7d7aa018fda2aa27ab42bd64b32
7
+ data.tar.gz: 4452a937b645f6bee6316521cff59689defd08395e256ee351dc80cc447cd433bb6c41a1af0542819a05590d1bf9eb61ac60d82a0cdd6b1509d0fa58e41b80f6
@@ -0,0 +1,40 @@
1
+ * IsAValidator
2
+
3
+ Provides an ActiveRecord validator that ensures a polymorphic association
4
+
5
+ * is an instance of specific class or one of its subclasses or
6
+ * implements a specific Concern
7
+
8
+ ** Usage:
9
+
10
+ #+BEGIN_SRC ruby
11
+ belongs_to :account, polymorphic: true
12
+ validates :account, is_a: Account
13
+ #+END_SRC
14
+
15
+ * Development & Testing
16
+
17
+ Ruby version is managed by =rvm= & =.rvmrc=
18
+
19
+ #+BEGIN_SRC shell
20
+ gem install bundler
21
+ bundle install
22
+ bundle exec appraisal install
23
+ bundle exec appraisal rspec
24
+ #+END_SRC
25
+
26
+ ** Generating Docs
27
+
28
+ #+BEGIN_SRC shell
29
+ bundle exec rdoc
30
+ #+END_SRC
31
+
32
+ ** Tagging & Deploying a new version
33
+
34
+ #+BEGIN_SRC shell
35
+ gem build is_a_validator.gemspec
36
+ #+END_SRC
37
+
38
+ * License
39
+
40
+ IsAValidator is released under an MIT-LICENSE. Use it how you see fit.
data/Rakefile CHANGED
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
4
6
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
7
  end
6
8
 
9
+ require 'bundler/gem_tasks'
10
+ require 'rspec/core/rake_task'
7
11
  require 'rdoc/task'
8
12
 
9
13
  RDoc::Task.new(:rdoc) do |rdoc|
@@ -14,21 +18,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
18
  rdoc.rdoc_files.include('lib/**/*.rb')
15
19
  end
16
20
 
17
-
18
-
19
-
20
-
21
-
22
- Bundler::GemHelper.install_tasks
23
-
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'lib'
28
- t.libs << 'test'
29
- t.pattern = 'test/**/*_test.rb'
21
+ desc 'Run RSpec'
22
+ RSpec::Core::RakeTask.new do |t|
30
23
  t.verbose = false
31
24
  end
32
25
 
33
-
34
- task default: :test
26
+ task default: :rspec
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
1
5
  # This validates that a polymorphic association implements a specific Concern or is a specific class
2
6
  #
3
7
  # Usage:
@@ -8,8 +12,9 @@
8
12
  class IsAValidator < ActiveModel::EachValidator
9
13
  def validate_each(record, attribute, value)
10
14
  required_class = options[:with]
11
- unless value.nil? || value.is_a?(required_class)
12
- record.errors[attribute] << "#{attribute} must be an instance of #{required_class.name}"
13
- end
15
+
16
+ return if value.nil? || value.is_a?(required_class) # All good here
17
+
18
+ record.errors[attribute] << "must be an instance of #{required_class.name}" # Not good here
14
19
  end
15
- end
20
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IsA
2
- VERSION = "1.0.0"
4
+ VERSION = '2.0.0'
3
5
  end
metadata CHANGED
@@ -1,43 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_a_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael P. Daugherty
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2020-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.3'
34
+ type: :development
35
+ prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '4.1'
40
+ version: '2.3'
27
41
  - !ruby/object:Gem::Dependency
28
- name: sqlite3
42
+ name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ">="
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: '2.1'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: '2.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.93'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.93'
41
97
  description: Adds an "is_a" validator to validate polymorphic relations.
42
98
  email:
43
99
  - mike@mpdaugherty.com
@@ -46,69 +102,15 @@ extensions: []
46
102
  extra_rdoc_files: []
47
103
  files:
48
104
  - MIT-LICENSE
49
- - README.rdoc
105
+ - README.org
50
106
  - Rakefile
51
107
  - lib/is_a_validator.rb
52
108
  - lib/is_a_validator/version.rb
53
- - test/dummy/README.rdoc
54
- - test/dummy/Rakefile
55
- - test/dummy/app/assets/javascripts/application.js
56
- - test/dummy/app/assets/stylesheets/application.css
57
- - test/dummy/app/controllers/application_controller.rb
58
- - test/dummy/app/helpers/application_helper.rb
59
- - test/dummy/app/models/account_implementer.rb
60
- - test/dummy/app/models/account_owner.rb
61
- - test/dummy/app/models/concerns/account.rb
62
- - test/dummy/app/models/not_an_account.rb
63
- - test/dummy/app/views/layouts/application.html.erb
64
- - test/dummy/bin/bundle
65
- - test/dummy/bin/rails
66
- - test/dummy/bin/rake
67
- - test/dummy/bin/setup
68
- - test/dummy/config.ru
69
- - test/dummy/config/application.rb
70
- - test/dummy/config/boot.rb
71
- - test/dummy/config/database.yml
72
- - test/dummy/config/environment.rb
73
- - test/dummy/config/environments/development.rb
74
- - test/dummy/config/environments/production.rb
75
- - test/dummy/config/environments/test.rb
76
- - test/dummy/config/initializers/assets.rb
77
- - test/dummy/config/initializers/backtrace_silencers.rb
78
- - test/dummy/config/initializers/cookies_serializer.rb
79
- - test/dummy/config/initializers/filter_parameter_logging.rb
80
- - test/dummy/config/initializers/inflections.rb
81
- - test/dummy/config/initializers/mime_types.rb
82
- - test/dummy/config/initializers/session_store.rb
83
- - test/dummy/config/initializers/wrap_parameters.rb
84
- - test/dummy/config/locales/en.yml
85
- - test/dummy/config/routes.rb
86
- - test/dummy/config/secrets.yml
87
- - test/dummy/db/development.sqlite3
88
- - test/dummy/db/migrate/20150519012115_create_account_implementers.rb
89
- - test/dummy/db/migrate/20150519012211_create_not_an_accounts.rb
90
- - test/dummy/db/migrate/20150519012248_create_account_owners.rb
91
- - test/dummy/db/schema.rb
92
- - test/dummy/db/test.sqlite3
93
- - test/dummy/log/development.log
94
- - test/dummy/log/test.log
95
- - test/dummy/public/404.html
96
- - test/dummy/public/422.html
97
- - test/dummy/public/500.html
98
- - test/dummy/public/favicon.ico
99
- - test/dummy/test/fixtures/account_implementers.yml
100
- - test/dummy/test/fixtures/account_owners.yml
101
- - test/dummy/test/fixtures/not_an_accounts.yml
102
- - test/dummy/test/models/account_implementer_test.rb
103
- - test/dummy/test/models/account_owner_test.rb
104
- - test/dummy/test/models/not_an_account_test.rb
105
- - test/is_a_validator_test.rb
106
- - test/test_helper.rb
107
109
  homepage: https://github.com/mpdaugherty/is_a_validator
108
110
  licenses:
109
111
  - MIT
110
112
  metadata: {}
111
- post_install_message:
113
+ post_install_message:
112
114
  rdoc_options: []
113
115
  require_paths:
114
116
  - lib
@@ -116,70 +118,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
118
  requirements:
117
119
  - - ">="
118
120
  - !ruby/object:Gem::Version
119
- version: '0'
121
+ version: '2.4'
120
122
  required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  requirements:
122
124
  - - ">="
123
125
  - !ruby/object:Gem::Version
124
126
  version: '0'
125
127
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.4.3
128
- signing_key:
128
+ rubygems_version: 3.1.4
129
+ signing_key:
129
130
  specification_version: 4
130
131
  summary: Adds an "is_a" validator to validate polymorphic relations.
131
- test_files:
132
- - test/dummy/app/assets/javascripts/application.js
133
- - test/dummy/app/assets/stylesheets/application.css
134
- - test/dummy/app/controllers/application_controller.rb
135
- - test/dummy/app/helpers/application_helper.rb
136
- - test/dummy/app/models/account_implementer.rb
137
- - test/dummy/app/models/account_owner.rb
138
- - test/dummy/app/models/concerns/account.rb
139
- - test/dummy/app/models/not_an_account.rb
140
- - test/dummy/app/views/layouts/application.html.erb
141
- - test/dummy/bin/bundle
142
- - test/dummy/bin/rails
143
- - test/dummy/bin/rake
144
- - test/dummy/bin/setup
145
- - test/dummy/config/application.rb
146
- - test/dummy/config/boot.rb
147
- - test/dummy/config/database.yml
148
- - test/dummy/config/environment.rb
149
- - test/dummy/config/environments/development.rb
150
- - test/dummy/config/environments/production.rb
151
- - test/dummy/config/environments/test.rb
152
- - test/dummy/config/initializers/assets.rb
153
- - test/dummy/config/initializers/backtrace_silencers.rb
154
- - test/dummy/config/initializers/cookies_serializer.rb
155
- - test/dummy/config/initializers/filter_parameter_logging.rb
156
- - test/dummy/config/initializers/inflections.rb
157
- - test/dummy/config/initializers/mime_types.rb
158
- - test/dummy/config/initializers/session_store.rb
159
- - test/dummy/config/initializers/wrap_parameters.rb
160
- - test/dummy/config/locales/en.yml
161
- - test/dummy/config/routes.rb
162
- - test/dummy/config/secrets.yml
163
- - test/dummy/config.ru
164
- - test/dummy/db/development.sqlite3
165
- - test/dummy/db/migrate/20150519012115_create_account_implementers.rb
166
- - test/dummy/db/migrate/20150519012211_create_not_an_accounts.rb
167
- - test/dummy/db/migrate/20150519012248_create_account_owners.rb
168
- - test/dummy/db/schema.rb
169
- - test/dummy/db/test.sqlite3
170
- - test/dummy/log/development.log
171
- - test/dummy/log/test.log
172
- - test/dummy/public/404.html
173
- - test/dummy/public/422.html
174
- - test/dummy/public/500.html
175
- - test/dummy/public/favicon.ico
176
- - test/dummy/Rakefile
177
- - test/dummy/README.rdoc
178
- - test/dummy/test/fixtures/account_implementers.yml
179
- - test/dummy/test/fixtures/account_owners.yml
180
- - test/dummy/test/fixtures/not_an_accounts.yml
181
- - test/dummy/test/models/account_implementer_test.rb
182
- - test/dummy/test/models/account_owner_test.rb
183
- - test/dummy/test/models/not_an_account_test.rb
184
- - test/is_a_validator_test.rb
185
- - test/test_helper.rb
132
+ test_files: []
@@ -1,15 +0,0 @@
1
- = IsAValidator
2
-
3
- Provides a Rails validator that ensures a polymorphic association
4
-
5
- * implements a specific Concern or
6
- * is an instance of specific class or one of its subclasses.
7
-
8
- Usage:
9
-
10
- belongs_to :account, polymorphic: true
11
- validates :account, is_a: Account
12
-
13
- = License
14
-
15
- IsAValidator is released under an MIT-LICENSE
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .