motion_bindable 0.1.0 → 0.1.1
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/.travis.yml +2 -0
 - data/README.md +39 -2
 - data/lib/motion_bindable/version.rb +1 -1
 - data/lib/strategies/ui_text_field.rb +5 -3
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a8fecf48e97819f07047c4d906ac09db46aa92da
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3ab8cce360df5457b93e6d1e4d7a41da5d86b901
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2b929c021c2f8b99a00867c8da1b9e976dd4d29e7d6b5b185d30e3ebe1d2da72b25c5d28e55c585f1e7ea6d49f9de1248f855d0b91d9b36cbd4a71a04a614af5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ffdfe46d6554d279a2f7e79002e1e45384a7f6077286192fa4ed8e1bec30bcba688edf93f827c2bf4cad300fa76002b29bb55b312aef1103a0e53048a232ad73
         
     | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Motion Bindable
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            [](https://travis-ci.org/nathankot/motion-bindable)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://codeclimate.com/github/nathankot/motion-bindable)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       3 
6 
     | 
    
         
             
            A simple data binding library for RubyMotion.
         
     | 
| 
       4 
7 
     | 
    
         | 
| 
       5 
8 
     | 
    
         
             
            ## Installation
         
     | 
| 
         @@ -76,14 +79,48 @@ end 
     | 
|
| 
       76 
79 
     | 
    
         | 
| 
       77 
80 
     | 
    
         
             
            When `@name_field.text` or `@address_field.text` changes, so will your model!
         
     | 
| 
       78 
81 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
            ###  
     | 
| 
      
 82 
     | 
    
         
            +
            ### Refresh
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            To refresh the values on your bindable object use this:
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 87 
     | 
    
         
            +
            @bindable.refresh
         
     | 
| 
      
 88 
     | 
    
         
            +
            ```
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            Some strategies only make an update when a `#refresh` is called. See the
         
     | 
| 
      
 91 
     | 
    
         
            +
            _Frequency_ column in the table below.
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            ### Custom Strategies
         
     | 
| 
       80 
94 
     | 
    
         | 
| 
       81 
95 
     | 
    
         
             
            The above example uses the `MotionBindable::Strategies::UITextField`.
         
     | 
| 
       82 
96 
     | 
    
         
             
            which comes with MotionBindable. Take a look in
         
     | 
| 
       83 
97 
     | 
    
         
             
            `lib/motion_bindable/strategies` for the available defaults. You can implement
         
     | 
| 
       84 
98 
     | 
    
         
             
            your own strategies by extending `MotionBindable::Strategy` like so:
         
     | 
| 
       85 
99 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 101 
     | 
    
         
            +
            class CustomBindableStrategy < MotionBindable::Strategy
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              def on_bind
         
     | 
| 
      
 104 
     | 
    
         
            +
                # This runs once when the object is bound.
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              def refresh
         
     | 
| 
      
 108 
     | 
    
         
            +
                # This runs when the object is bound, and each time `@bindable.refresh`
         
     | 
| 
      
 109 
     | 
    
         
            +
                # is called.
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
            end
         
     | 
| 
      
 113 
     | 
    
         
            +
            ```
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            ### Defaults Strategies
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            The following strategies come with motion-bindable and are setup when
         
     | 
| 
      
 118 
     | 
    
         
            +
            `MotionBindable::Strategies.use` is called.
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            | Name                                      | Object Candidates | Direction | Frequency  |
         
     | 
| 
      
 121 
     | 
    
         
            +
            | ----------------------------------------- | ----------------- | --------- | ---------- |
         
     | 
| 
      
 122 
     | 
    
         
            +
            | `MotionBindable::Strategies::UITextField` | Any `UITextField` | Two-way   | On Change  |
         
     | 
| 
      
 123 
     | 
    
         
            +
            | `MotionBindable::Strategies::Proc`        | Any `Proc`        | One-way   | On Refresh |
         
     | 
| 
       87 
124 
     | 
    
         | 
| 
       88 
125 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       89 
126 
     | 
    
         | 
| 
         @@ -9,8 +9,10 @@ module MotionBindable::Strategies 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  # Observe the bound object
         
     | 
| 
       11 
11 
     | 
    
         
             
                  NSNotificationCenter.defaultCenter.addObserver(
         
     | 
| 
       12 
     | 
    
         
            -
                    self, 
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
      
 12 
     | 
    
         
            +
                    self,
         
     | 
| 
      
 13 
     | 
    
         
            +
                    selector: :on_bound_change,
         
     | 
| 
      
 14 
     | 
    
         
            +
                    name: UITextFieldTextDidChangeNotification,
         
     | 
| 
      
 15 
     | 
    
         
            +
                    object: bound
         
     | 
| 
       14 
16 
     | 
    
         
             
                  )
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
18 
     | 
    
         
             
                  # Observe the attribute
         
     | 
| 
         @@ -18,7 +20,7 @@ module MotionBindable::Strategies 
     | 
|
| 
       18 
20 
     | 
    
         
             
                end
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
22 
     | 
    
         
             
                def on_bound_change
         
     | 
| 
       21 
     | 
    
         
            -
                  self.attribute = bound.text
         
     | 
| 
      
 23 
     | 
    
         
            +
                  self.attribute = bound.text unless bound.text.empty?
         
     | 
| 
       22 
24 
     | 
    
         
             
                end
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
                def on_object_change
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: motion_bindable
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Nathan Kot
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013-12- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-12-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bubble-wrap
         
     | 
| 
         @@ -33,6 +33,7 @@ extra_rdoc_files: [] 
     | 
|
| 
       33 
33 
     | 
    
         
             
            files:
         
     | 
| 
       34 
34 
     | 
    
         
             
            - .gemrelease
         
     | 
| 
       35 
35 
     | 
    
         
             
            - .gitignore
         
     | 
| 
      
 36 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
       36 
37 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       37 
38 
     | 
    
         
             
            - Gemfile.lock
         
     | 
| 
       38 
39 
     | 
    
         
             
            - LICENSE.txt
         
     |