roda-component 0.1.28 → 0.1.29

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f394e3df58f2cc1e6ae4b050f1d3fa1c115e619a
4
- data.tar.gz: 493c91445c9a9a4e609671c2e69b090cdb0a1671
3
+ metadata.gz: eae3fae4ea91aee88c28f270ebcf6fff1ff7b53f
4
+ data.tar.gz: 0b75b3ed5a36ca0dea4b387f0ca99c6d1df89ebd
5
5
  SHA512:
6
- metadata.gz: 1f69f31e023c2c386f62ac663e05965893df6be7da0b32c793da25d5b55fdecb98a64bba9be28f57acb95266cae653a95523c9b321ad8995e6f2e830a85fa342
7
- data.tar.gz: 2da6028f1ab9951904757aebe7f7baa5452002a3585bd181e3c57c0fa9558c94837f7446612ff87bf03f71ee18cbd5a065c0b2cae85052a295cc7c6940578cb9
6
+ metadata.gz: 7f5f576648297e189783d00cb7cf92d72f4e4afdf5e91565e677ea911ad45cec3b4aa944d33c1566ba9268034c2b56fff268982d7131ed42ff9b7a84b59f7880
7
+ data.tar.gz: 49f2db414e872f5f2caf5482a101276c4e676c7d05c9e408b643a054af18df9a84946a63569ba0c38e2b32a0308753076da6cd04f5587fd10f2dc6b393988d70
@@ -325,6 +325,16 @@ class Roda
325
325
  RUBY_ENGINE == 'opal'
326
326
  end
327
327
  alias :client :client?
328
+
329
+ def self.server? &block
330
+ RUBY_ENGINE == 'ruby'
331
+ end
332
+ alias :server :server?
333
+
334
+ def self.client?
335
+ RUBY_ENGINE == 'opal'
336
+ end
337
+ alias :client :client?
328
338
  end
329
339
  end
330
340
  end
@@ -50,6 +50,25 @@ class Roda
50
50
  # :date => [:format] }
51
51
  #
52
52
  module Validations
53
+ def server? &block
54
+ RUBY_ENGINE == 'ruby'
55
+ end
56
+ alias :server :server?
57
+
58
+ def client?
59
+ RUBY_ENGINE == 'opal'
60
+ end
61
+ alias :client :client?
62
+
63
+ def self.server? &block
64
+ RUBY_ENGINE == 'ruby'
65
+ end
66
+ alias :server :server?
67
+
68
+ def self.client?
69
+ RUBY_ENGINE == 'opal'
70
+ end
71
+ alias :client :client?
53
72
 
54
73
  # Check if the current model state is valid. Each call to {#valid?} will
55
74
  # reset the {#errors} array.
@@ -127,11 +146,19 @@ class Roda
127
146
  # when the validation fails.
128
147
  def assert_numeric(att, error = [att, :not_numeric])
129
148
  if assert_present(att, error)
130
- assert_format(att, /\A\-?\d+\z/, error)
149
+ if client?
150
+ assert_format(att, /^\-?\d+$/, error)
151
+ else
152
+ assert_format(att, /\A\-?\d+\z/, error)
153
+ end
131
154
  end
132
155
  end
133
156
 
134
- URL = /\A(http|https):\/\/([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}|(2 5[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3} |localhost)(:[0-9]{1,5})?(\/.*)?\z/i
157
+ if client?
158
+ URL = /^(http|https):\/\/([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}|(2 5[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3} |localhost)(:[0-9]{1,5})?(\/.*)?$/i
159
+ else
160
+ URL = /\A(http|https):\/\/([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}|(2 5[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3} |localhost)(:[0-9]{1,5})?(\/.*)?\z/i
161
+ end
135
162
 
136
163
  def assert_url(att, error = [att, :not_url])
137
164
  if assert_present(att, error)
@@ -139,7 +166,11 @@ class Roda
139
166
  end
140
167
  end
141
168
 
142
- EMAIL = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/i
169
+ if client?
170
+ EMAIL = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/i
171
+ else
172
+ EMAIL = /\A[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]\z/i
173
+ end
143
174
 
144
175
  def assert_email(att, error = [att, :not_email])
145
176
  if assert_present(att, error)
@@ -158,7 +189,11 @@ class Roda
158
189
  end
159
190
  end
160
191
 
161
- DECIMAL = /\A\-?(\d+)?(\.\d+)?\z/
192
+ if client?
193
+ DECIMAL = /^\-?(\d+)?(\.\d+)?$/
194
+ else
195
+ DECIMAL = /\A\-?(\d+)?(\.\d+)?\z/
196
+ end
162
197
 
163
198
  def assert_decimal(att, error = [att, :not_decimal])
164
199
  assert_format att, DECIMAL, error
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.28"
3
+ VERSION = "0.1.29"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj