wedge 0.1.29 → 0.1.30
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 +4 -4
 - data/lib/wedge.rb +1 -1
 - data/lib/wedge/opal.rb +22 -1
 - data/lib/wedge/plugins/form.rb +11 -5
 - data/lib/wedge/plugins/form/validations.rb +16 -11
 - data/lib/wedge/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: acb8310e6a55b6301fa9634798900c77820a1504
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7a50bc7d53488d69a4dcf746096d1271b672c0af
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ff1b4e7a60559b638977d43df2a0e150adfc2ddfebcf179aa6ce390720d0fdb02e4ead8a8802b51282e2777bff424d02a8398cba47ea7c3f1f7f9f96c04f873f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: babe2985f4b9eda4da72cd9065313123ab93eea0b6da1a3ed0b2aef6047e0f6807f452fcf74a9308a7b3525ed8934e58ab8cf153e0fc887334f5a2436da96427
         
     | 
    
        data/lib/wedge.rb
    CHANGED
    
    
    
        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 
     | 
    
         
            -
               
     | 
| 
      
 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 
     | 
    
         | 
    
        data/lib/wedge/plugins/form.rb
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
                       
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
                       
     | 
| 
      
 278 
     | 
    
         
            +
                      if (_accessor_options[key] || {})[:form]
         
     | 
| 
      
 279 
     | 
    
         
            +
                        send(key)._set_atts val
         
     | 
| 
      
 280 
     | 
    
         
            +
                      else
         
     | 
| 
      
 281 
     | 
    
         
            +
                        accessor = "#{key}="
         
     | 
| 
       277 
282 
     | 
    
         | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
      
 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( 
     | 
| 
      
 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?( 
     | 
| 
      
 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 =  
     | 
| 
      
 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 ===  
     | 
| 
      
 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
    
    
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-07-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: opal
         
     |