morse_active_record_helpers 1.1.3 → 1.1.4

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: b5f9b58d70d4b3a329d1454e093206eb991f0ddc
4
- data.tar.gz: 9766fa6a48d152f17c4932e16570d35adec638b8
3
+ metadata.gz: eb4c53fd5ef384884542a824b3846e0a2881aedb
4
+ data.tar.gz: 81e9f01130d230519253c1874063edb215c879cd
5
5
  SHA512:
6
- metadata.gz: 2057caa2ab85027c4f6842af0676e0f7d124159eee344f418767e0576dd654d8bb01d68425815927206748944cd682d126fdf8ee4f0b93ec1a86f301b4e3fd7e
7
- data.tar.gz: 01c5a461796c0f98e62daa2addc41e2229b5ea4b213bd52c1916e7ff980b440ee6cb010ca02a64081eeecc03a131a5833d4f38f9f6919fdff9f3d0d6f9339711
6
+ metadata.gz: 161c5d749be5a008eacee91964c49de4a033ede276f89ea5f9c12167b735f8be44808832d33118d65da44449758bb6bf494e8992536c9eeaec113eb5aad7825e
7
+ data.tar.gz: c49e5c0202c412757455f2953c39dbc5473765caf7987446a160cfabf24f5323c5b2449bc640e073fd8af4bcbf7c5e57d0b103622f12c5a9ce679340227957fb
@@ -89,6 +89,13 @@ module MorseActiveRecordHelpers
89
89
  end
90
90
  end
91
91
 
92
+ def url_compliant(*urls)
93
+ urls.each do |url|
94
+ return if url_compliant?(url)
95
+ self.errors.add(url, "'#{send(:url)}' is not a valid URL.")
96
+ end
97
+ end
98
+
92
99
  def validate_legal_age(field, min=18)
93
100
  if self.send(field).is_a?(Date)
94
101
  unless self.send(field)<min.years.ago
@@ -101,7 +108,6 @@ module MorseActiveRecordHelpers
101
108
  end
102
109
  end
103
110
 
104
-
105
111
  def validate_integer_or_default(thing,default)
106
112
  unless self.send(thing)
107
113
  self.send("#{thing}=",default)
@@ -113,4 +119,13 @@ module MorseActiveRecordHelpers
113
119
  errors.add(thing,message)
114
120
  end
115
121
  end
122
+
123
+ private
124
+
125
+ def url_compliant?(url)
126
+ uri = URI.parse(url)
127
+ uri.is_a?(URI::HTTP) && !uri.host.nil?
128
+ rescue URI::InvalidURIError
129
+ false
130
+ end
116
131
  end
@@ -1,3 +1,3 @@
1
1
  module MorseActiveRecordHelpers
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morse_active_record_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry S
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-28 00:00:00.000000000 Z
11
+ date: 2017-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,7 +112,6 @@ files:
112
112
  - bin/setup
113
113
  - lib/morse_active_record_helpers.rb
114
114
  - lib/morse_active_record_helpers/version.rb
115
- - morse_active_record_helpers-1.1.2.gem
116
115
  - morse_active_record_helpers.gemspec
117
116
  homepage: https://github.com/morsedigital/morse_active_record_helpers
118
117
  licenses: