morse_fields_validator 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 082814eed5755cb403d5d17aec4f64d3995775bd
4
- data.tar.gz: 9badbce8d4fa6a3bea0383acd4a2c24ef03f9e3b
3
+ metadata.gz: 60d06f1dbb65e932afc3de5176651c454e7666a2
4
+ data.tar.gz: 519626fa7857d7501d8b39f9abe4479bff34fa58
5
5
  SHA512:
6
- metadata.gz: 040e7bbbd09d30d36824bc383867b8bf9df56c17597fb95d3426f296154969c5239ce28a927102f1f7255af131cbbea5b6ea298494e0222f0dddf939f94f5abf
7
- data.tar.gz: a0fd3ad7381c1f62d7d4b36bd3fd2393b5a1c1d717a159d745127bda725ada8f3044fe88353f0fc87af4ab7ae11cbd51b64438947191a91b30a7707a21956f4d
6
+ metadata.gz: b4f69aff01519d07dba7c855c4045e5afe41fd88ab1bbbd9c85cfd25a9d1f6a1a16a0d4e03ec459e2b7deb6247e183c4825f9a477f17d6b33bc24687e70391f3
7
+ data.tar.gz: 119a4d35a841e331b984cf551be511d3443ec974e04ca66d9fe4d460bd543e3c4a413ce88714ed948cf6b85cbbda9b56acf6d969b645c6b4433db054a14156c1
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: bMCUHJhkmWcEBZaZsRWT3HZUBJaX3M4he
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+
17
+ end
@@ -1,7 +1,11 @@
1
1
  module FieldsValidator
2
- ERROR = 'please ensure necessary fields are in place'
3
2
 
4
3
  extend ActiveSupport::Concern
4
+
5
+ included do
6
+ validate :validate_column_names
7
+ end
8
+
5
9
  class_methods do
6
10
  def validate_required_attributes
7
11
  required_attributes.each do |a|
@@ -9,17 +13,22 @@ module FieldsValidator
9
13
  end
10
14
  end
11
15
  def load_required_attributes(*_attrs)
12
- @required_attributes ||=[]
13
- @required_attributes += _attrs
16
+ @required_attributes=_attrs.any? ? _attrs : []
14
17
  @required_attributes.uniq!
15
18
  end
16
19
 
17
20
  def required_attributes
18
21
  @required_attributes
19
22
  end
23
+ end
20
24
 
21
- def validate_column_names(*_attrs)
22
- _attrs.each { |rdf| raise "#{rdf} not included. #{ERROR}" unless column_names.include?(rdf)}
23
- end
25
+ private
26
+
27
+ def required_database_fields
28
+ defined?(super) ? super : []
29
+ end
30
+
31
+ def validate_column_names
32
+ required_database_fields.each { |rdf| errors_add(rdf, "does not have a column in the database.") unless self.class.column_names.include?(rdf)} if required_database_fields.any?
24
33
  end
25
34
  end
@@ -1,3 +1,3 @@
1
1
  module MorseFieldsValidator
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.8"
28
28
  spec.add_development_dependency "coveralls", "~> 0.8"
29
+ spec.add_development_dependency "guard-rspec", "~> 4.5"
30
+ spec.add_development_dependency "rb-fsevent", "~> 0.9"
29
31
  spec.add_development_dependency "shoulda-matchers", "~> 2.8"
30
32
  spec.add_development_dependency "rake", "~> 10.0"
31
33
  spec.add_development_dependency "rspec", "~> 3.2"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morse_fields_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry S
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-28 00:00:00.000000000 Z
12
+ date: 2015-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -67,6 +67,34 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0.8'
70
+ - !ruby/object:Gem::Dependency
71
+ name: guard-rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '4.5'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '4.5'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rb-fsevent
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.9'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.9'
70
98
  - !ruby/object:Gem::Dependency
71
99
  name: shoulda-matchers
72
100
  requirement: !ruby/object:Gem::Requirement
@@ -117,10 +145,12 @@ executables: []
117
145
  extensions: []
118
146
  extra_rdoc_files: []
119
147
  files:
148
+ - ".coveralls.yml"
120
149
  - ".gitignore"
121
150
  - ".rspec"
122
151
  - ".travis.yml"
123
152
  - Gemfile
153
+ - Guardfile
124
154
  - README.md
125
155
  - Rakefile
126
156
  - bin/console