wedge 0.1.29 → 0.1.30

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: 82ed2df92b72b0a213e2aa2bea5e94319ee0450b
4
- data.tar.gz: e466b573325a1ae29a07a7d22c586b56a1df5c4b
3
+ metadata.gz: acb8310e6a55b6301fa9634798900c77820a1504
4
+ data.tar.gz: 7a50bc7d53488d69a4dcf746096d1271b672c0af
5
5
  SHA512:
6
- metadata.gz: bc779cf77fb546f8dbe2b58a1a76bd90c86b59d2b29068c684e2075c6034d08c51eddb7771f53c1c7448ca0c4a1e0caee025ef4eda3f5556e1bc7b592162491e
7
- data.tar.gz: 226545e53176745e58f24c9a46e6216ce917d44541c13244c6a8cab8d27b20e59a57995539d3f286d1de8cd4be9b9fcec04e3195d8ec9e541c529076a3a67fea
6
+ metadata.gz: ff1b4e7a60559b638977d43df2a0e150adfc2ddfebcf179aa6ce390720d0fdb02e4ead8a8802b51282e2777bff424d02a8398cba47ea7c3f1f7f9f96c04f873f
7
+ data.tar.gz: babe2985f4b9eda4da72cd9065313123ab93eea0b6da1a3ed0b2aef6047e0f6807f452fcf74a9308a7b3525ed8934e58ab8cf153e0fc887334f5a2436da96427
data/lib/wedge.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'wedge/opal'
2
1
  require 'wedge/version'
2
+ require 'wedge/opal'
3
3
  require 'wedge/utilis/indifferent_hash'
4
4
  require 'wedge/utilis/hash'
5
5
  require 'wedge/utilis/blank'
data/lib/wedge/opal.rb CHANGED
@@ -79,6 +79,10 @@ end
79
79
  class Wedge
80
80
  # Create our own opal instance.
81
81
  Opal = ::Opal.dup
82
+
83
+ def self.version
84
+ Wedge::VERSION
85
+ end
82
86
  end
83
87
 
84
88
  if RUBY_ENGINE == 'opal'
@@ -89,6 +93,23 @@ if RUBY_ENGINE == 'opal'
89
93
  # alias_native :selectize
90
94
  end
91
95
  else
92
- Wedge::Opal.use_gem 'wedge'
96
+ # issue:
97
+ # Wedge::Opal.use_gem 'wedge'
98
+ # NoMethodError: method `runtime_dependencies' for nil:NilClass
99
+ # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:36:in `require_paths_for_gem'
100
+ # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:37:in `block in require_paths_for_gem'
101
+ # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:36:in `each'
102
+ # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:36:in `require_paths_for_gem'
103
+ # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:27:in `use_gem'
104
+ # /home/rof/cache/bundler/ruby/2.1.0/gems/wedge-0.1.29/lib/wedge/opal.rb:92:in `<top (required)>'
105
+ # /home/rof/cache/bundler/ruby/2.1.0/gems/wedge-0.1.29/lib/wedge.rb:1:in `require'
106
+ # /home/rof/cache/bundler/ruby/2.1.0/gems/wedge-0.1.29/lib/wedge.rb:1:in `<top (required)>'
107
+ # /home/rof/src/github.com/acdcorp/autolink.cuba/app/config/boot.rb:10:in `require'
108
+ # /home/rof/src/github.com/acdcorp/autolink.cuba/app/config/boot.rb:10:in `<top (required)>'
109
+ # /home/rof/src/github.com/acdcorp/autolink.cuba/Rakefile:15:in `require'
110
+ # /home/rof/src/github.com/acdcorp/autolink.cuba/Rakefile:15:in `<top (required)>'
111
+ # (See full trace by running task with --trace)
112
+ # make: *** [test] Error 1
113
+ Wedge::Opal.append_path Wedge.method(:version).source_location.first.sub('wedge/opal.rb', '')
93
114
  end
94
115
 
@@ -267,16 +267,22 @@ class Wedge
267
267
  @_atts = Atts.new atts, _accessors, _aliases, _accessor_options
268
268
  @_atts = @_atts.set_defaults self
269
269
 
270
+ _set_atts atts
271
+ end
272
+
273
+ def _set_atts atts
270
274
  atts.each do |key, val|
271
275
  # grab the original key if alias is given
272
276
  _atts_keys << (key = _aliases.invert[key] || key)
273
277
 
274
- next if (_accessor_options[key] || {})[:form]
275
-
276
- accessor = "#{key}="
278
+ if (_accessor_options[key] || {})[:form]
279
+ send(key)._set_atts val
280
+ else
281
+ accessor = "#{key}="
277
282
 
278
- if respond_to?(accessor)
279
- send(accessor, val)
283
+ if respond_to?(accessor)
284
+ send(accessor, val)
285
+ end
280
286
  end
281
287
  end
282
288
  end
@@ -75,6 +75,11 @@ class Wedge
75
75
  _errors.empty?
76
76
  end
77
77
 
78
+ def valid atts
79
+ _set_atts atts
80
+ valid?
81
+ end
82
+
78
83
  # Base validate implementation. Override this method in subclasses.
79
84
  def validate
80
85
  end
@@ -119,8 +124,8 @@ class Wedge
119
124
  # @param [Array<Symbol, Symbol>] error The error that should be returned
120
125
  # when the validation fails.
121
126
  def assert_format(att, format, error = [att, :format])
122
- if !send(att).to_s.empty?
123
- assert(atts.send(att).to_s.match(format), error)
127
+ if !_atts.send(att).to_s.empty?
128
+ assert(_atts.send(att).to_s.match(format), error)
124
129
  end
125
130
  end
126
131
 
@@ -139,7 +144,7 @@ class Wedge
139
144
  if att_options.key? :form
140
145
  assert_form att, error
141
146
  else
142
- assert(!send(att).to_s.empty?, error)
147
+ assert(!_atts.send(att).to_s.empty?, error)
143
148
  end
144
149
  end
145
150
  end
@@ -148,7 +153,7 @@ class Wedge
148
153
  att_options = _accessor_options[att].deep_dup
149
154
  form_name = att_options.delete :form
150
155
 
151
- f = wedge("#{form_name}_form", send(att).attributes, att_options)
156
+ f = wedge("#{form_name}_form", _atts.send(att).attributes, att_options)
152
157
  assert(f.valid?, [att, f._errors])
153
158
  end
154
159
 
@@ -162,7 +167,7 @@ class Wedge
162
167
  # want to validate presents if they validate for numeric. if they
163
168
  # validate for numeric.
164
169
  # if assert_present(att, error)
165
- if !send(att).to_s.empty?
170
+ if !_atts.send(att).to_s.empty?
166
171
  if client?
167
172
  assert_format(att, /^\-?\d+$/, error)
168
173
  else
@@ -178,7 +183,7 @@ class Wedge
178
183
  end
179
184
 
180
185
  def assert_url(att, error = [att, :not_url])
181
- if !send(att).to_s.empty?
186
+ if !_atts.send(att).to_s.empty?
182
187
  assert_format(att, URL, error)
183
188
  end
184
189
  end
@@ -190,18 +195,18 @@ class Wedge
190
195
  end
191
196
 
192
197
  def assert_email(att, error = [att, :not_email])
193
- if !send(att).to_s.empty?
198
+ if !_atts.send(att).to_s.empty?
194
199
  assert_format(att, EMAIL, error)
195
200
  end
196
201
  end
197
202
 
198
203
  def assert_member(att, set, err = [att, :not_valid])
199
- assert(set.include?(atts.send(att)), err)
204
+ assert(set.include?(_atts.send(att)), err)
200
205
  end
201
206
 
202
207
  def assert_length(att, range, error = [att, :not_in_range])
203
- if !send(att).to_s.empty?
204
- val = atts.send(att).to_s
208
+ if !_atts.send(att).to_s.empty?
209
+ val = _atts.send(att).to_s
205
210
  assert range.include?(val.length), error
206
211
  end
207
212
  end
@@ -234,7 +239,7 @@ class Wedge
234
239
  # @param [Array<Symbol, Symbol>] error The error that should be returned
235
240
  # when the validation fails.
236
241
  def assert_equal(att, value, error = [att, :not_equal])
237
- assert value === atts.send(att), error
242
+ assert value === _atts.send(att), error
238
243
  end
239
244
 
240
245
  # The grand daddy of all assertions. If you want to build custom
data/lib/wedge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Wedge
2
- VERSION = '0.1.29'
2
+ VERSION = '0.1.30'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wedge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29
4
+ version: 0.1.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-07 00:00:00.000000000 Z
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal